merge-master
Showing
6 changed files
with
110 additions
and
60 deletions
@@ -238,7 +238,7 @@ class DetailModel extends global.yoho.BaseModel { | @@ -238,7 +238,7 @@ class DetailModel extends global.yoho.BaseModel { | ||
238 | // 获取资讯 | 238 | // 获取资讯 |
239 | return this._getArticle(id).then(data => { | 239 | return this._getArticle(id).then(data => { |
240 | // 调用接口失败 | 240 | // 调用接口失败 |
241 | - if (!data || data.code !== 200) { | 241 | + if (!data || data.code !== 200 || _.get(data, 'data.status') !== 1) { |
242 | result.code = 400; | 242 | result.code = 400; |
243 | return result; | 243 | return result; |
244 | } | 244 | } |
@@ -346,7 +346,11 @@ const bind = { | @@ -346,7 +346,11 @@ const bind = { | ||
346 | 346 | ||
347 | // 第三方绑定手机号发送短信 | 347 | // 第三方绑定手机号发送短信 |
348 | thirdSendMsgApi: (req, res, next) => { | 348 | thirdSendMsgApi: (req, res, next) => { |
349 | - req.ctx(BindServiceModel).sendThirdBindMobileCodeOnly(req.body).then(result => { | 349 | + let params = { |
350 | + superCapture: req.body.geetest_challenge ? config.superCapture : '' | ||
351 | + }; | ||
352 | + | ||
353 | + req.ctx(BindServiceModel).sendThirdBindMobileCodeOnly(Object.assign({}, req.body, params)).then(result => { | ||
350 | if (_.get(result, 'code', 400) === 200) { | 354 | if (_.get(result, 'code', 400) === 200) { |
351 | return next(); | 355 | return next(); |
352 | } | 356 | } |
@@ -378,7 +382,11 @@ const bind = { | @@ -378,7 +382,11 @@ const bind = { | ||
378 | 382 | ||
379 | // 通过邮箱绑定手机号发送短信 | 383 | // 通过邮箱绑定手机号发送短信 |
380 | sendMsgApi: (req, res, next) => { | 384 | sendMsgApi: (req, res, next) => { |
381 | - req.ctx(BindServiceModel).sendChangeBindMobileCodeOnly(req.body).then(result => { | 385 | + let params = { |
386 | + superCapture: req.body.geetest_challenge ? config.superCapture : '' | ||
387 | + }; | ||
388 | + | ||
389 | + req.ctx(BindServiceModel).sendChangeBindMobileCodeOnly(Object.assign({}, req.body, params)).then(result => { | ||
382 | if (_.get(result, 'code', 400) === 200) { | 390 | if (_.get(result, 'code', 400) === 200) { |
383 | return next(); | 391 | return next(); |
384 | } | 392 | } |
@@ -388,7 +396,11 @@ const bind = { | @@ -388,7 +396,11 @@ const bind = { | ||
388 | 396 | ||
389 | // 检查手机是否绑定 | 397 | // 检查手机是否绑定 |
390 | changeMobileCheckApi: (req, res, next) => { | 398 | changeMobileCheckApi: (req, res, next) => { |
391 | - req.ctx(BindServiceModel).changeMobileCheck(req.body).then(result => { | 399 | + let params = { |
400 | + superCapture: req.body.geetest_challenge ? config.superCapture : '' | ||
401 | + }; | ||
402 | + | ||
403 | + req.ctx(BindServiceModel).changeMobileCheck(Object.assign({}, req.body, params)).then(result => { | ||
392 | if (_.get(result, 'data.isBind', '') === 'N' && | 404 | if (_.get(result, 'data.isBind', '') === 'N' && |
393 | _.get(result, 'data.isRegister', '') === 'N') { | 405 | _.get(result, 'data.isRegister', '') === 'N') { |
394 | return next(); | 406 | return next(); |
@@ -433,10 +445,12 @@ const bind = { | @@ -433,10 +445,12 @@ const bind = { | ||
433 | 445 | ||
434 | // 调用绑定接口 | 446 | // 调用绑定接口 |
435 | forceBindMobileApi: (req, res, next) => { | 447 | forceBindMobileApi: (req, res, next) => { |
436 | - req.ctx(BindServiceModel).bindEmailLoginMobile(Object.assign(req.body, { | 448 | + let params = { |
437 | email: req.session.bindEmail, | 449 | email: req.session.bindEmail, |
438 | password: req.session.bindPassword, | 450 | password: req.session.bindPassword, |
439 | - })).then(result => { | 451 | + }; |
452 | + | ||
453 | + req.ctx(BindServiceModel).bindEmailLoginMobile(Object.assign({}, req.body, params)).then(result => { | ||
440 | if (_.get(result, 'code', 400) !== 200) { | 454 | if (_.get(result, 'code', 400) !== 200) { |
441 | return res.json(result); | 455 | return res.json(result); |
442 | } | 456 | } |
@@ -104,10 +104,12 @@ class BindServiceModel extends global.yoho.BaseModel { | @@ -104,10 +104,12 @@ class BindServiceModel extends global.yoho.BaseModel { | ||
104 | // 强制绑定手机↓↓↓↓ -> 邮件登录绑定手机号发送短信 | 104 | // 强制绑定手机↓↓↓↓ -> 邮件登录绑定手机号发送短信 |
105 | sendChangeBindMobileCodeOnly(params) { | 105 | sendChangeBindMobileCodeOnly(params) { |
106 | return this.get({data: { | 106 | return this.get({data: { |
107 | - method: 'app.bind.sendChangeBindMobileCodeOnly', | ||
108 | - business_line: 'yohobuy', | 107 | + method: 'app.bind.sendChangeBindMobileCodeOnlyImg', |
109 | mobile: params.mobile || '', | 108 | mobile: params.mobile || '', |
110 | - area: params.area || '86' | 109 | + area: params.area || '86', |
110 | + degrees: params.captcha || '', | ||
111 | + superCapture: params.superCapture || '', | ||
112 | + fromPage: PAGE | ||
111 | }}); | 113 | }}); |
112 | } | 114 | } |
113 | 115 | ||
@@ -116,7 +118,6 @@ class BindServiceModel extends global.yoho.BaseModel { | @@ -116,7 +118,6 @@ class BindServiceModel extends global.yoho.BaseModel { | ||
116 | return this.get({ | 118 | return this.get({ |
117 | data: Object.assign({ | 119 | data: Object.assign({ |
118 | method: 'app.bind.changeMobileCheck', | 120 | method: 'app.bind.changeMobileCheck', |
119 | - business_line: 'yohobuy', | ||
120 | }, params) | 121 | }, params) |
121 | }); | 122 | }); |
122 | } | 123 | } |
@@ -125,7 +126,6 @@ class BindServiceModel extends global.yoho.BaseModel { | @@ -125,7 +126,6 @@ class BindServiceModel extends global.yoho.BaseModel { | ||
125 | bindEmailLoginMobile(params) { | 126 | bindEmailLoginMobile(params) { |
126 | return this.get({data: { | 127 | return this.get({data: { |
127 | method: 'app.bind.bindEmailLoginMobile', | 128 | method: 'app.bind.bindEmailLoginMobile', |
128 | - business_line: 'yohobuy', | ||
129 | mobile: params.mobile || '', | 129 | mobile: params.mobile || '', |
130 | area: params.area || '86', | 130 | area: params.area || '86', |
131 | code: params.code, | 131 | code: params.code, |
@@ -137,10 +137,12 @@ class BindServiceModel extends global.yoho.BaseModel { | @@ -137,10 +137,12 @@ class BindServiceModel extends global.yoho.BaseModel { | ||
137 | // 第三方绑定手机号发送短信 | 137 | // 第三方绑定手机号发送短信 |
138 | sendThirdBindMobileCodeOnly(params) { | 138 | sendThirdBindMobileCodeOnly(params) { |
139 | return this.get({data: { | 139 | return this.get({data: { |
140 | - method: 'app.bind.sendThirdBindMobileCodeOnly', | ||
141 | - business_line: 'yohobuy', | 140 | + method: 'app.bind.sendThirdBindMobileCodeOnlyImg', |
142 | mobile: params.mobile || '', | 141 | mobile: params.mobile || '', |
143 | - area: params.area || '86' | 142 | + area: params.area || '86', |
143 | + superCapture: params.superCapture || '', | ||
144 | + degrees: params.captcha || '', | ||
145 | + fromPage: PAGE | ||
144 | }}); | 146 | }}); |
145 | } | 147 | } |
146 | 148 | ||
@@ -148,7 +150,6 @@ class BindServiceModel extends global.yoho.BaseModel { | @@ -148,7 +150,6 @@ class BindServiceModel extends global.yoho.BaseModel { | ||
148 | thirdBindMobile(params) { | 150 | thirdBindMobile(params) { |
149 | return this.get({data: { | 151 | return this.get({data: { |
150 | method: 'app.bind.bindMobile', | 152 | method: 'app.bind.bindMobile', |
151 | - business_line: 'yohobuy', | ||
152 | mobile: params.mobile || '', | 153 | mobile: params.mobile || '', |
153 | area: params.area || '86', | 154 | area: params.area || '86', |
154 | code: params.code, | 155 | code: params.code, |
@@ -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,37 @@ class EmailBindMobile extends Page { | @@ -134,27 +146,37 @@ 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 | - } | 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 | + }); | ||
155 | }).catch(() => { | 178 | }).catch(() => { |
156 | this.selector.verifyCodeBtn.data('oneClick', false); | 179 | this.selector.verifyCodeBtn.data('oneClick', false); |
157 | - showErrTip('出错了,请重试'); | ||
158 | }); | 180 | }); |
159 | } | 181 | } |
160 | 182 | ||
@@ -173,8 +195,6 @@ class EmailBindMobile extends Page { | @@ -173,8 +195,6 @@ class EmailBindMobile extends Page { | ||
173 | return showErrTip('手机号格式不正确,请重新输入'); | 195 | return showErrTip('手机号格式不正确,请重新输入'); |
174 | } | 196 | } |
175 | 197 | ||
176 | - this.selector.loginBtn.data('oneClick', true); | ||
177 | - | ||
178 | let params = { | 198 | let params = { |
179 | area: area.replace('+', ''), | 199 | area: area.replace('+', ''), |
180 | mobile: pn, | 200 | mobile: pn, |
@@ -186,8 +206,6 @@ class EmailBindMobile extends Page { | @@ -186,8 +206,6 @@ class EmailBindMobile extends Page { | ||
186 | type: 'POST', | 206 | type: 'POST', |
187 | data: params | 207 | data: params |
188 | }).then(codeResult => { | 208 | }).then(codeResult => { |
189 | - this.selector.loginBtn.data('oneClick', false); | ||
190 | - | ||
191 | if (codeResult.code === 200) { | 209 | if (codeResult.code === 200) { |
192 | this.continueBind( | 210 | this.continueBind( |
193 | $.extend({isBind: 'N', isRegister: 'N'}, codeResult.data), | 211 | $.extend({isBind: 'N', isRegister: 'N'}, codeResult.data), |
@@ -197,7 +215,6 @@ class EmailBindMobile extends Page { | @@ -197,7 +215,6 @@ class EmailBindMobile extends Page { | ||
197 | showErrTip(codeResult.message); | 215 | showErrTip(codeResult.message); |
198 | } | 216 | } |
199 | }).catch(() => { | 217 | }).catch(() => { |
200 | - this.selector.loginBtn.data('oneClick', false); | ||
201 | showErrTip('出错了,请重试'); | 218 | showErrTip('出错了,请重试'); |
202 | }); | 219 | }); |
203 | } | 220 | } |
@@ -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 | ||
@@ -137,27 +149,37 @@ class ThirdBindMobile extends Page { | @@ -137,27 +149,37 @@ class ThirdBindMobile extends Page { | ||
137 | 149 | ||
138 | this.selector.verifyCodeBtn.data('oneClick', true); | 150 | this.selector.verifyCodeBtn.data('oneClick', true); |
139 | 151 | ||
140 | - let params = { | ||
141 | - area: area.replace('+', ''), | ||
142 | - mobile: pn | ||
143 | - }; | 152 | + validate.getResults().then(result => { |
153 | + let params = { | ||
154 | + area: area.replace('+', ''), | ||
155 | + mobile: pn | ||
156 | + }; | ||
144 | 157 | ||
145 | - this.ajax({ | ||
146 | - url: '/passport/bind/thirdSendMsg', | ||
147 | - type: 'POST', | ||
148 | - data: params | ||
149 | - }).then(codeResult => { | ||
150 | - this.selector.verifyCodeBtn.data('oneClick', false); | 158 | + $.extend(params, result); |
151 | 159 | ||
152 | - if (codeResult.code === 200) { | ||
153 | - this.countDown(); | ||
154 | - return; | ||
155 | - } else { | ||
156 | - showErrTip(codeResult.message); | ||
157 | - } | 160 | + this.ajax({ |
161 | + url: '/passport/bind/thirdSendMsg', | ||
162 | + type: 'POST', | ||
163 | + data: params | ||
164 | + }).then(codeResult => { | ||
165 | + this.selector.verifyCodeBtn.data('oneClick', false); | ||
166 | + validate.type === 2 && validate.refresh(); | ||
167 | + | ||
168 | + if (codeResult.code === 200) { | ||
169 | + this.countDown(); | ||
170 | + return; | ||
171 | + } else { | ||
172 | + showErrTip(codeResult.message); | ||
173 | + } | ||
174 | + | ||
175 | + (codeResult.changeCaptcha && validate.type !== 2) && validate.refresh(); | ||
176 | + }).catch(() => { | ||
177 | + this.selector.verifyCodeBtn.data('oneClick', false); | ||
178 | + showErrTip('出错了,请重试'); | ||
179 | + validate.refresh(); | ||
180 | + }); | ||
158 | }).catch(() => { | 181 | }).catch(() => { |
159 | this.selector.verifyCodeBtn.data('oneClick', false); | 182 | this.selector.verifyCodeBtn.data('oneClick', false); |
160 | - showErrTip('出错了,请重试'); | ||
161 | }); | 183 | }); |
162 | } | 184 | } |
163 | 185 | ||
@@ -176,8 +198,6 @@ class ThirdBindMobile extends Page { | @@ -176,8 +198,6 @@ class ThirdBindMobile extends Page { | ||
176 | return showErrTip('手机号格式不正确,请重新输入'); | 198 | return showErrTip('手机号格式不正确,请重新输入'); |
177 | } | 199 | } |
178 | 200 | ||
179 | - this.selector.loginBtn.data('oneClick', true); | ||
180 | - | ||
181 | let params = { | 201 | let params = { |
182 | area: area.replace('+', ''), | 202 | area: area.replace('+', ''), |
183 | mobile: pn, | 203 | mobile: pn, |
@@ -191,8 +211,6 @@ class ThirdBindMobile extends Page { | @@ -191,8 +211,6 @@ class ThirdBindMobile extends Page { | ||
191 | type: 'POST', | 211 | type: 'POST', |
192 | data: params | 212 | data: params |
193 | }).then(codeResult => { | 213 | }).then(codeResult => { |
194 | - this.selector.loginBtn.data('oneClick', false); | ||
195 | - | ||
196 | if (codeResult.code === 200) { | 214 | if (codeResult.code === 200) { |
197 | this.continueBind( | 215 | this.continueBind( |
198 | $.extend({isBind: 'N', isRegister: 'N'}, codeResult.data), | 216 | $.extend({isBind: 'N', isRegister: 'N'}, codeResult.data), |
@@ -202,7 +220,6 @@ class ThirdBindMobile extends Page { | @@ -202,7 +220,6 @@ class ThirdBindMobile extends Page { | ||
202 | showErrTip(codeResult.message); | 220 | showErrTip(codeResult.message); |
203 | } | 221 | } |
204 | }).catch(() => { | 222 | }).catch(() => { |
205 | - this.selector.loginBtn.data('oneClick', false); | ||
206 | showErrTip('出错了,请重试'); | 223 | showErrTip('出错了,请重试'); |
207 | }); | 224 | }); |
208 | } | 225 | } |
-
Please register or login to post a comment