feat(login): 增加登录相关功能和验证码处理- 在 user store 中添加新的错误码处理逻辑- 在登录页面添加验证码输入框和重置密码对话框- 实现强制修改密码的功能-优化密码修改后的处理逻辑

This commit is contained in:
陈昱达
2025-08-13 17:47:27 +08:00
parent 0e625655fa
commit 717382611d
3 changed files with 37 additions and 7 deletions

View File

@@ -53,12 +53,20 @@ const actions = {
case 51001:
// 需要发送 短信验证码
resolve({
code: 51001
code: numberResult
})
break
case 50024:
// 需要验证码
resolve({
code: 50024,
code: numberResult,
message: res.content.resultMessage
})
break
case 51003:
// 需要验证码
resolve({
code: numberResult,
message: res.content.resultMessage
})
break

View File

@@ -117,6 +117,11 @@
:user-name="loginForm.userName"
@handleSubmit="handleSubmit"
></send-phone-code>
<reset-password-dialog
:visible.sync="resetPasswordVisible"
:hideDialog="true"
></reset-password-dialog>
</div>
</template>
@@ -130,9 +135,11 @@ import {
} from '@/api/app/user'
import { setToken } from '@/assets/js/utils/auth'
import uuid from 'uuid'
import ResetPasswordDialog from '@/views/system/user/components/ResetPasswordDialog.vue'
// import { indexUser } from '@/api/app/user'
export default {
name: 'Login',
components: { ResetPasswordDialog },
data() {
const validateuserName = (rule, value, callback) => {
if (!validUsername(value)) {
@@ -194,6 +201,7 @@ export default {
loading: false,
passwordType: 'password',
redirect: undefined,
resetPasswordVisible: false,
minute: 120 // 默认120秒 发送间隔
}
},
@@ -302,7 +310,7 @@ export default {
this.loading = false
// this.sendPhoneCode()
}
// 展示验证码
if (res.code === 50024) {
this.loading = false
if (res.message) {
@@ -310,6 +318,11 @@ export default {
}
this.getCaptChaCode()
}
// 强制修改密码
if (res.code === 51003) {
this.loading = false
this.resetPasswordVisible = true
}
})
.catch(err => {
if (this.captchaKey) {

View File

@@ -1,6 +1,5 @@
<template>
<div>
{{ minute }}
<r-dialog
title="修改密码"
:visible.sync="visible"
@@ -81,6 +80,10 @@ export default {
userId: {
type: String,
default: ''
},
hideDialog: {
type: Boolean,
default: false
}
},
data() {
@@ -124,9 +127,15 @@ export default {
smsCode: code
}).then(async res => {
if (res) {
this.$message.success('密码修改成功')
await this.$store.dispatch('user/logout')
this.$router.push(`/login?redirect=${this.$route.fullPath}`)
if (!this.hideDialog) {
this.$message.success('密码修改成功')
await this.$store.dispatch('user/logout')
this.$router.push(`/login?redirect=${this.$route.fullPath}`)
} else {
this.$message.success('密码修改成功')
await this.$store.dispatch('user/logout')
this.handleClose()
}
}
})
},