Authored by 郭成尧

bind-bug-fixed

@@ -99,14 +99,14 @@ const bind = { @@ -99,14 +99,14 @@ const bind = {
99 99
100 if (result.code === 200) { 100 if (result.code === 200) {
101 let nextUrl = helpers.urlFormat('/passport/bind/code', { 101 let nextUrl = helpers.urlFormat('/passport/bind/code', {
102 - isReg: result.data.is_register, // esline-disable-line 102 + is_register: result.data.is_register,
103 openId: openId, 103 openId: openId,
104 sourceType: sourceType, 104 sourceType: sourceType,
105 areaCode: areaCode, 105 areaCode: areaCode,
106 phoneNum: phoneNum 106 phoneNum: phoneNum
107 }); 107 });
108 108
109 - data.data.isReg = result.data.is_register; 109 + data.data.is_register = result.data.is_register;
110 data.data.next = nextUrl; 110 data.data.next = nextUrl;
111 } else { 111 } else {
112 data.data = result.data; 112 data.data = result.data;
@@ -8,8 +8,6 @@ @@ -8,8 +8,6 @@
8 const _ = require('lodash'); 8 const _ = require('lodash');
9 const config = global.yoho.config; 9 const config = global.yoho.config;
10 const co = Promise.coroutine; 10 const co = Promise.coroutine;
11 -const cache = global.yoho.cache;  
12 -const log = global.yoho.logger;  
13 const geetest = require('./geetest'); 11 const geetest = require('./geetest');
14 const captcha = require('./captcha'); 12 const captcha = require('./captcha');
15 const imgCheck = require('../models/imgcheck'); 13 const imgCheck = require('../models/imgcheck');
@@ -60,48 +58,25 @@ const check = (req, res, next) => { @@ -60,48 +58,25 @@ const check = (req, res, next) => {
60 req.yoho.captchaShow = !_.get(req.app.locals.wap, 'close.loginValidation', false); 58 req.yoho.captchaShow = !_.get(req.app.locals.wap, 'close.loginValidation', false);
61 59
62 co(function* () { 60 co(function* () {
63 - // 如果是账号密码登录,那么需要检查是否登录失败过,登录失败过展示验证码  
64 - if (req.path === '/passport/login/auth') {  
65 - // 第一次登录要不要展示验证码:后台开关勾选,首次登录不需要展示  
66 - let firstLoginShowCaptcha = !_.get(req.app.locals.wap, 'close.firstLoginShowCaptcha', false);  
67 -  
68 - log.info(`firstLoginShowCaptcha status is ${firstLoginShowCaptcha}`);  
69 -  
70 - if (firstLoginShowCaptcha) {  
71 - req.yoho.captchaShow = true;  
72 - } else {  
73 - let hasErrorLog = yield cache.get(`loginErrorIp:${req.yoho.clientIp}`);  
74 -  
75 - log.info(`Check clientip ${req.yoho.clientIp} status is ` + hasErrorLog); 61 + res.locals.useGeetest = _.get(req.app.locals.wap, 'geetest.validation', false); // 使用极验证
  62 + if (res.locals.useGeetest) {
  63 + req.yoho.captchaShow = false;
  64 + } else {
  65 + let isNeedImgCheckApiData = yield req.ctx(imgCheck).isNeedImgCheck(req.sessionID);
76 66
77 - if (hasErrorLog) {  
78 - req.yoho.captchaShow = true;  
79 - } else {  
80 - req.yoho.captchaShow = false;  
81 - } 67 + req.yoho.captchaShow = true;
  68 + if (_.parseInt(_.get(isNeedImgCheckApiData, 'code')) === 200) {
  69 + req.yoho.captchaShow = _.get(isNeedImgCheckApiData, 'data');
82 } 70 }
83 } 71 }
84 -  
85 return req.yoho.captchaShow; 72 return req.yoho.captchaShow;
86 - })().catch(function() {  
87 - // memcache 不可用,展示验证码  
88 - req.yoho.captchaShow = true;  
89 - return req.yoho.captchaShow;  
90 - }).then(function() { 73 + })().then(function() {
91 // 不是账号密码登录,直接根据配置总开关决定是否需要展示验证码 74 // 不是账号密码登录,直接根据配置总开关决定是否需要展示验证码
92 if (!req.yoho.captchaShow) { 75 if (!req.yoho.captchaShow) {
93 return next(); 76 return next();
94 } 77 }
95 78
96 - // 使用极验证  
97 - let useGeetest = _.get(req.app.locals.wap, 'geetest.validation', false);  
98 -  
99 - // 某次请求极验证调用注册失败,强制使用自有图形验证码  
100 - if (req.session.useYohoCaptcha) {  
101 - useGeetest = false;  
102 - }  
103 -  
104 - return (useGeetest ? geetest : captcha).validate(req, res, next); 79 + return (res.locals.useGeetest ? geetest : captcha).validate(req, res, next);
105 }); 80 });
106 }; 81 };
107 82
@@ -8,6 +8,7 @@ @@ -8,6 +8,7 @@
8 'use strict'; 8 'use strict';
9 9
10 const FROM = require('../../../config/from'); 10 const FROM = require('../../../config/from');
  11 +const PAGE = 'H5';
11 12
12 class BindServiceModel extends global.yoho.BaseModel { 13 class BindServiceModel extends global.yoho.BaseModel {
13 constructor(ctx) { 14 constructor(ctx) {
@@ -33,7 +34,8 @@ class BindServiceModel extends global.yoho.BaseModel { @@ -33,7 +34,8 @@ class BindServiceModel extends global.yoho.BaseModel {
33 mobile: params.mobile, 34 mobile: params.mobile,
34 area: params.area, 35 area: params.area,
35 udid: params.udid, 36 udid: params.udid,
36 - degrees: params.captcha 37 + degrees: params.captcha,
  38 + fromPage: PAGE
37 } 39 }
38 }); 40 });
39 } 41 }
@@ -62,6 +62,7 @@ function nextStep(url, mobileNo, areaCode) { @@ -62,6 +62,7 @@ function nextStep(url, mobileNo, areaCode) {
62 url: '/passport/bind/sendBindMsg', 62 url: '/passport/bind/sendBindMsg',
63 data: params, 63 data: params,
64 success: function(res) { 64 success: function(res) {
  65 + requested = false;
65 if (res.code === 200) { 66 if (res.code === 200) {
66 67
67 // 统计代码:用于统计从哪个渠道登录 68 // 统计代码:用于统计从哪个渠道登录
@@ -73,6 +74,7 @@ function nextStep(url, mobileNo, areaCode) { @@ -73,6 +74,7 @@ function nextStep(url, mobileNo, areaCode) {
73 74
74 location.href = url; 75 location.href = url;
75 } else { 76 } else {
  77 + $btnNext.removeClass('disable').html('下一步');
76 tip.show(res.message); 78 tip.show(res.message);
77 } 79 }
78 }, 80 },
@@ -135,7 +137,8 @@ $btnNext.on('touchstart', function() { @@ -135,7 +137,8 @@ $btnNext.on('touchstart', function() {
135 leftBtnText: '更换号码', 137 leftBtnText: '更换号码',
136 rightBtnText: '继续绑定' 138 rightBtnText: '继续绑定'
137 } 139 }
138 - }, function() { 140 + }, () => {
  141 + dialog.hideDialog();
139 nextStep(res.data.next, pn, areaCode); 142 nextStep(res.data.next, pn, areaCode);
140 }); 143 });
141 } else if (res.data.is_register === 3) { 144 } else if (res.data.is_register === 3) {