Authored by 毕凯

Merge branch 'feature/newBindMobile' into 'release/6.5'

强绑定手机号



See merge request !1234
... ... @@ -89,6 +89,8 @@ passport.use(new LocalStrategy({
done({code: 4189}, null);
} else if (result.code && result.code === 510) {
done(null, Object.assign(result.data, {weakPassword: true}));
} else if (result.code && result.code === 50004) {
done(result, null);
} else if (result.code) {
done(result.message, null);
} else {
... ...
... ... @@ -13,6 +13,7 @@ const RegServiceModel = require('../models/reg-service');
const BindServiceModel = require('../models/bind-service');
const AuthHelperModel = require('../models/auth-helper');
const _ = require('lodash');
const headerModel = require('../../../doraemon/models/header'); // 头部model
const Sources = {
qq: 'QQ',
... ... @@ -275,9 +276,8 @@ const bind = {
successPage: (req, res) => {
let refer = req.cookies.refer;
let type = req.query.type;
if (!refer || /signin|login/.test(refer)) {
if (!refer || /signin|login|\/bind\//.test(refer)) {
refer = helpers.urlFormat('/?go=1');
}
... ... @@ -286,7 +286,7 @@ const bind = {
res.render('bind/success', {
isPassportPage: true,
successTip: type === 'bind' ? '恭喜您,第三方账号绑定手机号码成功!' : '恭喜您,第三方账号关联手机号码成功!',
successTip: '恭喜您,绑定手机号码成功!',
goUrl: refer,
module: 'passport',
page: 'bind-success',
... ... @@ -320,6 +320,138 @@ const bind = {
} else {
res.json({ code: 400, message: '', data: '' });
}
},
// 第三方绑定手机号页面
thirdBindMobilePage: (req, res) => {
let headerData = headerModel.setNav({
navTitle: '绑定手机号', // 标题
navBack: true, // 是否显示返回按钮
backUrl: helpers.urlFormat('/signin.html'), // 返回按钮对应的url
navBtn: false // 顶部下拉菜单选项
});
res.render('bind/bind-mobile', {
captchaShow: req.yoho.captchaShow,
width750: true,
pageHeader: headerData,
localCss: true,
module: 'passport',
page: 'third-bind-mobile',
btnName: '绑定手机号',
areaCode: '+86', // 默认区号
countrys: req.ctx(RegServiceModel).getAreaData(), // 国别码
});
},
// 第三方绑定手机号发送短信
thirdSendMsgApi: (req, res, next) => {
req.ctx(BindServiceModel).sendThirdBindMobileCodeOnly(req.body).then(result => {
if (_.get(result, 'code', 400) === 200) {
return next();
}
return res.json(result);
}).catch(next);
},
// 第三方调用绑定接口
thirdBindMobileApi: (req, res, next) => {
if (_.isEmpty(req.body.open_id) || _.isEmpty(req.body.source_type)) {
return res.json({code: 401, data: {}, message: '请重新登录授权'});
}
req.ctx(BindServiceModel).thirdBindMobile(req.body).then(result => {
if (_.get(result, 'code', 400) !== 200) {
return res.json(result);
}
return req.ctx(AuthHelperModel).syncUserSession(
result.data.uid,
req,
res,
result.data.session_key
).then(() => {
return res.json({code: 200, data: {}, message: 'success'});
});
}).catch(next);
},
// 通过邮箱绑定手机号发送短信
sendMsgApi: (req, res, next) => {
req.ctx(BindServiceModel).sendChangeBindMobileCodeOnly(req.body).then(result => {
if (_.get(result, 'code', 400) === 200) {
return next();
}
return res.json(result);
}).catch(next);
},
// 检查手机是否绑定
changeMobileCheckApi: (req, res, next) => {
req.ctx(BindServiceModel).changeMobileCheck(req.body).then(result => {
if (_.get(result, 'data.isBind', '') === 'N' &&
_.get(result, 'data.isRegister', '') === 'N') {
return next();
}
return res.json(result);
}).catch(next);
},
// 通过邮箱强制绑定手机号页面
forceBindMobilePage: (req, res) => {
let headerData = headerModel.setNav({
navTitle: '绑定手机号', // 标题
navBack: true, // 是否显示返回按钮
backUrl: helpers.urlFormat('/signin.html'), // 返回按钮对应的url
navBtn: false // 顶部下拉菜单选项
});
res.render('bind/bind-mobile', {
captchaShow: req.yoho.captchaShow,
width750: true,
pageHeader: headerData,
localCss: true,
module: 'passport',
page: 'bind-email-mobile',
btnName: '绑定手机号',
areaCode: '+86', // 默认区号
countrys: req.ctx(RegServiceModel).getAreaData(), // 国别码
});
},
forceSendMsg: (req, res) => {
return res.json({code: 200, data: {}, message: 'success'});
},
isCheckEmailPassword: (req, res, next) => {
if (!req.session.bindEmail || !req.session.bindPassword) {
return res.json({code: 401, data: {}, message: '请重新登录授权'});
}
return next();
},
// 调用绑定接口
forceBindMobileApi: (req, res, next) => {
req.ctx(BindServiceModel).bindEmailLoginMobile(Object.assign(req.body, {
email: req.session.bindEmail,
password: req.session.bindPassword,
})).then(result => {
if (_.get(result, 'code', 400) !== 200) {
return res.json(result);
}
return req.ctx(AuthHelperModel).syncUserSession(
result.data.uid,
req,
res,
result.data.session_key
).then(() => {
delete req.session.bindEmail;
delete req.session.bindPassword;
return res.json({code: 200, data: {}, message: 'success'});
});
}).catch(next);
}
};
... ...
... ... @@ -283,6 +283,13 @@ const local = {
};
return res.json(obj);
} else if (_.get(err, 'code', 400) === 50004) {
// 强制绑定手机号需要邮箱和密码
req.session.bindEmail = req.body.account;
req.session.bindPassword = req.body.password;
return res.json(Object.assign(err, {
url: '//m.yohobuy.com/passport/bind/forceBindMobile'
}));
} else {
let obj = {
code: 400,
... ...
... ... @@ -9,6 +9,7 @@
const FROM = require('../../../config/from');
const PAGE = 'H5';
const aes = require('./aes-pwd');
class BindServiceModel extends global.yoho.BaseModel {
constructor(ctx) {
... ... @@ -99,6 +100,63 @@ class BindServiceModel extends global.yoho.BaseModel {
area: area
}});
}
// 强制绑定手机↓↓↓↓ -> 邮件登录绑定手机号发送短信
sendChangeBindMobileCodeOnly(params) {
return this.get({data: {
method: 'app.bind.sendChangeBindMobileCodeOnly',
business_line: 'yohobuy',
mobile: params.mobile || '',
area: params.area || '86'
}});
}
// 校验手机号,判断这个手机号是否已经注册,是否下面有第三方
changeMobileCheck(params) {
return this.get({data: {
method: 'app.bind.changeMobileCheck',
business_line: 'yohobuy',
mobile: params.mobile || '',
area: params.area || '86',
code: params.code || ''
}});
}
// 邮箱强制绑定手机号(邮箱强制绑定手机号场景使用)
bindEmailLoginMobile(params) {
return this.get({data: {
method: 'app.bind.bindEmailLoginMobile',
business_line: 'yohobuy',
mobile: params.mobile || '',
area: params.area || '86',
code: params.code,
email: params.email,
password: aes.aesPwd(params.password || '')
}});
}
// 第三方绑定手机号发送短信
sendThirdBindMobileCodeOnly(params) {
return this.get({data: {
method: 'app.bind.sendThirdBindMobileCodeOnly',
business_line: 'yohobuy',
mobile: params.mobile || '',
area: params.area || '86'
}});
}
// 第三方绑定手机号
thirdBindMobile(params) {
return this.get({data: {
method: 'app.bind.bindMobile',
business_line: 'yohobuy',
mobile: params.mobile || '',
area: params.area || '86',
code: params.code,
open_id: params.open_id,
source_type: params.source_type
}});
}
}
module.exports = BindServiceModel;
... ...
... ... @@ -62,7 +62,7 @@ router.get('/passport/login/alipay', login.common.beforeLogin, login.alipay.logi
router.get('/passport/login/alipay/callback', login.alipay.callback);
// 登录绑定
router.get('/passport/bind/index', validateCode.load, bind.indexPage);
// router.get('/passport/bind/index', validateCode.load, bind.indexPage);
router.post('/passport/bind/bindCheck', bind.bindCheck);
router.get('/passport/bind/code', validateCode.load, bind.codePage);
router.post('/passport/bind/sendBindMsg',
... ... @@ -81,6 +81,30 @@ router.get('/passport/password/resetpage', reset.passwordResetPage); // 重置
router.post('/passport/password/reset', reset.passwordReset); // 重置密码
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
);
router.post('/passport/bind/forceMobileCheck',
bind.isCheckEmailPassword,
bind.changeMobileCheckApi,
bind.forceBindMobileApi
);
router.post('/passport/bind/continueMobile', bind.isCheckEmailPassword, bind.forceBindMobileApi);
// 第三方绑定手机号
router.get('/passport/bind/index', validateCode.load, bind.thirdBindMobilePage);
router.post('/passport/bind/thirdSendMsg', validateCode.check, bind.thirdSendMsgApi, bind.forceSendMsg);
router.post('/passport/bind/thirdMobileCheck',
bind.changeMobileCheckApi,
bind.thirdBindMobileApi
);
router.post('/passport/bind/thirdContinueMobile', bind.thirdBindMobileApi);
/**
* 密码找回
*/
... ...
<div class="passport-bind-page">
<div class="safety-tip">
<i for="verifyCode" class="iconfont">&#xe71c;</i>
您的账户存在安全风险,建议您绑定手机号码提升安全级别
</div>
{{> passport/mobile-form-login}}
</div>
... ...
<div class="mobile-form-login">
<div class="form-group mobile">
<label for="mobile" class="iconfont">&#xe727;</label>
<select name="" id="countryCodeSelector" class="country-select">
{{# countrys}}
<option value={{areaCode}} {{#if selected}}selected{{/if}}>{{name}}</option>
{{/ countrys}}
</select>
<i class="iconfont arrow-icon">&#xe72f;</i>
<i class="line">|</i>
<input type="tel" name="mobile" placeholder="请输入手机号" class="mobile-input">
<i id="clearMobile" class="iconfont clear hide">&#xe72a;</i>
</div>
<div class="form-group verify-code">
<label for="verifyCode" class="iconfont">&#xe71c;</label>
<input type="text" name="verifyCode" placeholder="请输入验证码" class="verify-code-input">
<button id="getVerifyCodeBtn" class="get-verify-code">获取验证码</button>
</div>
{{> use-geetest}}
<button id="smsLoginBtn" class="sms-login-btn">
{{#if btnName}}
{{btnName}}
{{^}}
登录
{{/if}}
</button>
</div>
... ...
... ... @@ -12,10 +12,10 @@ const isTest = process.env.NODE_ENV === 'test';
const domains = {
api: 'http://api.yoho.cn/',
service: 'http://service.yoho.cn/',
liveApi: 'http://testapi.live.yohops.com:9999/',
singleApi: 'http://api-test3.yohops.com:9999/',
// api: 'http://api.yoho.cn/',
// service: 'http://service.yoho.cn/',
// liveApi: 'http://testapi.live.yohops.com:9999/',
// singleApi: 'http://api-test3.yohops.com:9999/',
// gray
// singleApi: 'http://single.gray.yohops.com/',
... ... @@ -24,10 +24,10 @@ const domains = {
// platformApi: 'http://172.16.6.210:8088/',
// api: 'http://api-test3.yohops.com:9999/',
// service: 'http://service-test3.yohops.com:9999/',
// liveApi: 'http://testapi.live.yohops.com:9999/',
// singleApi: 'http://api-test3.yohops.com:9999/',
api: 'http://api-test3.yohops.com:9999/',
service: 'http://service-test3.yohops.com:9999/',
liveApi: 'http://testapi.live.yohops.com:9999/',
singleApi: 'http://api-test3.yohops.com:9999/',
imSocket: 'ws://socket.yohobuy.com:10240',
imCs: 'http://im.yohobuy.com/api',
... ...
<div data-userverify="{{captchaShow}}" data-geetest="{{useGeetest}}" id="js-img-check" {{#unless useGeetest}} class="full-img-verify" {{/unless}}></div>
... ...
{{#if isBind}}
<div class="bind-title">
该手机已绑定Yoho!Family其他账号,
点击“继续”将解绑并绑定当前账号,
是否继续?
</div>
<div class="bind-subtitle">
解绑后原账号将不可使用该手机号登录!
</div>
{{else if isRegister}}
<div class="bind-title">
该账号已被注册,是否选择绑定?
点击“继续”原注册账号将被停用!
</div>
{{/if}}
... ...
require('passport/bind-mobile.page.css');
const $ = require('yoho-jquery');
const BindEmailMobile = require('./bind/_email-bind-mobile.js');
$(() => {
new BindEmailMobile();
});
... ...
import $ from 'yoho-jquery';
import tip from 'plugin/tip';
import Page from 'yoho-page';
import api from '../api';
import Validate from 'plugin/validata';
import dialog from 'plugin/dialog';
import bindDialogHbs from 'passport/bind-dialog-tip.hbs';
const $captcha = $('#js-img-check');
const validate = new Validate($captcha, {
useREM: {
rootFontSize: 40,
picWidth: 150
}
});
const showErrTip = tip.show;
class EmailBindMobile extends Page {
constructor() {
super();
this.selector = {
itime: 0,
countrySelect: $('.mobile-form-login select.country-select'),
mobileInput: $('.mobile-form-login input.mobile-input'),
clearMobile: $('.mobile-form-login .clear'),
verifyCodeInput: $('.mobile-form-login input.verify-code-input'),
verifyCodeBtn: $('.mobile-form-login .get-verify-code'),
loginBtn: $('.mobile-form-login .sms-login-btn'),
};
this.init();
}
init() {
if ($captcha.data('userverify')) {
validate.init();
}
this.bindEvents();
}
bindEvents() {
this.selector.countrySelect.on('change', this.changeBtnStatus.bind(this));
this.selector.mobileInput.on('input', this.changeBtnStatus.bind(this));
this.selector.clearMobile.on('click', this.clearMobile.bind(this));
this.selector.verifyCodeInput.on('input', this.changeBtnStatus.bind(this, true));
this.selector.verifyCodeBtn.on('click', this.getVerifyCode.bind(this));
this.selector.loginBtn.on('click', this.login.bind(this));
}
/**
* 清除输入的手机号
*/
clearMobile() {
this.selector.mobileInput.val('');
this.selector.verifyCodeInput.val('');
this.selector.clearMobile.addClass('hide');
this.selector.countrySelect.trigger('change');
}
/**
* 输入监听,改变按钮状态
*/
changeBtnStatus(isVerifycode) {
let areaCode = $.trim(this.selector.countrySelect.val());
let phoneNum = $.trim(this.selector.mobileInput.val());
let verifyCode = $.trim(this.selector.verifyCodeInput.val());
if (!api.phoneRegx[areaCode]) {
return showErrTip('出错了,请重新刷新页面');
}
if (phoneNum) {
this.selector.clearMobile.removeClass('hide');
}
// 验证码输入框单独处理
if (isVerifycode === true) {
// 提交表单按钮激活
if (verifyCode && api.phoneRegx[areaCode].test(phoneNum)) {
this.selector.loginBtn.addClass('active');
} else {
this.selector.loginBtn.removeClass('active');
}
return;
}
clearInterval(this.selector.itime);
this.selector.verifyCodeBtn.text('获取验证码');
if (api.phoneRegx[areaCode].test(phoneNum)) {
this.selector.verifyCodeBtn.addClass('active');
if (verifyCode) {
this.selector.loginBtn.addClass('active');
}
} else {
this.selector.verifyCodeBtn.removeClass('active');
this.selector.loginBtn.removeClass('active');
}
}
/**
* 获取验证码倒计时
*/
countDown(during) {
let count = parseInt(during, 10) || 59;
if (!this.selector.verifyCodeBtn.hasClass('active')) {
return;
}
this.selector.verifyCodeBtn.removeClass('active');
this.selector.itime = setInterval(() => {
window.setCookie('intTimer', count, {path: '/' });
if (count <= 0) {
this.selector.verifyCodeBtn.text('重新获取').addClass('active');
clearInterval(this.selector.itime);
} else {
this.selector.verifyCodeBtn.text('重新获取 (' + count-- + '秒)');
}
}, 1000);
}
/**
* 获取验证码
*/
getVerifyCode() {
let pn = $.trim(this.selector.mobileInput.val());
let area = $.trim(this.selector.countrySelect.val());
if (!this.selector.verifyCodeBtn.hasClass('active') ||
this.selector.verifyCodeBtn.data('oneClick')) {
return;
}
if (!api.phoneRegx[area]) {
return showErrTip('出错了,请重新刷新页面');
} else if (!api.phoneRegx[area].test(pn)) {
return showErrTip('手机号格式不正确,请重新输入');
}
this.selector.verifyCodeBtn.data('oneClick', true);
validate.getResults().then(result => {
let params = {
area: area.replace('+', ''),
mobile: pn
};
$.extend(params, result);
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();
});
});
}
login() {
let pn = $.trim(this.selector.mobileInput.val());
let area = $.trim(this.selector.countrySelect.val());
let verifyCode = $.trim(this.selector.verifyCodeInput.val());
if (!this.selector.loginBtn.hasClass('active')) {
return;
}
if (!api.phoneRegx[area]) {
return showErrTip('出错了,请重新刷新页面');
} else if (!api.phoneRegx[area].test(pn)) {
return showErrTip('手机号格式不正确,请重新输入');
}
this.selector.loginBtn.data('oneClick', true);
let params = {
area: area.replace('+', ''),
mobile: pn,
code: verifyCode,
};
this.ajax({
url: '/passport/bind/forceMobileCheck',
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),
params
);
} else {
showErrTip(codeResult.message);
}
}).catch(() => {
this.selector.loginBtn.data('oneClick', false);
showErrTip('出错了,请重试');
});
}
continueBind(codeResult, params) {
let that = this;
let goUrl = '/passport/bind/success';
let bindParams = {
isBind: codeResult.isBind === 'Y',
isRegister: codeResult.isRegister === 'Y'
};
// 如果没有绑定没有注册,直接注册
if (!(bindParams.isBind || bindParams.isRegister)) {
document.location.href = goUrl;
return;
}
dialog.showDialog({
dialogText: bindDialogHbs(bindParams),
fast: true,
hasFooter: {
leftBtnText: '去登录',
rightBtnText: '继续'
}
}, function() {
return that.ajax({
url: '/passport/bind/continueMobile',
type: 'POST',
data: params
}).then(cresult => {
if (cresult.code === 200) {
document.location.href = goUrl;
return;
} else {
showErrTip(cresult.message);
}
}).catch(() => {
showErrTip('出错了,请重试');
});
}, function() {
document.location.href = '//m.yohobuy.com/signin.html';
});
$('.dialog-wrapper').addClass('s-dialog-bind');
}
}
module.exports = EmailBindMobile;
... ...
import $ from 'yoho-jquery';
import tip from 'plugin/tip';
import Page from 'yoho-page';
import api from '../api';
import Validate from 'plugin/validata';
import dialog from 'plugin/dialog';
import bindDialogHbs from 'passport/bind-dialog-tip.hbs';
const $captcha = $('#js-img-check');
const validate = new Validate($captcha, {
useREM: {
rootFontSize: 40,
picWidth: 150
}
});
const showErrTip = tip.show;
class ThirdBindMobile extends Page {
constructor() {
super();
this.selector = {
itime: 0,
openId: $.trim($.queryString().openId),
sourceType: $.trim($.queryString().sourceType),
countrySelect: $('.mobile-form-login select.country-select'),
mobileInput: $('.mobile-form-login input.mobile-input'),
clearMobile: $('.mobile-form-login .clear'),
verifyCodeInput: $('.mobile-form-login input.verify-code-input'),
verifyCodeBtn: $('.mobile-form-login .get-verify-code'),
loginBtn: $('.mobile-form-login .sms-login-btn'),
};
this.init();
}
init() {
if ($captcha.data('userverify')) {
validate.init();
}
this.bindEvents();
}
bindEvents() {
this.selector.countrySelect.on('change', this.changeBtnStatus.bind(this));
this.selector.mobileInput.on('input', this.changeBtnStatus.bind(this));
this.selector.clearMobile.on('click', this.clearMobile.bind(this));
this.selector.verifyCodeInput.on('input', this.changeBtnStatus.bind(this, true));
this.selector.verifyCodeBtn.on('click', this.getVerifyCode.bind(this));
this.selector.loginBtn.on('click', this.login.bind(this));
}
/**
* 清除输入的手机号
*/
clearMobile() {
this.selector.mobileInput.val('');
this.selector.verifyCodeInput.val('');
this.selector.clearMobile.addClass('hide');
this.selector.countrySelect.trigger('change');
}
/**
* 输入监听,改变按钮状态
*/
changeBtnStatus(isVerifycode) {
let areaCode = $.trim(this.selector.countrySelect.val());
let phoneNum = $.trim(this.selector.mobileInput.val());
let verifyCode = $.trim(this.selector.verifyCodeInput.val());
if (!api.phoneRegx[areaCode]) {
return showErrTip('出错了,请重新刷新页面');
}
if (phoneNum) {
this.selector.clearMobile.removeClass('hide');
}
// 验证码输入框单独处理
if (isVerifycode === true) {
// 提交表单按钮激活
if (verifyCode && api.phoneRegx[areaCode].test(phoneNum)) {
this.selector.loginBtn.addClass('active');
} else {
this.selector.loginBtn.removeClass('active');
}
return;
}
clearInterval(this.selector.itime);
this.selector.verifyCodeBtn.text('获取验证码');
if (api.phoneRegx[areaCode].test(phoneNum)) {
this.selector.verifyCodeBtn.addClass('active');
if (verifyCode) {
this.selector.loginBtn.addClass('active');
}
} else {
this.selector.verifyCodeBtn.removeClass('active');
this.selector.loginBtn.removeClass('active');
}
}
/**
* 获取验证码倒计时
*/
countDown(during) {
let count = parseInt(during, 10) || 59;
if (!this.selector.verifyCodeBtn.hasClass('active')) {
return;
}
this.selector.verifyCodeBtn.removeClass('active');
this.selector.itime = setInterval(() => {
window.setCookie('intTimer', count, {path: '/' });
if (count <= 0) {
this.selector.verifyCodeBtn.text('重新获取').addClass('active');
clearInterval(this.selector.itime);
} else {
this.selector.verifyCodeBtn.text('重新获取 (' + count-- + '秒)');
}
}, 1000);
}
/**
* 获取验证码
*/
getVerifyCode() {
let pn = $.trim(this.selector.mobileInput.val());
let area = $.trim(this.selector.countrySelect.val());
if (!this.selector.verifyCodeBtn.hasClass('active') ||
this.selector.verifyCodeBtn.data('oneClick')) {
return;
}
if (!api.phoneRegx[area]) {
return showErrTip('出错了,请重新刷新页面');
} else if (!api.phoneRegx[area].test(pn)) {
return showErrTip('手机号格式不正确,请重新输入');
}
this.selector.verifyCodeBtn.data('oneClick', true);
validate.getResults().then(result => {
let params = {
area: area.replace('+', ''),
mobile: pn
};
$.extend(params, result);
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();
});
});
}
login() {
let pn = $.trim(this.selector.mobileInput.val());
let area = $.trim(this.selector.countrySelect.val());
let verifyCode = $.trim(this.selector.verifyCodeInput.val());
if (!this.selector.loginBtn.hasClass('active')) {
return;
}
if (!api.phoneRegx[area]) {
return showErrTip('出错了,请重新刷新页面');
} else if (!api.phoneRegx[area].test(pn)) {
return showErrTip('手机号格式不正确,请重新输入');
}
this.selector.loginBtn.data('oneClick', true);
let params = {
area: area.replace('+', ''),
mobile: pn,
code: verifyCode,
open_id: this.selector.openId,
source_type: this.selector.sourceType,
};
this.ajax({
url: '/passport/bind/thirdMobileCheck',
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),
params
);
} else {
showErrTip(codeResult.message);
}
}).catch(() => {
this.selector.loginBtn.data('oneClick', false);
showErrTip('出错了,请重试');
});
}
continueBind(codeResult, params) {
let that = this;
let goUrl = '/passport/bind/success';
let bindParams = {
isBind: codeResult.isBind === 'Y',
isRegister: codeResult.isRegister === 'Y'
};
// 如果没有绑定没有注册,直接注册
if (!(bindParams.isBind || bindParams.isRegister)) {
document.location.href = goUrl;
return;
}
dialog.showDialog({
dialogText: bindDialogHbs(bindParams),
fast: true,
hasFooter: {
leftBtnText: '去登录',
rightBtnText: '继续'
}
}, function() {
return that.ajax({
url: '/passport/bind/thirdContinueMobile',
type: 'POST',
data: params
}).then(cresult => {
if (cresult.code === 200) {
document.location.href = goUrl;
return;
} else {
showErrTip(cresult.message);
}
}).catch(() => {
showErrTip('出错了,请重试');
});
}, function() {
document.location.href = '//m.yohobuy.com/signin.html';
});
$('.dialog-wrapper').addClass('s-dialog-bind');
}
}
module.exports = ThirdBindMobile;
... ...
... ... @@ -139,7 +139,7 @@ class Login {
localStorage.loginJumpUrl = $('#account').val();
localStorage.loginJump = 'true';
location.href = data.url;
} else if (data.code === 510) {
} else if (data.code === 510 || data.code === 50004) {
location.href = data.url;
} else {
$captcha.data('userverify', data.captchaShow);
... ...
... ... @@ -100,7 +100,7 @@ function loginAuth(params, acc) {
localStorage.loginJumpUrl = $('#account').val();
localStorage.loginJump = 'true';
location.href = data.url;
} else if (data.code === 510) {
} else if (data.code === 510 || data.code === 50004) {
location.href = data.url;
} else {
$captcha.data('userverify', data.captchaShow);
... ...
require('passport/bind-mobile.page.css');
const $ = require('yoho-jquery');
const ThirdEmailMobile = require('./bind/_third-bind-mobile.js');
$(() => {
new ThirdEmailMobile();
});
... ...
... ... @@ -836,7 +836,6 @@
}
> .dialog-content {
.safe-check-tip {
font-size: 22px;
color: #b0b0b0;
... ...
@import "layout/img-check";
$disable-gray: #b0b0b0;
.mobile-form-login {
padding: 100px 45px 45px;
.active {
background-color: #444 !important;
}
> .form-group {
border-bottom: 1px solid #e0e0e0;
height: 50px;
> label {
font-size: 26px;
margin-right: 36px;
}
> input {
width: 400px;
border: none;
&.mobile-input {
width: 350px;
}
&.verify-code-input {
width: 350px;
}
}
> i {
float: right;
&.line {
float: none;
margin-right: 20px;
}
}
&.mobile {
margin-bottom: 62px;
> label {
margin-right: 30px;
}
> .country-select {
width: 140px;
appearance: none;
border: none;
background-color: transparent;
}
> .arrow-icon {
color: #444;
float: none;
font-size: 12px;
}
> .clear {
color: #e0e0e0;
margin-right: 4px;
margin-top: 10px;
}
}
.country-code {
width: 98px;
height: 22px;
font-size: 28px;
line-height: 1.14;
color: #444;
background-color: transparent;
margin-right: 20px;
}
> .get-verify-code {
padding: 0 16px;
height: 50px;
line-height: 50px;
border-radius: 25px;
background-color: $disable-gray;
color: #fff;
font-size: 22px;
float: right;
margin-top: -8px;
min-width: 187px;
}
}
> .verify-code {
margin-bottom: 0;
}
.sms-login-btn {
width: 100%;
height: 70px;
border-radius: 4px;
background-color: $disable-gray;
margin-top: 40px;
font-size: 32px;
color: #fff;
}
}
... ...
@import "mobile-form-login";
.passport-bind-page {
background-color: #fff;
.safety-tip {
line-height: 70px;
height: 70px;
padding: 0 30px;
font-size: 24px;
background-color: #ff575c;
color: #fff;
opacity: 0.8;
}
}
.s-dialog-bind {
.bind-title {
font-size: 28px;
text-align: center;
color: #444;
}
.bind-subtitle {
font-size: 24px;
text-align: left;
color: #b0b0b0;
margin-top: 25px;
}
.dialog-box {
background-color: #fff;
}
}
... ...