2023-09-01 03:10:33 +07:00
|
|
|
<template>
|
|
|
|
|
|
|
|
<v-app>
|
|
|
|
<top-bar :show-back-icon="true" :page-title="pageTitle" />
|
|
|
|
<v-main>
|
2023-10-01 02:03:16 +07:00
|
|
|
<div class="text-center mt-8 mb-16">
|
|
|
|
<div class="text-h4 font-weight-bold">
|
|
|
|
ยินดีต้อนรับกลับสู่
|
|
|
|
<div>Little Lines</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="mx-5">
|
|
|
|
<v-text-field
|
|
|
|
class="username"
|
|
|
|
v-model="input.username"
|
|
|
|
label="อีเมล"
|
|
|
|
variant="solo"
|
|
|
|
>
|
|
|
|
<template v-slot:append-inner>
|
|
|
|
<img
|
|
|
|
class="iconEdit"
|
|
|
|
:src="edit"
|
|
|
|
>
|
|
|
|
</template>
|
|
|
|
</v-text-field>
|
|
|
|
|
|
|
|
<v-text-field
|
|
|
|
class="password"
|
|
|
|
v-model="input.password"
|
|
|
|
label="รหัสผ่าน"
|
|
|
|
variant="solo"
|
|
|
|
>
|
|
|
|
<template v-slot:append-inner>
|
|
|
|
<img
|
|
|
|
class="iconEdit"
|
|
|
|
:src="edit"
|
|
|
|
>
|
|
|
|
<img
|
|
|
|
class="iconEyeNotLooking"
|
|
|
|
:src="eyeNotLooking"
|
|
|
|
>
|
|
|
|
</template>
|
|
|
|
</v-text-field>
|
|
|
|
</div>
|
2023-09-01 03:10:33 +07:00
|
|
|
|
2023-10-01 02:03:16 +07:00
|
|
|
<v-contaioner>
|
|
|
|
<v-row class="button">
|
|
|
|
<v-btn @click.prevent="login" rounded="xl" variant="flat" class="text-white" width="45vw" height="44px" color="#f16322">
|
|
|
|
ลงชื่อเข้าใช้</v-btn>
|
|
|
|
</v-row>
|
|
|
|
<v-row class="button">
|
|
|
|
<v-btn class="text-none" rounded="xl" variant="tonal" width="45vw" height="44px">
|
|
|
|
ลงชื่อเข้าใช้ด้วย Google</v-btn>
|
|
|
|
</v-row>
|
|
|
|
<v-row class="button">
|
|
|
|
<v-btn :to="{name: 'register'}" rounded="xl" variant="tonal" width="45vw" height="44px">
|
|
|
|
ฉันต้องการสมัครสมาชิก</v-btn>
|
|
|
|
</v-row>
|
|
|
|
</v-contaioner>
|
|
|
|
|
|
|
|
|
2023-09-01 03:10:33 +07:00
|
|
|
|
|
|
|
</v-main>
|
|
|
|
</v-app>
|
|
|
|
|
|
|
|
</template>
|
|
|
|
|
2023-10-01 02:03:16 +07:00
|
|
|
<script setup>
|
|
|
|
import edit from '../../icons/Material/edit.svg';
|
|
|
|
import eyeNotLooking from '../../icons/Material/eye-not-looking.svg';
|
|
|
|
</script>
|
|
|
|
|
2023-09-01 03:10:33 +07:00
|
|
|
<script>
|
2023-09-01 03:35:39 +07:00
|
|
|
import {RouterLink} from 'vue-router';
|
2023-09-01 03:10:33 +07:00
|
|
|
import TopBar from '@/components/TopBar.vue';
|
2023-10-01 02:03:16 +07:00
|
|
|
import { VContainer } from 'vuetify/lib/components/index.mjs';
|
2023-09-01 03:10:33 +07:00
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
TopBar
|
|
|
|
},
|
|
|
|
name: 'Login',
|
|
|
|
data() {
|
|
|
|
return {
|
2023-09-01 03:35:39 +07:00
|
|
|
pageTitle: 'ลงชื่อเข้าใช้',
|
2023-09-01 03:10:33 +07:00
|
|
|
input: {
|
|
|
|
username: '',
|
|
|
|
password: ''
|
|
|
|
}
|
|
|
|
};
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
login() {
|
2023-09-24 18:35:25 +07:00
|
|
|
if (this.input.username !== '' && this.input.password !== '') {
|
2023-09-01 03:10:33 +07:00
|
|
|
console.log('Authenticated: Checking with Backend');
|
2023-09-30 12:01:28 +07:00
|
|
|
fetch(`http://test.techtransthai.org:5001/api/users/login`, {
|
2023-09-27 00:47:59 +07:00
|
|
|
method: "POST",
|
|
|
|
headers: {
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
},
|
|
|
|
body: JSON.stringify({
|
|
|
|
username: this.input.username,
|
|
|
|
password: this.input.password,
|
|
|
|
}),
|
|
|
|
})
|
|
|
|
.then((res) => {
|
|
|
|
if (res.ok) {
|
|
|
|
return res.json();
|
|
|
|
} else {
|
|
|
|
throw Error(`Login failed (${res.status})`);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.then((data) => {
|
2023-09-27 00:58:43 +07:00
|
|
|
console.log(data.success);
|
|
|
|
sessionStorage.setItem('current_user', data.user.username);
|
2023-09-27 00:47:59 +07:00
|
|
|
this.$router.push({ name: 'home' });
|
|
|
|
})
|
|
|
|
.catch((err) => {
|
|
|
|
console.log(err);
|
|
|
|
// Handle the error, e.g., display an error message to the user
|
|
|
|
});
|
2023-09-01 03:10:33 +07:00
|
|
|
} else {
|
|
|
|
console.log('Username and Password cannot be empty');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|
2023-10-01 02:03:16 +07:00
|
|
|
|
|
|
|
<style>
|
|
|
|
.username {
|
|
|
|
margin-bottom: -21px;
|
|
|
|
}
|
|
|
|
.iconEdit, .iconEyeNotLooking {
|
|
|
|
width: 25px;
|
|
|
|
height: 25px;
|
|
|
|
}
|
|
|
|
.iconEdit {
|
|
|
|
margin-right: 10px;
|
|
|
|
}
|
|
|
|
.iconEyeNotLooking {
|
|
|
|
margin-right: 10px;
|
|
|
|
margin-left: 10px;
|
|
|
|
}
|
|
|
|
.button {
|
|
|
|
padding: 10px;
|
|
|
|
display: flex;
|
|
|
|
justify-content: center;
|
|
|
|
align-content: center;
|
|
|
|
}
|
|
|
|
</style>
|