Authored by 郭成尧

merge-master

... ... @@ -238,7 +238,7 @@ class DetailModel extends global.yoho.BaseModel {
// 获取资讯
return this._getArticle(id).then(data => {
// 调用接口失败
if (!data || data.code !== 200) {
if (!data || data.code !== 200 || _.get(data, 'data.status') !== 1) {
result.code = 400;
return result;
}
... ...
... ... @@ -346,7 +346,11 @@ const bind = {
// 第三方绑定手机号发送短信
thirdSendMsgApi: (req, res, next) => {
req.ctx(BindServiceModel).sendThirdBindMobileCodeOnly(req.body).then(result => {
let params = {
superCapture: req.body.geetest_challenge ? config.superCapture : ''
};
req.ctx(BindServiceModel).sendThirdBindMobileCodeOnly(Object.assign({}, req.body, params)).then(result => {
if (_.get(result, 'code', 400) === 200) {
return next();
}
... ... @@ -378,7 +382,11 @@ const bind = {
// 通过邮箱绑定手机号发送短信
sendMsgApi: (req, res, next) => {
req.ctx(BindServiceModel).sendChangeBindMobileCodeOnly(req.body).then(result => {
let params = {
superCapture: req.body.geetest_challenge ? config.superCapture : ''
};
req.ctx(BindServiceModel).sendChangeBindMobileCodeOnly(Object.assign({}, req.body, params)).then(result => {
if (_.get(result, 'code', 400) === 200) {
return next();
}
... ... @@ -388,7 +396,11 @@ const bind = {
// 检查手机是否绑定
changeMobileCheckApi: (req, res, next) => {
req.ctx(BindServiceModel).changeMobileCheck(req.body).then(result => {
let params = {
superCapture: req.body.geetest_challenge ? config.superCapture : ''
};
req.ctx(BindServiceModel).changeMobileCheck(Object.assign({}, req.body, params)).then(result => {
if (_.get(result, 'data.isBind', '') === 'N' &&
_.get(result, 'data.isRegister', '') === 'N') {
return next();
... ... @@ -433,10 +445,12 @@ const bind = {
// 调用绑定接口
forceBindMobileApi: (req, res, next) => {
req.ctx(BindServiceModel).bindEmailLoginMobile(Object.assign(req.body, {
let params = {
email: req.session.bindEmail,
password: req.session.bindPassword,
})).then(result => {
};
req.ctx(BindServiceModel).bindEmailLoginMobile(Object.assign({}, req.body, params)).then(result => {
if (_.get(result, 'code', 400) !== 200) {
return res.json(result);
}
... ...
... ... @@ -104,10 +104,12 @@ class BindServiceModel extends global.yoho.BaseModel {
// 强制绑定手机↓↓↓↓ -> 邮件登录绑定手机号发送短信
sendChangeBindMobileCodeOnly(params) {
return this.get({data: {
method: 'app.bind.sendChangeBindMobileCodeOnly',
business_line: 'yohobuy',
method: 'app.bind.sendChangeBindMobileCodeOnlyImg',
mobile: params.mobile || '',
area: params.area || '86'
area: params.area || '86',
degrees: params.captcha || '',
superCapture: params.superCapture || '',
fromPage: PAGE
}});
}
... ... @@ -116,7 +118,6 @@ class BindServiceModel extends global.yoho.BaseModel {
return this.get({
data: Object.assign({
method: 'app.bind.changeMobileCheck',
business_line: 'yohobuy',
}, params)
});
}
... ... @@ -125,7 +126,6 @@ class BindServiceModel extends global.yoho.BaseModel {
bindEmailLoginMobile(params) {
return this.get({data: {
method: 'app.bind.bindEmailLoginMobile',
business_line: 'yohobuy',
mobile: params.mobile || '',
area: params.area || '86',
code: params.code,
... ... @@ -137,10 +137,12 @@ class BindServiceModel extends global.yoho.BaseModel {
// 第三方绑定手机号发送短信
sendThirdBindMobileCodeOnly(params) {
return this.get({data: {
method: 'app.bind.sendThirdBindMobileCodeOnly',
business_line: 'yohobuy',
method: 'app.bind.sendThirdBindMobileCodeOnlyImg',
mobile: params.mobile || '',
area: params.area || '86'
area: params.area || '86',
superCapture: params.superCapture || '',
degrees: params.captcha || '',
fromPage: PAGE
}});
}
... ... @@ -148,7 +150,6 @@ class BindServiceModel extends global.yoho.BaseModel {
thirdBindMobile(params) {
return this.get({data: {
method: 'app.bind.bindMobile',
business_line: 'yohobuy',
mobile: params.mobile || '',
area: params.area || '86',
code: params.code,
... ...
... ... @@ -84,6 +84,7 @@ router.get('/passport/password/resetsuccess', reset.passwordResetOkPage); // 重
// 通过邮箱登录绑定手机号
router.get('/passport/bind/forceBindMobile', validateCode.load, bind.forceBindMobilePage);
router.post('/passport/bind/forceSendMsg',
validateCode.check,
bind.isCheckEmailPassword,
bind.sendMsgApi,
bind.forceSendMsg
... ... @@ -97,7 +98,7 @@ router.post('/passport/bind/continueMobile', bind.isCheckEmailPassword, bind.for
// 第三方绑定手机号
router.get('/passport/bind/index', validateCode.load, bind.thirdBindMobilePage);
router.post('/passport/bind/thirdSendMsg', bind.thirdSendMsgApi, bind.forceSendMsg);
router.post('/passport/bind/thirdSendMsg', validateCode.check, bind.thirdSendMsgApi, bind.forceSendMsg);
router.post('/passport/bind/thirdMobileCheck',
bind.changeMobileCheckApi,
bind.thirdBindMobileApi
... ...
... ... @@ -4,7 +4,14 @@ import Page from 'yoho-page';
import api from '../api';
import dialog from 'plugin/dialog';
import bindDialogHbs from 'passport/bind-dialog-tip.hbs';
import Validate from 'plugin/validata';
const validate = new Validate('#js-img-check', {
useREM: {
rootFontSize: 40,
picWidth: 150
}
});
const showErrTip = tip.show;
class EmailBindMobile extends Page {
... ... @@ -19,12 +26,17 @@ class EmailBindMobile extends Page {
verifyCodeInput: $('.mobile-form-login input.verify-code-input'),
verifyCodeBtn: $('.mobile-form-login .get-verify-code'),
loginBtn: $('.mobile-form-login .sms-login-btn'),
$captcha: $('#js-img-check')
};
this.init();
}
init() {
if (this.selector.$captcha.data('userverify')) {
validate.init();
}
this.bindEvents();
}
... ... @@ -134,27 +146,37 @@ class EmailBindMobile extends Page {
this.selector.verifyCodeBtn.data('oneClick', true);
let params = {
area: area.replace('+', ''),
mobile: pn
};
validate.getResults().then(result => {
let params = {
area: area.replace('+', ''),
mobile: pn
};
this.ajax({
url: '/passport/bind/forceSendMsg',
type: 'POST',
data: params
}).then(codeResult => {
this.selector.verifyCodeBtn.data('oneClick', false);
$.extend(params, result);
if (codeResult.code === 200) {
this.countDown();
return;
} else {
showErrTip(codeResult.message);
}
this.ajax({
url: '/passport/bind/forceSendMsg',
type: 'POST',
data: params
}).then(codeResult => {
this.selector.verifyCodeBtn.data('oneClick', false);
validate.type === 2 && validate.refresh();
if (codeResult.code === 200) {
this.countDown();
return;
} else {
showErrTip(codeResult.message);
}
(codeResult.changeCaptcha && validate.type !== 2) && validate.refresh();
}).catch(() => {
this.selector.verifyCodeBtn.data('oneClick', false);
showErrTip('出错了,请重试');
validate.refresh();
});
}).catch(() => {
this.selector.verifyCodeBtn.data('oneClick', false);
showErrTip('出错了,请重试');
});
}
... ... @@ -173,8 +195,6 @@ class EmailBindMobile extends Page {
return showErrTip('手机号格式不正确,请重新输入');
}
this.selector.loginBtn.data('oneClick', true);
let params = {
area: area.replace('+', ''),
mobile: pn,
... ... @@ -186,8 +206,6 @@ class EmailBindMobile extends Page {
type: 'POST',
data: params
}).then(codeResult => {
this.selector.loginBtn.data('oneClick', false);
if (codeResult.code === 200) {
this.continueBind(
$.extend({isBind: 'N', isRegister: 'N'}, codeResult.data),
... ... @@ -197,7 +215,6 @@ class EmailBindMobile extends Page {
showErrTip(codeResult.message);
}
}).catch(() => {
this.selector.loginBtn.data('oneClick', false);
showErrTip('出错了,请重试');
});
}
... ...
... ... @@ -4,7 +4,14 @@ import Page from 'yoho-page';
import api from '../api';
import dialog from 'plugin/dialog';
import bindDialogHbs from 'passport/bind-dialog-tip.hbs';
import Validate from 'plugin/validata';
const validate = new Validate('#js-img-check', {
useREM: {
rootFontSize: 40,
picWidth: 150
}
});
const showErrTip = tip.show;
class ThirdBindMobile extends Page {
... ... @@ -21,12 +28,17 @@ class ThirdBindMobile extends Page {
verifyCodeInput: $('.mobile-form-login input.verify-code-input'),
verifyCodeBtn: $('.mobile-form-login .get-verify-code'),
loginBtn: $('.mobile-form-login .sms-login-btn'),
$captcha: $('#js-img-check')
};
this.init();
}
init() {
if (this.selector.$captcha.data('userverify')) {
validate.init();
}
this.bindEvents();
}
... ... @@ -137,27 +149,37 @@ class ThirdBindMobile extends Page {
this.selector.verifyCodeBtn.data('oneClick', true);
let params = {
area: area.replace('+', ''),
mobile: pn
};
validate.getResults().then(result => {
let params = {
area: area.replace('+', ''),
mobile: pn
};
this.ajax({
url: '/passport/bind/thirdSendMsg',
type: 'POST',
data: params
}).then(codeResult => {
this.selector.verifyCodeBtn.data('oneClick', false);
$.extend(params, result);
if (codeResult.code === 200) {
this.countDown();
return;
} else {
showErrTip(codeResult.message);
}
this.ajax({
url: '/passport/bind/thirdSendMsg',
type: 'POST',
data: params
}).then(codeResult => {
this.selector.verifyCodeBtn.data('oneClick', false);
validate.type === 2 && validate.refresh();
if (codeResult.code === 200) {
this.countDown();
return;
} else {
showErrTip(codeResult.message);
}
(codeResult.changeCaptcha && validate.type !== 2) && validate.refresh();
}).catch(() => {
this.selector.verifyCodeBtn.data('oneClick', false);
showErrTip('出错了,请重试');
validate.refresh();
});
}).catch(() => {
this.selector.verifyCodeBtn.data('oneClick', false);
showErrTip('出错了,请重试');
});
}
... ... @@ -176,8 +198,6 @@ class ThirdBindMobile extends Page {
return showErrTip('手机号格式不正确,请重新输入');
}
this.selector.loginBtn.data('oneClick', true);
let params = {
area: area.replace('+', ''),
mobile: pn,
... ... @@ -191,8 +211,6 @@ class ThirdBindMobile extends Page {
type: 'POST',
data: params
}).then(codeResult => {
this.selector.loginBtn.data('oneClick', false);
if (codeResult.code === 200) {
this.continueBind(
$.extend({isBind: 'N', isRegister: 'N'}, codeResult.data),
... ... @@ -202,7 +220,6 @@ class ThirdBindMobile extends Page {
showErrTip(codeResult.message);
}
}).catch(() => {
this.selector.loginBtn.data('oneClick', false);
showErrTip('出错了,请重试');
});
}
... ...