Authored by 郝肖肖

'绑定手机号加图形验证码'

@@ -84,6 +84,7 @@ router.get('/passport/password/resetsuccess', reset.passwordResetOkPage); // 重 @@ -84,6 +84,7 @@ router.get('/passport/password/resetsuccess', reset.passwordResetOkPage); // 重
84 // 通过邮箱登录绑定手机号 84 // 通过邮箱登录绑定手机号
85 router.get('/passport/bind/forceBindMobile', validateCode.load, bind.forceBindMobilePage); 85 router.get('/passport/bind/forceBindMobile', validateCode.load, bind.forceBindMobilePage);
86 router.post('/passport/bind/forceSendMsg', 86 router.post('/passport/bind/forceSendMsg',
  87 + validateCode.check,
87 bind.isCheckEmailPassword, 88 bind.isCheckEmailPassword,
88 bind.sendMsgApi, 89 bind.sendMsgApi,
89 bind.forceSendMsg 90 bind.forceSendMsg
@@ -97,7 +98,7 @@ router.post('/passport/bind/continueMobile', bind.isCheckEmailPassword, bind.for @@ -97,7 +98,7 @@ router.post('/passport/bind/continueMobile', bind.isCheckEmailPassword, bind.for
97 98
98 // 第三方绑定手机号 99 // 第三方绑定手机号
99 router.get('/passport/bind/index', validateCode.load, bind.thirdBindMobilePage); 100 router.get('/passport/bind/index', validateCode.load, bind.thirdBindMobilePage);
100 -router.post('/passport/bind/thirdSendMsg', bind.thirdSendMsgApi, bind.forceSendMsg); 101 +router.post('/passport/bind/thirdSendMsg', validateCode.check, bind.thirdSendMsgApi, bind.forceSendMsg);
101 router.post('/passport/bind/thirdMobileCheck', 102 router.post('/passport/bind/thirdMobileCheck',
102 bind.changeMobileCheckApi, 103 bind.changeMobileCheckApi,
103 bind.thirdBindMobileApi 104 bind.thirdBindMobileApi
@@ -4,7 +4,14 @@ import Page from 'yoho-page'; @@ -4,7 +4,14 @@ import Page from 'yoho-page';
4 import api from '../api'; 4 import api from '../api';
5 import dialog from 'plugin/dialog'; 5 import dialog from 'plugin/dialog';
6 import bindDialogHbs from 'passport/bind-dialog-tip.hbs'; 6 import bindDialogHbs from 'passport/bind-dialog-tip.hbs';
  7 +import Validate from 'plugin/validata';
7 8
  9 +const validate = new Validate('#js-img-check', {
  10 + useREM: {
  11 + rootFontSize: 40,
  12 + picWidth: 150
  13 + }
  14 +});
8 const showErrTip = tip.show; 15 const showErrTip = tip.show;
9 16
10 class EmailBindMobile extends Page { 17 class EmailBindMobile extends Page {
@@ -19,12 +26,17 @@ class EmailBindMobile extends Page { @@ -19,12 +26,17 @@ class EmailBindMobile extends Page {
19 verifyCodeInput: $('.mobile-form-login input.verify-code-input'), 26 verifyCodeInput: $('.mobile-form-login input.verify-code-input'),
20 verifyCodeBtn: $('.mobile-form-login .get-verify-code'), 27 verifyCodeBtn: $('.mobile-form-login .get-verify-code'),
21 loginBtn: $('.mobile-form-login .sms-login-btn'), 28 loginBtn: $('.mobile-form-login .sms-login-btn'),
  29 + $captcha: $('#js-img-check')
22 }; 30 };
23 31
24 this.init(); 32 this.init();
25 } 33 }
26 34
27 init() { 35 init() {
  36 + if (this.selector.$captcha.data('userverify')) {
  37 + validate.init();
  38 + }
  39 +
28 this.bindEvents(); 40 this.bindEvents();
29 } 41 }
30 42
@@ -134,27 +146,35 @@ class EmailBindMobile extends Page { @@ -134,27 +146,35 @@ class EmailBindMobile extends Page {
134 146
135 this.selector.verifyCodeBtn.data('oneClick', true); 147 this.selector.verifyCodeBtn.data('oneClick', true);
136 148
137 - let params = {  
138 - area: area.replace('+', ''),  
139 - mobile: pn  
140 - }; 149 + validate.getResults().then(result => {
  150 + let params = {
  151 + area: area.replace('+', ''),
  152 + mobile: pn
  153 + };
141 154
142 - this.ajax({  
143 - url: '/passport/bind/forceSendMsg',  
144 - type: 'POST',  
145 - data: params  
146 - }).then(codeResult => {  
147 - this.selector.verifyCodeBtn.data('oneClick', false); 155 + $.extend(params, result);
148 156
149 - if (codeResult.code === 200) {  
150 - this.countDown();  
151 - return;  
152 - } else {  
153 - showErrTip(codeResult.message);  
154 - }  
155 - }).catch(() => {  
156 - this.selector.verifyCodeBtn.data('oneClick', false);  
157 - showErrTip('出错了,请重试'); 157 + this.ajax({
  158 + url: '/passport/bind/forceSendMsg',
  159 + type: 'POST',
  160 + data: params
  161 + }).then(codeResult => {
  162 + this.selector.verifyCodeBtn.data('oneClick', false);
  163 + validate.type === 2 && validate.refresh();
  164 +
  165 + if (codeResult.code === 200) {
  166 + this.countDown();
  167 + return;
  168 + } else {
  169 + showErrTip(codeResult.message);
  170 + }
  171 +
  172 + (codeResult.changeCaptcha && validate.type !== 2) && validate.refresh();
  173 + }).catch(() => {
  174 + this.selector.verifyCodeBtn.data('oneClick', false);
  175 + showErrTip('出错了,请重试');
  176 + validate.refresh();
  177 + });
158 }); 178 });
159 } 179 }
160 180
@@ -173,8 +193,6 @@ class EmailBindMobile extends Page { @@ -173,8 +193,6 @@ class EmailBindMobile extends Page {
173 return showErrTip('手机号格式不正确,请重新输入'); 193 return showErrTip('手机号格式不正确,请重新输入');
174 } 194 }
175 195
176 - this.selector.loginBtn.data('oneClick', true);  
177 -  
178 let params = { 196 let params = {
179 area: area.replace('+', ''), 197 area: area.replace('+', ''),
180 mobile: pn, 198 mobile: pn,
@@ -186,8 +204,6 @@ class EmailBindMobile extends Page { @@ -186,8 +204,6 @@ class EmailBindMobile extends Page {
186 type: 'POST', 204 type: 'POST',
187 data: params 205 data: params
188 }).then(codeResult => { 206 }).then(codeResult => {
189 - this.selector.loginBtn.data('oneClick', false);  
190 -  
191 if (codeResult.code === 200) { 207 if (codeResult.code === 200) {
192 this.continueBind( 208 this.continueBind(
193 $.extend({isBind: 'N', isRegister: 'N'}, codeResult.data), 209 $.extend({isBind: 'N', isRegister: 'N'}, codeResult.data),
@@ -197,7 +213,6 @@ class EmailBindMobile extends Page { @@ -197,7 +213,6 @@ class EmailBindMobile extends Page {
197 showErrTip(codeResult.message); 213 showErrTip(codeResult.message);
198 } 214 }
199 }).catch(() => { 215 }).catch(() => {
200 - this.selector.loginBtn.data('oneClick', false);  
201 showErrTip('出错了,请重试'); 216 showErrTip('出错了,请重试');
202 }); 217 });
203 } 218 }
@@ -4,7 +4,14 @@ import Page from 'yoho-page'; @@ -4,7 +4,14 @@ import Page from 'yoho-page';
4 import api from '../api'; 4 import api from '../api';
5 import dialog from 'plugin/dialog'; 5 import dialog from 'plugin/dialog';
6 import bindDialogHbs from 'passport/bind-dialog-tip.hbs'; 6 import bindDialogHbs from 'passport/bind-dialog-tip.hbs';
  7 +import Validate from 'plugin/validata';
7 8
  9 +const validate = new Validate('#js-img-check', {
  10 + useREM: {
  11 + rootFontSize: 40,
  12 + picWidth: 150
  13 + }
  14 +});
8 const showErrTip = tip.show; 15 const showErrTip = tip.show;
9 16
10 class ThirdBindMobile extends Page { 17 class ThirdBindMobile extends Page {
@@ -21,12 +28,17 @@ class ThirdBindMobile extends Page { @@ -21,12 +28,17 @@ class ThirdBindMobile extends Page {
21 verifyCodeInput: $('.mobile-form-login input.verify-code-input'), 28 verifyCodeInput: $('.mobile-form-login input.verify-code-input'),
22 verifyCodeBtn: $('.mobile-form-login .get-verify-code'), 29 verifyCodeBtn: $('.mobile-form-login .get-verify-code'),
23 loginBtn: $('.mobile-form-login .sms-login-btn'), 30 loginBtn: $('.mobile-form-login .sms-login-btn'),
  31 + $captcha: $('#js-img-check')
24 }; 32 };
25 33
26 this.init(); 34 this.init();
27 } 35 }
28 36
29 init() { 37 init() {
  38 + if (this.selector.$captcha.data('userverify')) {
  39 + validate.init();
  40 + }
  41 +
30 this.bindEvents(); 42 this.bindEvents();
31 } 43 }
32 44
@@ -136,28 +148,35 @@ class ThirdBindMobile extends Page { @@ -136,28 +148,35 @@ class ThirdBindMobile extends Page {
136 } 148 }
137 149
138 this.selector.verifyCodeBtn.data('oneClick', true); 150 this.selector.verifyCodeBtn.data('oneClick', true);
  151 + validate.getResults().then(result => {
  152 + let params = {
  153 + area: area.replace('+', ''),
  154 + mobile: pn
  155 + };
139 156
140 - let params = {  
141 - area: area.replace('+', ''),  
142 - mobile: pn  
143 - }; 157 + $.extend(params, result);
144 158
145 - this.ajax({  
146 - url: '/passport/bind/thirdSendMsg',  
147 - type: 'POST',  
148 - data: params  
149 - }).then(codeResult => {  
150 - this.selector.verifyCodeBtn.data('oneClick', false); 159 + this.ajax({
  160 + url: '/passport/bind/thirdSendMsg',
  161 + type: 'POST',
  162 + data: params
  163 + }).then(codeResult => {
  164 + this.selector.verifyCodeBtn.data('oneClick', false);
  165 + validate.type === 2 && validate.refresh();
151 166
152 - if (codeResult.code === 200) {  
153 - this.countDown();  
154 - return;  
155 - } else {  
156 - showErrTip(codeResult.message);  
157 - }  
158 - }).catch(() => {  
159 - this.selector.verifyCodeBtn.data('oneClick', false);  
160 - showErrTip('出错了,请重试'); 167 + if (codeResult.code === 200) {
  168 + this.countDown();
  169 + return;
  170 + } else {
  171 + showErrTip(codeResult.message);
  172 + }
  173 +
  174 + (codeResult.changeCaptcha && validate.type !== 2) && validate.refresh();
  175 + }).catch(() => {
  176 + this.selector.verifyCodeBtn.data('oneClick', false);
  177 + showErrTip('出错了,请重试');
  178 + validate.refresh();
  179 + });
161 }); 180 });
162 } 181 }
163 182
@@ -176,8 +195,6 @@ class ThirdBindMobile extends Page { @@ -176,8 +195,6 @@ class ThirdBindMobile extends Page {
176 return showErrTip('手机号格式不正确,请重新输入'); 195 return showErrTip('手机号格式不正确,请重新输入');
177 } 196 }
178 197
179 - this.selector.loginBtn.data('oneClick', true);  
180 -  
181 let params = { 198 let params = {
182 area: area.replace('+', ''), 199 area: area.replace('+', ''),
183 mobile: pn, 200 mobile: pn,
@@ -191,8 +208,6 @@ class ThirdBindMobile extends Page { @@ -191,8 +208,6 @@ class ThirdBindMobile extends Page {
191 type: 'POST', 208 type: 'POST',
192 data: params 209 data: params
193 }).then(codeResult => { 210 }).then(codeResult => {
194 - this.selector.loginBtn.data('oneClick', false);  
195 -  
196 if (codeResult.code === 200) { 211 if (codeResult.code === 200) {
197 this.continueBind( 212 this.continueBind(
198 $.extend({isBind: 'N', isRegister: 'N'}, codeResult.data), 213 $.extend({isBind: 'N', isRegister: 'N'}, codeResult.data),
@@ -202,7 +217,6 @@ class ThirdBindMobile extends Page { @@ -202,7 +217,6 @@ class ThirdBindMobile extends Page {
202 showErrTip(codeResult.message); 217 showErrTip(codeResult.message);
203 } 218 }
204 }).catch(() => { 219 }).catch(() => {
205 - this.selector.loginBtn.data('oneClick', false);  
206 showErrTip('出错了,请重试'); 220 showErrTip('出错了,请重试');
207 }); 221 });
208 } 222 }