|
@@ -129,6 +129,12 @@ module.exports = app => {
|
|
|
const rule = { mobile: { type: 'mobile', allowEmpty: false } };
|
|
|
ctx.helper.validate(rule);
|
|
|
|
|
|
+ // 查找是否有重复的认证手机
|
|
|
+ const accountData = await ctx.service.projectAccount.getDataByCondition({ project_id: ctx.session.sessionProject.id, auth_mobile: mobile });
|
|
|
+ if (accountData !== null) {
|
|
|
+ throw '此手机号码已被使用,请重新输入!';
|
|
|
+ }
|
|
|
+
|
|
|
const result = await ctx.service.projectAccount.setSMSCode(sessionUser.accountId, mobile);
|
|
|
if (!result) {
|
|
|
throw '获取验证码失败';
|
|
@@ -148,22 +154,30 @@ module.exports = app => {
|
|
|
* @return {void}
|
|
|
*/
|
|
|
async bindMobile(ctx) {
|
|
|
+ const response = {
|
|
|
+ err: 0,
|
|
|
+ msg: '',
|
|
|
+ };
|
|
|
try {
|
|
|
const rule = ctx.service.projectAccount.rule('bindMobile');
|
|
|
ctx.helper.validate(rule);
|
|
|
|
|
|
const sessionUser = ctx.session.sessionUser;
|
|
|
+
|
|
|
const result = await ctx.service.projectAccount.bindMobile(sessionUser.accountId, ctx.request.body, ctx.session.sessionProject.id);
|
|
|
|
|
|
if (!result) {
|
|
|
throw '绑定手机失败!';
|
|
|
}
|
|
|
- this.setMessage('绑定成功', this.messageType.SUCCESS);
|
|
|
+ // this.setMessage('绑定成功', this.messageType.SUCCESS);
|
|
|
+ response.msg = '绑定成功';
|
|
|
+ response.url = ctx.request.header.referer;
|
|
|
} catch (error) {
|
|
|
console.log(error);
|
|
|
- this.setMessage(error.toString(), this.messageType.ERROR);
|
|
|
+ response.err = 1;
|
|
|
+ response.msg = error.toString();
|
|
|
}
|
|
|
- ctx.redirect(ctx.request.header.referer);
|
|
|
+ ctx.body = response;
|
|
|
}
|
|
|
|
|
|
/**
|