调整登录和注册的逻辑

This commit is contained in:
jishenghua
2024-05-29 01:11:30 +08:00
parent d3f0ff3777
commit 98e728cc55
3 changed files with 65 additions and 72 deletions

View File

@@ -77,6 +77,8 @@ const user = {
}
commit('SET_INFO', userInfo)
resolve(response)
} else if(response.code == 500010 || response.code == 500011){
resolve(response)
} else{
reject(response)
}

View File

@@ -122,7 +122,7 @@
currentUsername:"",
validate_status:"",
currdatetime:'',
randCode:'',
uuid:'',
randCodeImage:'',
registerFlag:'',
requestCodeSuccess:false,
@@ -176,11 +176,10 @@
this.checked = e.target.checked
},
handleChangeCheckCode(){
this.currdatetime = new Date().getTime();
getAction(`/user/randomImage/${this.currdatetime}`).then(res=>{
getAction('/user/randomImage').then(res=>{
if(res.code == 200){
this.randCode = res.data.codeNum;
this.randCodeImage = res.data.base64;
this.uuid = res.data.uuid
this.randCodeImage = res.data.base64
this.requestCodeSuccess=true
}else{
this.$message.error(res.data)
@@ -198,9 +197,10 @@
if (that.customActiveKey === 'tab1') {
that.form.validateFields([ 'loginName', 'password', 'inputCode' ], { force: true }, (err, values) => {
if (!err) {
if(values.inputCode === this.randCode) {
loginParams.loginName = values.loginName
loginParams.password = md5(values.password)
loginParams.code = values.inputCode
loginParams.uuid = that.uuid
if(that.checked) {
//勾选的时候进行缓存
Vue.ls.set('cache_loginName', values.loginName)
@@ -214,15 +214,7 @@
this.departConfirm(res, loginParams.loginName)
}).catch((err) => {
that.requestFailed(err);
});
} else {
this.$notification['error']({
message: "提示",
description: "验证码错误",
duration: 2
});
this.loginBtn = false
}
})
}else {
that.loginBtn = false;
}
@@ -280,10 +272,13 @@
requestFailed (err) {
this.$notification[ 'error' ]({
message: '登录失败',
description: ((err.response || {}).data || {}).message || err.message || "请求出现错误请稍后再试",
description: ((err.response || {}).data || {}).message || err.message || err.data.message || "请求出现错误请稍后再试",
duration: 4,
});
this.loginBtn = false;
//验证码刷新
this.form.setFieldsValue({'inputCode':''})
this.handleChangeCheckCode()
},
generateCode(value){
this.verifiedCode = value.toLowerCase()

View File

@@ -109,7 +109,7 @@
systemTitle: window.SYS_TITLE,
systemUrl: window.SYS_URL,
form: null,
randCode:'',
uuid:'',
randCodeImage:'',
requestCodeSuccess:false,
state: {
@@ -140,9 +140,9 @@
methods: {
handleChangeCheckCode(){
this.currdatetime = new Date().getTime();
getAction(`/user/randomImage/${this.currdatetime}`).then(res=>{
getAction('/user/randomImage').then(res=>{
if(res.code == 200){
this.randCode = res.data.codeNum;
this.uuid = res.data.uuid;
this.randCodeImage = res.data.base64;
this.requestCodeSuccess=true
}else{
@@ -219,10 +219,11 @@
that.registerBtn = true;
this.form.validateFields((err, values) => {
if (!err) {
if(values.inputCode === this.randCode) {
let register = {
loginName: values.username,
password: md5(values.password)
password: md5(values.password),
code: values.inputCode,
uuid: that.uuid
};
postAction("/user/registerUser", register).then((res) => {
if(res.code === 200){
@@ -245,18 +246,13 @@
duration: 2
});
that.registerBtn = false
//验证码刷新
this.form.setFieldsValue({'inputCode':''})
this.handleChangeCheckCode()
}
}).catch((err) => {
that.requestFailed(err);
})
} else {
this.$notification['error']({
message: "提示",
description: "验证码错误",
duration: 2
});
that.registerBtn = false
}
} else {
that.registerBtn = false
}