|
|
@ -38,7 +38,7 @@ |
|
|
|
</a-input-password> |
|
|
|
</a-form-item> |
|
|
|
|
|
|
|
<a-form-item name="code" :rules="[{ validator }]"> |
|
|
|
<a-form-item name="code"> |
|
|
|
<!-- 验证码 --> |
|
|
|
<a-input v-model:value="code" placeholder="验证码" class="loginInfo"> |
|
|
|
<template #prefix> |
|
|
@ -49,7 +49,7 @@ |
|
|
|
style="margin-right: 20px" /> |
|
|
|
</template> |
|
|
|
<template #addonAfter> |
|
|
|
<ns-verify @get-code="onGetCode" /> |
|
|
|
<ns-verify @get-code="onGetCode" ref="verifyRef" /> |
|
|
|
</template> |
|
|
|
</a-input> |
|
|
|
</a-form-item> |
|
|
@ -78,6 +78,7 @@ |
|
|
|
import { authorizationService } from '/nerv-base/store/modules/authorization-service'; |
|
|
|
import { Cookies } from '/nerv-lib/util/cookie'; |
|
|
|
import { storeToRefs } from 'pinia'; |
|
|
|
import { NsMessage } from '/nerv-lib/component'; |
|
|
|
|
|
|
|
export default defineComponent({ |
|
|
|
name: 'UserLogin', |
|
|
@ -94,6 +95,7 @@ |
|
|
|
const initUrl = ref(''); |
|
|
|
const verifyCode = ref(''); |
|
|
|
const code = ref(); |
|
|
|
const verifyRef = ref(); |
|
|
|
const isRemember = ref(false); |
|
|
|
title.value = '账号登录'; |
|
|
|
// title.value = appConfig.title ? appConfig.title : '账号登录'; |
|
|
@ -123,40 +125,19 @@ |
|
|
|
const submit = (value): void => { |
|
|
|
console.log(value); |
|
|
|
|
|
|
|
// if (password.value === '') { |
|
|
|
// errorMsg.value = '请输入密码'; |
|
|
|
// errorShow.value = true; |
|
|
|
// return; |
|
|
|
// } |
|
|
|
// if (userName.value === '') { |
|
|
|
// errorMsg.value = '请输入账号'; |
|
|
|
// errorShow.value = true; |
|
|
|
// return; |
|
|
|
// } |
|
|
|
// if (!code.value) { |
|
|
|
// // errorMsg.value = '请输入验证码'; |
|
|
|
// // errorShow.value = true; |
|
|
|
// return; |
|
|
|
// } |
|
|
|
// if (code.value.toLocaleLowerCase() !== verifyCode.value.toLocaleLowerCase()) { |
|
|
|
// errorMsg.value = '请输入正确的验证码'; |
|
|
|
// errorShow.value = true; |
|
|
|
// return; |
|
|
|
// } |
|
|
|
if (userName.value !== '' && password.value !== '') { |
|
|
|
errorShow.value = false; |
|
|
|
let data = JSON.stringify({ |
|
|
|
accountNo: userName.value.trim(), |
|
|
|
password: password.value.trim(), |
|
|
|
}); |
|
|
|
|
|
|
|
validator(null, value.code) |
|
|
|
.then(() => { |
|
|
|
// 记住密码 |
|
|
|
rememberFunc(data); |
|
|
|
loading.value = true; |
|
|
|
async function logins() { |
|
|
|
try { |
|
|
|
const res = await configStore.userLogin(JSON.parse(data)); |
|
|
|
|
|
|
|
verifyRef.value?.reload(); |
|
|
|
if (res.data?.token) { |
|
|
|
if (res.data?.token) { |
|
|
|
Cookies.set('nervsid', res.data?.token); |
|
|
@ -218,7 +199,15 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
logins(); |
|
|
|
}) |
|
|
|
.catch((flag) => { |
|
|
|
if (flag) { |
|
|
|
NsMessage.error('请输入正确的验证码'); |
|
|
|
verifyRef.value?.reload(); |
|
|
|
} else { |
|
|
|
NsMessage.error('请输入验证码'); |
|
|
|
} |
|
|
|
}); |
|
|
|
}; |
|
|
|
const checkoutLogo = (): void => { |
|
|
|
logUrl.value = ''; |
|
|
@ -232,10 +221,11 @@ |
|
|
|
verifyCode.value = res; |
|
|
|
}; |
|
|
|
|
|
|
|
const validator = async (rule, value) => { |
|
|
|
if (!value) return Promise.reject('请输入验证码'); |
|
|
|
const validator = (rule, value) => { |
|
|
|
if (!value) return Promise.reject(false); |
|
|
|
if (value?.toLocaleLowerCase() !== verifyCode.value.toLocaleLowerCase()) |
|
|
|
return Promise.reject('请输入正确的验证码'); |
|
|
|
return Promise.reject(true); |
|
|
|
return Promise.resolve(); |
|
|
|
}; |
|
|
|
return { |
|
|
|
validator, |
|
|
@ -258,6 +248,7 @@ |
|
|
|
errorShow, |
|
|
|
configStore, |
|
|
|
isRemember, |
|
|
|
verifyRef, |
|
|
|
}; |
|
|
|
}, |
|
|
|
created() { |
|
|
|