Authored by 周少峰

Merge branch 'gray'

@@ -135,16 +135,15 @@ const exchangeDetail = (req, res, next) => { @@ -135,16 +135,15 @@ const exchangeDetail = (req, res, next) => {
135 * 我的订单-获取换货方式 135 * 我的订单-获取换货方式
136 */ 136 */
137 const getDelivery = (req, res, next) => { 137 const getDelivery = (req, res, next) => {
138 - 138 + let orderCode = req.body.orderCode;
139 let areaCode = req.body.areaCode; 139 let areaCode = req.body.areaCode;
  140 + let skns = req.body.skns;
140 141
141 // 获取必要参数 142 // 获取必要参数
142 let uid = req.user.uid; 143 let uid = req.user.uid;
143 - let gender = req.yoho.gender;  
144 - let channel = req.yoho.channel;  
145 144
146 // 调用接口获得该用户支持的换货方式(白金会员可享受上门换货,偏远地区不支持上门换货) 145 // 调用接口获得该用户支持的换货方式(白金会员可享受上门换货,偏远地区不支持上门换货)
147 - req.ctx(returnsModel).getDelivery(areaCode, uid, gender, channel).then(result => { 146 + req.ctx(returnsModel).getDelivery(orderCode, areaCode, uid, skns).then(result => {
148 res.send(result); 147 res.send(result);
149 }).catch(next); 148 }).catch(next);
150 }; 149 };
@@ -203,14 +203,15 @@ module.exports = class extends global.yoho.BaseModel { @@ -203,14 +203,15 @@ module.exports = class extends global.yoho.BaseModel {
203 * @param $yhChannel 203 * @param $yhChannel
204 * @return mixed 204 * @return mixed
205 */ 205 */
206 - getDeliveryAsync(areaCode, uid, gender, channel) { 206 + getDeliveryAsync(orderCode, areaCode, uid, skns) {
  207 + skns = skns || [];
207 208
208 let options = { 209 let options = {
209 - method: 'app.change.getDelivery', 210 + method: 'app.change.refreshDelivery',
210 uid: uid, 211 uid: uid,
  212 + order_code: orderCode,
211 area_code: areaCode, 213 area_code: areaCode,
212 - gender: gender,  
213 - yh_channel: channel 214 + skns: JSON.stringify(skns)
214 }; 215 };
215 216
216 return this.post({data: options}); 217 return this.post({data: options});
@@ -677,8 +677,16 @@ module.exports = class extends global.yoho.BaseModel { @@ -677,8 +677,16 @@ module.exports = class extends global.yoho.BaseModel {
677 } 677 }
678 678
679 // 获取换货方式 679 // 获取换货方式
680 - getDelivery(areaCode, uid, gender, channel) {  
681 - return new ReturnAPI(this.ctx).getDeliveryAsync(areaCode, uid, gender, channel); 680 + getDelivery(orderCode, areaCode, uid, skns) {
  681 + return new ReturnAPI(this.ctx).getDeliveryAsync(orderCode, areaCode, uid, _.split(skns, ',')).then(result => {
  682 + if (+result.code === 200) {
  683 + _.remove(result.data, n => {
  684 + return n.is_support !== 'Y';
  685 + });
  686 + }
  687 +
  688 + return result;
  689 + });
682 } 690 }
683 691
684 // 取消退货申请 692 // 取消退货申请
@@ -73,7 +73,7 @@ const bind = { @@ -73,7 +73,7 @@ const bind = {
73 let openId = req.body.openId; 73 let openId = req.body.openId;
74 let area = req.body.area; 74 let area = req.body.area;
75 75
76 - if (req.session.verifyCode !== 'relateStep1') { 76 + if (req.session.type !== 'relateStep1') {
77 return next(); 77 return next();
78 } 78 }
79 79
@@ -140,10 +140,10 @@ const bind = { @@ -140,10 +140,10 @@ const bind = {
140 return {code: 201, message: result.message, data: {user: user}}; 140 return {code: 201, message: result.message, data: {user: user}};
141 }); 141 });
142 } else if (result.code === 200 && result.data.is_register === 3) { 142 } else if (result.code === 200 && result.data.is_register === 3) {
143 - let nextUrl = helpers.urlFormat('/passport/thirdlogin/relate');  
144 -  
145 // 关联流程 143 // 关联流程
146 - return {code: 203, message: result.message, data: {next: nextUrl}}; 144 + return userService.getUserInfo(area, mobile).then(user => {
  145 + return {code: 203, message: result.message, data: {user: user}};
  146 + });
147 } else if (result.code === 506 || result.code === 505) { 147 } else if (result.code === 506 || result.code === 505) {
148 return userService.getUserInfo(area, mobile).then(user => { 148 return userService.getUserInfo(area, mobile).then(user => {
149 // 绑定流程:code=506 手机号码注册过,而且该手机号码也已经绑定过该类型第三方 149 // 绑定流程:code=506 手机号码注册过,而且该手机号码也已经绑定过该类型第三方
@@ -139,10 +139,11 @@ const cert = { @@ -139,10 +139,11 @@ const cert = {
139 139
140 if (_.get(result, 'data.isCanBind') === 'Y') { 140 if (_.get(result, 'data.isCanBind') === 'Y') {
141 nextUrl = helpers.urlFormat('/passport/cert/cert'); 141 nextUrl = helpers.urlFormat('/passport/cert/cert');
  142 + return {code: 200, message: result.message, data: {next: nextUrl}};
142 } else { 143 } else {
143 - nextUrl = helpers.urlFormat('/passport/cert/relate'); 144 + // 不可以关联
  145 + return {code: 403, message: '绑定失败,该手机号已注册,请更换或使用该手机号直接登录'};
144 } 146 }
145 - return {code: 200, message: result.message, data: {next: nextUrl}};  
146 } else { 147 } else {
147 return {code: result.code, message: result.message, data: result.data ? result.data : ''}; 148 return {code: result.code, message: result.message, data: result.data ? result.data : ''};
148 } 149 }
@@ -264,6 +264,8 @@ let mobileRegister = (req, res, next) => { @@ -264,6 +264,8 @@ let mobileRegister = (req, res, next) => {
264 let mobile = req.body.mobile; 264 let mobile = req.body.mobile;
265 let code = req.body.code; // 短信验证码 265 let code = req.body.code; // 短信验证码
266 let password = req.body.password; 266 let password = req.body.password;
  267 + let inviteCode = req.body.inviteCode;
  268 + let clientIp = req.yoho.clientIp;
267 let result = yield regService.validMobileCode(area, mobile, code); // 验证注册的标识码是否有效 269 let result = yield regService.validMobileCode(area, mobile, code); // 验证注册的标识码是否有效
268 270
269 if (!result.code || result.code !== 200) { 271 if (!result.code || result.code !== 200) {
@@ -272,7 +274,9 @@ let mobileRegister = (req, res, next) => { @@ -272,7 +274,9 @@ let mobileRegister = (req, res, next) => {
272 } 274 }
273 275
274 /* 手机注册: 调用注册接口*/ 276 /* 手机注册: 调用注册接口*/
275 - let regResult = yield regService.regMobileAes(area, mobile, password, code, cookie.getShoppingKey(req), req.body); // eslint-disable-line 277 + let regResult = yield regService.regMobileAes(
  278 + area, mobile, password, code, cookie.getShoppingKey(req), inviteCode, clientIp
  279 + );
276 280
277 if (!regResult.code || regResult.code !== 200) { 281 if (!regResult.code || regResult.code !== 200) {
278 data.message = '注册失败'; 282 data.message = '注册失败';
@@ -10,7 +10,7 @@ const logger = global.yoho.logger; @@ -10,7 +10,7 @@ const logger = global.yoho.logger;
10 10
11 const signinByPasswordWithAes = (area, profile, password, shoppingKey, clientIp) => { 11 const signinByPasswordWithAes = (area, profile, password, shoppingKey, clientIp) => {
12 let param = { 12 let param = {
13 - method: 'app.passport.signinAES', 13 + method: 'sesame.flowering.higher',
14 area: area, 14 area: area,
15 profile: profile, 15 profile: profile,
16 password: aes.aesPwd(password) 16 password: aes.aesPwd(password)
@@ -31,7 +31,7 @@ let validMobileCode = (area, mobile, code) => { @@ -31,7 +31,7 @@ let validMobileCode = (area, mobile, code) => {
31 return api.post('', params); 31 return api.post('', params);
32 }; 32 };
33 33
34 -let regMobileAes = (area, mobile, password, code, shoppingKey, extParam)=> { 34 +let regMobileAes = (area, mobile, password, code, shoppingKey, inviteCode, clientIp)=> {
35 let params = { 35 let params = {
36 method: 'app.passport.registerAES', 36 method: 'app.passport.registerAES',
37 area: area, 37 area: area,
@@ -44,13 +44,16 @@ let regMobileAes = (area, mobile, password, code, shoppingKey, extParam)=> { @@ -44,13 +44,16 @@ let regMobileAes = (area, mobile, password, code, shoppingKey, extParam)=> {
44 params.shopping_key = shoppingKey; 44 params.shopping_key = shoppingKey;
45 } 45 }
46 46
47 - if (extParam) {  
48 - if (extParam.inviteCode) {  
49 - params.inviteCode = extParam.inviteCode;  
50 - } 47 + if (inviteCode) {
  48 + params.inviteCode = inviteCode;
51 } 49 }
52 50
53 - return api.post('', params); 51 + return api.post('', params, {
  52 + headers: {
  53 + 'user-agent': 'yoho/nodejs',
  54 + 'X-YOHO-IP': clientIp
  55 + }
  56 + });
54 }; 57 };
55 58
56 module.exports = { 59 module.exports = {
@@ -133,4 +133,27 @@ @@ -133,4 +133,27 @@
133 <div class="backdrop" style="display:none"></div> 133 <div class="backdrop" style="display:none"></div>
134 </div> 134 </div>
135 135
  136 +<div id="norelate" style="display:none">
  137 + <div class="mask">
  138 + <div class="bindconfrimwrapper">
  139 + <div class="topwrapper">
  140 + <img src="" alt="" class="userphoto" id="userphoto-relate">
  141 + <span class="username">
  142 + 用户名: <i id="username-relate"></i>
  143 + </span>
  144 + </div>
  145 + <h2 class="usertaginfo">
  146 + 手机号
  147 + <span id="registphone-relate"></span>
  148 + 已经被以上账户注册。
  149 + </h2>
  150 + <h1 class="usertagremind">您可以更换一个新的手机号码绑定该账号,也可以使用该手机号码直接登录</h1>
  151 + <div class="gobindbottomwrapper">
  152 + <a href="javascript:;" class="logindirectly" id="yohobindbtn3">绑定其他手机号</a>
  153 + <a href="http://www.yohobuy.com/signin.html" class="logindirectly" id="logindirectly3">使用手机号直接登录</a>
  154 + </div>
  155 + </div>
  156 + </div>
  157 +</div>
  158 +
136 {{> gee-captcha}} 159 {{> gee-captcha}}
@@ -12,30 +12,10 @@ @@ -12,30 +12,10 @@
12 已经被以上账户注册,点击 12 已经被以上账户注册,点击
13 <a href="{{bindLogin}}" target="_blank">登录该账号</a> 13 <a href="{{bindLogin}}" target="_blank">登录该账号</a>
14 </h3> 14 </h3>
15 - <p>您可以使用此号码进行账户关联或更换一个新的手机号码</p> 15 + <p>您可以更换一个新的手机号码绑定该账号,</p><p>也可以使用该手机号码直接登录</p>
16 </div> 16 </div>
17 <div class="option-btn"> 17 <div class="option-btn">
18 - <a id="next-step-btn">关联此手机号</a>  
19 <a href="{{changeHref}}">更换新手机号</a> 18 <a href="{{changeHref}}">更换新手机号</a>
20 </div> 19 </div>
21 - <p class="remind-tips">注:关联的手机号码不能用来登录此账户</p>  
22 </div> 20 </div>
23 - <div id="code-validate" class="code-validate hide">  
24 - <div class="action-link">短信验证码已发送至<span>{{phoneNum}}</span></div>  
25 - <div class="validate-wrapper action-link">  
26 - <div class="code-name">短信验证码</div>  
27 - <input type="text" class="msg-code">  
28 - <label class="get-code">免费获取短信验证码</label>  
29 - <label class="count-down"><span>60</span>秒后可重新操作</label>  
30 - <div class="code-error hide">  
31 - <i></i>  
32 - 验证码错误  
33 - </div>  
34 - </div>  
35 - <div class="action-link">  
36 - <button id="relate-btn" class="relate-btn left">确定</button>  
37 - <a class="perv-step" href="javascript:void(0)">返回上一步</a>  
38 - </div>  
39 - </div>  
40 - <div id="hide-info" data-mobile="{{phoneNum}}" data-area="{{areaCode}}" data-refer="{{refer}}"></div>  
41 </div> 21 </div>
1 <div class="login-page passport-page yoho-page clearfix"> 1 <div class="login-page passport-page yoho-page clearfix">
  2 + <div style="font-size: 12px;text-align: center">
  3 + <div style="display: inline-block;width: 990px; height: 25px; background-color: #f5f5f5; line-height: 25px; overflow: hidden; margin-top: 10px;">
  4 + <i class="iconfont" style="font-size: 12px;">&#xe6c9;</i>&nbsp;&nbsp;为保障账户安全与正常使用,依《网络安全法》相关要求,会员账号需绑定手机号。<span style="color: red;">如您尚未绑定手机号,请尽快完成,</span>感谢您对Yoho!Buy有货的理解与支持!
  5 + </div>
  6 + </div>
2 {{# passport}} 7 {{# passport}}
3 {{> login/cover}} 8 {{> login/cover}}
4 <form method='post' onsubmit='return false;'> 9 <form method='post' onsubmit='return false;'>
1 { 1 {
2 "name": "yohobuy-node", 2 "name": "yohobuy-node",
3 - "version": "6.0.4", 3 + "version": "6.0.11",
4 "private": true, 4 "private": true,
5 "description": "A New Yohobuy Project With Express", 5 "description": "A New Yohobuy Project With Express",
6 "repository": { 6 "repository": {
No preview for this file type
This diff could not be displayed because it is too large.
No preview for this file type
No preview for this file type
@@ -303,6 +303,9 @@ deliveryWay = { @@ -303,6 +303,9 @@ deliveryWay = {
303 unsupport: $this.parent().hasClass('unsp-way') 303 unsupport: $this.parent().hasClass('unsp-way')
304 }; 304 };
305 305
  306 + // 设置默认支持状态
  307 + that.deliveryType[data.id].defaultSupport = !that.deliveryType[data.id].unsupport;
  308 +
306 // 更新订单配送方式数据 309 // 更新订单配送方式数据
307 if ($this.hasClass('checked')) { 310 if ($this.hasClass('checked')) {
308 that.updateOrder({way: data.id}); 311 that.updateOrder({way: data.id});
@@ -370,7 +373,7 @@ deliveryWay = { @@ -370,7 +373,7 @@ deliveryWay = {
370 373
371 dt = this.deliveryType[id]; 374 dt = this.deliveryType[id];
372 375
373 - if (support && !dt.unsupport) { 376 + if (support && dt.defaultSupport) {
374 dt.dom.parent().removeClass('unsp-way'); 377 dt.dom.parent().removeClass('unsp-way');
375 dt.unsupport = false; 378 dt.unsupport = false;
376 } else { 379 } else {
@@ -120,12 +120,24 @@ function getRefundCompute() { @@ -120,12 +120,24 @@ function getRefundCompute() {
120 }); 120 });
121 } 121 }
122 122
123 -function syncRefundMode(code) { 123 +function syncRefundMode() {
  124 + var skns = [];
  125 +
  126 + if (!defaultArea) {
  127 + return;
  128 + }
  129 +
  130 + $goodsTable.find('input[type="checkbox"]:checked').each(function() {
  131 + skns.push($(this).siblings('input[name="skn"]').val());
  132 + });
  133 +
124 $.ajax({ 134 $.ajax({
125 type: 'POST', 135 type: 'POST',
126 url: '/home/returns/getDelivery', 136 url: '/home/returns/getDelivery',
127 data: { 137 data: {
128 - areaCode: code 138 + orderCode: orderCode,
  139 + areaCode: defaultArea,
  140 + skns: skns.join(',')
129 } 141 }
130 }).then(function(jsonData) { 142 }).then(function(jsonData) {
131 var _html = ''; 143 var _html = '';
@@ -224,7 +236,7 @@ if ($refundInfo.length) { @@ -224,7 +236,7 @@ if ($refundInfo.length) {
224 } 236 }
225 }); 237 });
226 } else if (defaultArea) { 238 } else if (defaultArea) {
227 - syncRefundMode(defaultArea); 239 + syncRefundMode();
228 } 240 }
229 241
230 defaultArea = defaultArea ? defaultArea : ''; 242 defaultArea = defaultArea ? defaultArea : '';
@@ -282,6 +294,7 @@ $checkBox.change(function() { @@ -282,6 +294,7 @@ $checkBox.change(function() {
282 $par.next().hide(); 294 $par.next().hide();
283 } 295 }
284 296
  297 + syncRefundMode();
285 getRefundCompute(); 298 getRefundCompute();
286 }); 299 });
287 300
@@ -373,11 +386,9 @@ function fileChangeEvent() { @@ -373,11 +386,9 @@ function fileChangeEvent() {
373 fileChangeEvent();// 初始化上传图片事件 386 fileChangeEvent();// 初始化上传图片事件
374 387
375 $exchange.on('change', '#streets', function() { 388 $exchange.on('change', '#streets', function() {
376 - var code = $(this).val() * 1; 389 + defaultArea = $(this).val() * 1;
377 390
378 - if (code) {  
379 - syncRefundMode(code);  
380 - } 391 + syncRefundMode();
381 }); 392 });
382 393
383 $refundType.change(function() { 394 $refundType.change(function() {
@@ -21,6 +21,8 @@ var $wrapper = $('.bindwrapper'), @@ -21,6 +21,8 @@ var $wrapper = $('.bindwrapper'),
21 var captcha = new Captcha('#captcha').init(); 21 var captcha = new Captcha('#captcha').init();
22 var captcha2; 22 var captcha2;
23 23
  24 +var Alert = require('../../common/dialog').Alert;
  25 +
24 require('../../simple-header'); 26 require('../../simple-header');
25 27
26 /** 28 /**
@@ -381,8 +383,7 @@ function nextStep() { @@ -381,8 +383,7 @@ function nextStep() {
381 circleTime($('#mobile').val()); 383 circleTime($('#mobile').val());
382 } else if (data.code === 203) { 384 } else if (data.code === 203) {
383 // 已注册 可关联 385 // 已注册 可关联
384 - $('#bindmobileform').attr('action', data.data.next);  
385 - $('#bindmobileform').submit(); 386 + new Alert('绑定失败,该手机号已注册,请更换或使用该手机号直接登录').show();
386 } else if (data.code === 205) { 387 } else if (data.code === 205) {
387 // 未注册 不可关联 388 // 未注册 不可关联
388 username = data.data.user.username; 389 username = data.data.user.username;
@@ -11,6 +11,8 @@ var $wrapper = $('.bindwrapper'), @@ -11,6 +11,8 @@ var $wrapper = $('.bindwrapper'),
11 $phoneTip = $wrapper.find('.phone-err-tip'), 11 $phoneTip = $wrapper.find('.phone-err-tip'),
12 $nextBtn = $wrapper.find('.yohobindbtn'); 12 $nextBtn = $wrapper.find('.yohobindbtn');
13 13
  14 +var Alert = require('../../common/dialog').Alert;
  15 +
14 require('../../simple-header'); 16 require('../../simple-header');
15 17
16 /** 18 /**
@@ -151,7 +153,7 @@ function nextStep() { @@ -151,7 +153,7 @@ function nextStep() {
151 $phoneTip.removeClass('hide'); 153 $phoneTip.removeClass('hide');
152 } else { 154 } else {
153 if (data && data.message) { 155 if (data && data.message) {
154 - alert(data.message); // eslint-disable-line 156 + new Alert(data.message).show();
155 } 157 }
156 } 158 }
157 } 159 }
@@ -70,7 +70,7 @@ var couponPickConfig = { @@ -70,7 +70,7 @@ var couponPickConfig = {
70 }] 70 }]
71 }, 71 },
72 over: { 72 over: {
73 - content: '<i class="iconfont">&#xe61f;</i>优惠券已光', 73 + content: '<i class="iconfont">&#xe61f;</i>优惠券已光',
74 subContents: ['尝试领取其它优惠券吧'], 74 subContents: ['尝试领取其它优惠券吧'],
75 className: 'top-coupon-dialog', 75 className: 'top-coupon-dialog',
76 btns: [{ 76 btns: [{
@@ -103,7 +103,7 @@ function getCouponInfo() { @@ -103,7 +103,7 @@ function getCouponInfo() {
103 money: data.money || 0, 103 money: data.money || 0,
104 name: data.name || '', 104 name: data.name || '',
105 time: data.time || '', 105 time: data.time || '',
106 - status: 1 // 1:可领取,2:已光,3:已领取 106 + status: 1 // 1:可领取,2:已光,3:已领取
107 }; 107 };
108 }); 108 });
109 } 109 }
@@ -137,18 +137,18 @@ function syncCouponStatus() { @@ -137,18 +137,18 @@ function syncCouponStatus() {
137 for (i = 0; i < info.length; i++) { 137 for (i = 0; i < info.length; i++) {
138 asyncObj[info[i].coupon_id] = info[i]; 138 asyncObj[info[i].coupon_id] = info[i];
139 } 139 }
  140 + }
  141 +
  142 + for (i in couponObj) {
  143 + if (couponObj.hasOwnProperty(i)) {
  144 + coup = asyncObj[i];
140 145
141 - for (i in couponObj) {  
142 - if (couponObj.hasOwnProperty(i)) {  
143 - coup = asyncObj[i];  
144 -  
145 - if (coup) {  
146 - couponObj[i].status = coup.status;  
147 - coup.status === 3 ? setPicked(couponObj[i]) : false;  
148 - } else {  
149 - couponObj[i].status = 2; // 券不存在设置领取状态为已领光  
150 - couponObj[i].dom.text('已领光');  
151 - } 146 + if (coup && (coup.status === 1 || coup.status === 3)) {
  147 + couponObj[i].status = coup.status;
  148 + coup.status === 3 ? setPicked(couponObj[i]) : false;
  149 + } else {
  150 + couponObj[i].status = 2; // 券不存在设置领取状态为已抢光
  151 + couponObj[i].dom.text('已抢光');
152 } 152 }
153 } 153 }
154 } 154 }
@@ -245,7 +245,7 @@ if ($couponWrap && $couponWrap.length) { @@ -245,7 +245,7 @@ if ($couponWrap && $couponWrap.length) {
245 245
246 if (!couponInfo) { // 优惠券号异常错误提示 246 if (!couponInfo) { // 优惠券号异常错误提示
247 return couponAlert(couponPickConfig.failed); 247 return couponAlert(couponPickConfig.failed);
248 - } else if (couponInfo.status === 2) { // 优惠券已光提示 248 + } else if (couponInfo.status === 2) { // 优惠券已光提示
249 return couponAlert(couponPickConfig.over); 249 return couponAlert(couponPickConfig.over);
250 } else if (couponInfo.status === 3) { // 优惠券已领取提示 250 } else if (couponInfo.status === 3) { // 优惠券已领取提示
251 return couponAlert(couponPickConfig.got); 251 return couponAlert(couponPickConfig.got);