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

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

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