|
|
@@ -2,8 +2,8 @@
|
|
|
import ErrorTips from './components/ErrorTips.vue'
|
|
|
|
|
|
const loginForm = ref({
|
|
|
- username: '',
|
|
|
- password: '',
|
|
|
+ username: 'ra.admin',
|
|
|
+ password: 'abc123456789',
|
|
|
email: '',
|
|
|
code: ''
|
|
|
})
|
|
|
@@ -11,8 +11,8 @@ const loginForm = ref({
|
|
|
const status = ref('login')
|
|
|
watch(status, () => {
|
|
|
loginForm.value = {
|
|
|
- username: '',
|
|
|
- password: '',
|
|
|
+ username: 'ra.admin',
|
|
|
+ password: 'abc123456789',
|
|
|
email: '',
|
|
|
code: ''
|
|
|
}
|
|
|
@@ -22,10 +22,11 @@ watch(status, () => {
|
|
|
email: false,
|
|
|
code: false
|
|
|
}
|
|
|
+ verificationCode.value = ''
|
|
|
getCode()
|
|
|
})
|
|
|
|
|
|
-const loginError = ref({
|
|
|
+const loginError: any = ref({
|
|
|
username: false,
|
|
|
password: false,
|
|
|
email: false,
|
|
|
@@ -34,7 +35,7 @@ const loginError = ref({
|
|
|
const verificationCode = ref()
|
|
|
// 获取验证码
|
|
|
const getCode = () => {
|
|
|
- $api.getVerifcationCode().then((res) => {
|
|
|
+ $api.getVerifcationCode().then((res: any) => {
|
|
|
verificationCode.value = `data:image/png;base64,${res.data.imagePngBase64}`
|
|
|
console.log(res)
|
|
|
})
|
|
|
@@ -47,7 +48,7 @@ const handleCheckUser = () => {
|
|
|
return
|
|
|
}
|
|
|
// 这里是验证用户是否存在的逻辑
|
|
|
- $api.isUserNameExit({ uname: loginForm.value.username }).then((res) => {
|
|
|
+ $api.isUserNameExit({ uname: loginForm.value.username }).then((res: any) => {
|
|
|
if (res.code === 200) {
|
|
|
if (res.data.msg !== 'no_exist') {
|
|
|
isUserNameExit.value = true
|
|
|
@@ -70,8 +71,29 @@ const handleLogin = () => {
|
|
|
psw: loginForm.value.password,
|
|
|
verifcation_code: loginForm.value.code
|
|
|
})
|
|
|
- .then((res) => {
|
|
|
+ .then((res: any) => {
|
|
|
console.log(res)
|
|
|
+ if (res.code === 200) {
|
|
|
+ const { data } = res
|
|
|
+ if (data.msg === 'today') {
|
|
|
+ ElMessageBox.alert('Your password will expire today, please reset', 'Prompt', {
|
|
|
+ confirmButtonText: 'OK',
|
|
|
+ type: 'warning'
|
|
|
+ })
|
|
|
+ } else if (data.msg === 'last') {
|
|
|
+ ElMessageBox.alert(
|
|
|
+ `Your password will expire in${data.data}days, please reset`,
|
|
|
+ 'Prompt',
|
|
|
+ {
|
|
|
+ confirmButtonText: 'OK',
|
|
|
+ type: 'warning'
|
|
|
+ }
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .finally(() => {
|
|
|
+ getCode()
|
|
|
})
|
|
|
}
|
|
|
|
|
|
@@ -89,7 +111,7 @@ const handleSendPassword = () => {
|
|
|
login: loginForm.value.username,
|
|
|
email: loginForm.value.email
|
|
|
})
|
|
|
- .then((res) => {
|
|
|
+ .then((res: any) => {
|
|
|
if (res.code === 200) {
|
|
|
isEmailTips.value = true
|
|
|
}
|
|
|
@@ -97,7 +119,7 @@ const handleSendPassword = () => {
|
|
|
}
|
|
|
|
|
|
const isEmailTips = ref(false)
|
|
|
-const handleDeleteEmailTips = (type: string) => {
|
|
|
+const handleDeleteEmailTips = (type?: any) => {
|
|
|
isEmailTips.value = false
|
|
|
if (type) {
|
|
|
loginError.value[type] = false
|
|
|
@@ -233,7 +255,7 @@ const errorTipsRef = ref()
|
|
|
placeholder="Verification Code"
|
|
|
@focus="handleDeleteEmailTips('code')"
|
|
|
><template #append>
|
|
|
- <img class="verification-code-img" src="./image/code.png" alt="" /> </template
|
|
|
+ <img class="verification-code-img" :src="verificationCode" alt="" /> </template
|
|
|
></el-input>
|
|
|
<div class="error" v-if="loginError.code">
|
|
|
This is the prompt information given by the verification
|