提交 034361e3 编写于 作者: chengxiang.li's avatar chengxiang.li

update 获取 验证码、重设密码、登录

上级 3b61d45b
...@@ -30,6 +30,26 @@ export const handleLogin = data => { ...@@ -30,6 +30,26 @@ export const handleLogin = data => {
}) })
} }
// 忘记密码时 获取验证码
export const handleGetAuthCode = data => {
return fetch({
headers,
url: getBaseUrl(`account/authCode`),
method: 'post',
data: data,
description: '获取验证码',
})
}
// 重设密码
export const handleResetPWD = data => {
return fetch({
headers,
url: getBaseUrl(`account/password/reset`),
method: 'post',
data: data,
description: '忘记密码之重设密码',
})
}
...@@ -71,7 +71,7 @@ module.exports = { ...@@ -71,7 +71,7 @@ module.exports = {
key: '', key: '',
content: '' content: ''
}; };
// 开发阶段后端接口还没处理加密,先传 原始json数据 // 开发阶段后端接口还没处理加密,先传 原始json数据 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 后端加密OK后 再用下面的注释代码
params.content = content; params.content = content;
// params.content = this.AesEncrypt(content, aesKey); // params.content = this.AesEncrypt(content, aesKey);
params.key = this.RsaEncrypt(aesKey, pubKey); params.key = this.RsaEncrypt(aesKey, pubKey);
......
...@@ -93,7 +93,7 @@ ...@@ -93,7 +93,7 @@
import { ssoLogin2, getDeviceInfo } from '@/utils/utils'; import { ssoLogin2, getDeviceInfo } from '@/utils/utils';
import { mapActions } from 'vuex'; import { mapActions } from 'vuex';
import md5 from 'js-md5'; import md5 from 'js-md5';
import { handleLogin } from '@/utils/account/accountApi'; import { handleLogin, handleGetAuthCode, handleResetPWD } from '@/utils/account/accountApi';
export default { export default {
...@@ -206,47 +206,79 @@ ...@@ -206,47 +206,79 @@
} }
// ------------------------ Old Start------------------------------- // ------------------------ Old Start-------------------------------
let params = { // let params = {
receiver: this.resetPassword.mobile, // receiver: this.resetPassword.mobile,
token: localStorage.getItem("token"), // token: localStorage.getItem("token"),
flag: 2, //1表示注册 2表示忘记密码 // flag: 2, //1表示注册 2表示忘记密码
gaoFlag: 1 ,//1表示saas 2表示高血压项目 // gaoFlag: 1 ,//1表示saas 2表示高血压项目
deviceInfo: getDeviceInfo() // deviceInfo: getDeviceInfo()
}; // };
this.saasPOST('/mobiles/sendCaptchaNew',params, 'application/x-www-form-urlencoded;charset=UTF-8').then(data => { // this.saasPOST('/mobiles/sendCaptchaNew',params, 'application/x-www-form-urlencoded;charset=UTF-8').then(data => {
if (data.mobileFlag == 2) { // if (data.mobileFlag == 2) {
this.resetMobileErr = true; // this.resetMobileErr = true;
this.resetMobileErrText = '该手机号尚未注册!'; // this.resetMobileErrText = '该手机号尚未注册!';
return; // return;
} else { // } else {
const TIME_COUNT = 60; // const TIME_COUNT = 60;
if (!this.timer) { // if (!this.timer) {
this.countDown = TIME_COUNT; // this.countDown = TIME_COUNT;
this.timer = setInterval(() => { // this.timer = setInterval(() => {
if (this.countDown > 0 && this.countDown <= TIME_COUNT) { // if (this.countDown > 0 && this.countDown <= TIME_COUNT) {
this.countDown--; // this.countDown--;
} else { // } else {
this.countDown = 0; // this.countDown = 0;
clearInterval(this.timer); // clearInterval(this.timer);
this.timer = null; // this.timer = null;
} // }
}, 1000) // }, 1000)
} // }
} // }
}).catch( err => { // }).catch( err => {
this.$message({ // this.$message({
message: '系统错误!', // message: '系统错误!',
type: 'error' // type: 'error'
}); // });
}) // })
// ------------------------ Old End------------------------------- // ------------------------ Old End-------------------------------
// ------------------------ New Start------------------------------- // ------------------------ New Start-------------------------------
// let params = { let paramsObj = {
// mobilePhone: this.resetPassword.mobile, mobile: this.resetPassword.mobile,
// flag: 4, // 4 重置密码 flag: 4, // 4 重置密码
// }; };
let getAuthCodeCB = params => {
handleGetAuthCode(params).then(res => {
console.log('>>>>>>login res ', res)
if (res.code != '000000') {
this.resetMobileErr = true;
this.resetMobileErrText = res.message;
return;
} else {
const TIME_COUNT = 60;
if (!this.timer) {
this.countDown = TIME_COUNT;
this.timer = setInterval(() => {
if (this.countDown > 0 && this.countDown <= TIME_COUNT) {
this.countDown--;
} else {
this.countDown = 0;
clearInterval(this.timer);
this.timer = null;
}
}, 1000)
}
}
}).catch(err => {
this.$message({
message: '系统错误!',
type: 'error'
});
})
};
this.sendEncryptRequest( paramsObj, getAuthCodeCB)
...@@ -332,22 +364,22 @@ ...@@ -332,22 +364,22 @@
password: md5(this.loginData.password).toUpperCase(), password: md5(this.loginData.password).toUpperCase(),
}; };
let loginCB = params => { let loginCB = params => {
handleLogin(params).then(data => { handleLogin(params).then(res => {
console.log('>>>>>>login res ', data) console.log('>>>>>>login res ', res)
if (data.code == '216509' || data.code == '216502' || data.code == '100001' ) { if (res.code == '216509' || res.code == '216502' || res.code == '100001' ) {
this.loginPWDErr = true; this.loginPWDErr = true;
this.loginPWDErrText = '手机号或密码不正确!'; this.loginPWDErrText = '手机号或密码不正确!';
return; return;
} }
if (data.code == '216508') { if (res.code == '216508') {
this.loginMobileErr = true; this.loginMobileErr = true;
this.loginMobileErrText = '该手机号尚未注册!'; this.loginMobileErrText = '该手机号尚未注册!';
return; return;
} }
debugger;
localStorage.setItem("token", data.token); localStorage.setItem("token", res.data.token);
vm.changeToken(data.token) vm.changeToken(res.data.token)
localStorage.setItem("storageToken", data.token); localStorage.setItem("storageToken", res.data.token);
this.$router.push('/'); this.$router.push('/');
}).catch(err => { }).catch(err => {
...@@ -404,39 +436,84 @@ ...@@ -404,39 +436,84 @@
||!this.checkPwdVal(this.resetPassword.password)) { ||!this.checkPwdVal(this.resetPassword.password)) {
return; return;
} }
let para = {
// ------------------------ Old Start-------------------------------
// ------------------------ Old End-------------------------------
// ------------------------ New Start-------------------------------
// ------------------------ New End-------------------------------
// ------------------------ Old Start-------------------------------
// let para = {
// mobile: this.resetPassword.mobile,
// authCode: this.resetPassword.authCode
// }
// this.saasGET('/mobiles/checkCaptcha',para).then(data => {
// let req = {
// mobile: this.resetPassword.mobile,
// password: md5(this.resetPassword.password).toUpperCase()
// }
// this.saasPUT('/login/password',req).then(data => {
// this.$message({
// message: '重设密码成功,请重新登录!',
// type: 'success'
// });
// setTimeout(function () {
// window.location.reload();
// }, 2000)
// }).catch( err => {
// this.$message({
// message: '系统错误!',
// type: 'error'
// });
// })
// }).catch( err => {
// /*this.$message({
// message: '验证码已过期或不存在!',
// type: 'error'
// });*/
// this.resetCodeErr = true;
// this.resetCodeErrText = '验证码已过期或不存在';
// return;
// })
// ------------------------ Old End-------------------------------
// ------------------------ New Start-------------------------------
let paramsObj = {
mobile: this.resetPassword.mobile, mobile: this.resetPassword.mobile,
authCode: this.resetPassword.authCode authCode: this.resetPassword.authCode,
} password: md5(this.resetPassword.password).toUpperCase()
this.saasGET('/mobiles/checkCaptcha',para).then(data => { };
let req = { let resetPWDCB = params => {
mobile: this.resetPassword.mobile, handleResetPWD(params).then(res => {
password: md5(this.resetPassword.password).toUpperCase() console.log('>>>>>>login res ', res)
} if(res && res.code == '000000'){
this.saasPUT('/login/password',req).then(data => { this.$message({
this.$message({ message: '重设密码成功,请重新登录!',
message: '重设密码成功,请重新登录!', type: 'success'
type: 'success' });
}); setTimeout(function () {
setTimeout(function () { window.location.reload();
window.location.reload(); }, 2000)
}, 2000) }else{
}).catch( err => { this.$message({
message: (res && res.message) || '系统错误!',
type: 'error'
});
}
}).catch(err => {
this.$message({ this.$message({
message: '系统错误!', message: '系统错误!',
type: 'error' type: 'error'
}); });
}) })
};
this.sendEncryptRequest( paramsObj, resetPWDCB)
}).catch( err => { // ------------------------ New End-------------------------------
/*this.$message({
message: '验证码已过期或不存在!',
type: 'error'
});*/
this.resetCodeErr = true;
this.resetCodeErrText = '验证码已过期或不存在';
return;
})
} }
} }
} }
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册