Authored by 郭成尧

Merge branch 'feature/passportctx' into 'release/6.3'

bind-code-add



See merge request !1167
@@ -190,13 +190,9 @@ const bind = { @@ -190,13 +190,9 @@ const bind = {
190 let from = req.cookies.from || 'yohobuy'; 190 let from = req.cookies.from || 'yohobuy';
191 191
192 if (_.isNumber(parseInt(phoneNum, 0)) && openId && sourceType && nickname && areaCode && code) { 192 if (_.isNumber(parseInt(phoneNum, 0)) && openId && sourceType && nickname && areaCode && code) {
193 - req.ctx(BindServiceModel).checkBindCode(areaCode, phoneNum, code).then(result => {  
194 - if (result && result.code && result.code === 200) {  
195 - return req.ctx(BindServiceModel).bindMobile(openId, sourceType,  
196 - phoneNum, areaCode, password, from, nickname);  
197 - } else {  
198 - return { code: 400, message: '短信验证码错误', data: '' };  
199 - } 193 + req.ctx(BindServiceModel).bindMobile({
  194 + openId, sourceType, phoneNum,
  195 + areaCode, password, from, nickname, code
200 }).then(result => { 196 }).then(result => {
201 let refer = helpers.urlFormat('/passport/bind/success?type=bind'); 197 let refer = helpers.urlFormat('/passport/bind/success?type=bind');
202 198
@@ -50,25 +50,26 @@ class BindServiceModel extends global.yoho.BaseModel { @@ -50,25 +50,26 @@ class BindServiceModel extends global.yoho.BaseModel {
50 }}); 50 }});
51 } 51 }
52 52
53 - bindMobile(openId, sourceType, mobile, area, password, from, nickname) {  
54 - let params = { 53 + bindMobile(params) {
  54 + let finalParams = {
55 method: 'app.passport.bind', 55 method: 'app.passport.bind',
56 - mobile: mobile,  
57 - open_id: openId,  
58 - source_type: sourceType,  
59 - area: area,  
60 - business_line: FROM[from].business_line 56 + mobile: params.phoneNum,
  57 + code: params.code,
  58 + open_id: params.openId,
  59 + source_type: params.sourceType,
  60 + area: params.areaCode,
  61 + business_line: FROM[params.from].business_line
61 }; 62 };
62 63
63 - if (password) {  
64 - params.password = password; 64 + if (params.password) {
  65 + finalParams.password = params.password;
65 } 66 }
66 67
67 - if (nickname) {  
68 - params.nickname = nickname; 68 + if (params.nickname) {
  69 + finalParams.nickname = params.nickname;
69 } 70 }
70 71
71 - return this.get({ data: params }); 72 + return this.get({ data: finalParams });
72 } 73 }
73 74
74 relateMobile(openId, sourceType, mobile, area) { 75 relateMobile(openId, sourceType, mobile, area) {