login
This commit is contained in:
parent
c9efaf9643
commit
6c83a28721
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
<UserFormInput
|
<UserFormInput
|
||||||
title="비밀번호"
|
title="비밀번호"
|
||||||
name="pw"
|
name="password"
|
||||||
type="password"
|
type="password"
|
||||||
:is-alert="passwordAlert"
|
:is-alert="passwordAlert"
|
||||||
@update:data="handlePasswordChange"
|
@update:data="handlePasswordChange"
|
||||||
@ -36,6 +36,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
|
import $api from '@api';
|
||||||
|
import router from '@/router';
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
import UserFormInput from '@c/input/UserFormInput.vue';
|
import UserFormInput from '@c/input/UserFormInput.vue';
|
||||||
|
|
||||||
@ -44,8 +46,6 @@
|
|||||||
const idAlert = ref(false);
|
const idAlert = ref(false);
|
||||||
const passwordAlert = ref(false);
|
const passwordAlert = ref(false);
|
||||||
|
|
||||||
const emit = defineEmits(['submit']);
|
|
||||||
|
|
||||||
const handleIdChange = value => {
|
const handleIdChange = value => {
|
||||||
id.value = value;
|
id.value = value;
|
||||||
idAlert.value = false;
|
idAlert.value = false;
|
||||||
@ -56,12 +56,23 @@
|
|||||||
passwordAlert.value = false;
|
passwordAlert.value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSubmit = () => {
|
const handleSubmit = async () => {
|
||||||
idAlert.value = id.value.trim() === '';
|
|
||||||
passwordAlert.value = password.value.trim() === '';
|
|
||||||
|
|
||||||
if (!idAlert.value && !passwordAlert.value) {
|
try {
|
||||||
emit('submit', { id: id.value, password: password.value });
|
const response = await $api.post('user/login', {
|
||||||
|
loginId: id.value,
|
||||||
|
password: password.value,
|
||||||
|
remember: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.status === 200) {
|
||||||
|
console.log('로그인 성공', response.data);
|
||||||
|
router.push('/');
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('로그인 실패', error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -2,33 +2,15 @@
|
|||||||
<div class="d-flex justify-content-center align-items-center vh-100">
|
<div class="d-flex justify-content-center align-items-center vh-100">
|
||||||
<div class="container container-p-y rounded bg-white" style="max-width: 500px">
|
<div class="container container-p-y rounded bg-white" style="max-width: 500px">
|
||||||
<LogoHeader title="LOCALNET" />
|
<LogoHeader title="LOCALNET" />
|
||||||
<LoginForm @submit="handleSubmit" />
|
<LoginForm />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import $api from '@api';
|
|
||||||
import router from '@/router';
|
|
||||||
import LoginForm from '@c/user/LoginForm.vue';
|
import LoginForm from '@c/user/LoginForm.vue';
|
||||||
import LogoHeader from '@c/user/LogoHeader.vue';
|
import LogoHeader from '@c/user/LogoHeader.vue';
|
||||||
|
|
||||||
const handleSubmit = async ({ id, password }) => {
|
|
||||||
try {
|
|
||||||
const response = await $api.post('user/login', {
|
|
||||||
loginId: id,
|
|
||||||
password: password,
|
|
||||||
remember: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (response.status === 200) {
|
|
||||||
console.log('로그인 성공', response.data);
|
|
||||||
router.push('/');
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error('로그인 실패', error);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style></style>
|
<style></style>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user