Authored by yyq

Merge branch 'release/5.4.1' of git.yoho.cn:fe/yohobuy-node into release/5.4.1

@@ -91,10 +91,6 @@ const miniCart = (req, res, next) => { @@ -91,10 +91,6 @@ const miniCart = (req, res, next) => {
91 data: ret 91 data: ret
92 }; 92 };
93 93
94 - if (req.query.json === '1') {  
95 - return res.send(dest);  
96 - }  
97 -  
98 res.type('text/javascript'); 94 res.type('text/javascript');
99 res.send(req.query.callback + '(' + JSON.stringify(dest) + ')'); 95 res.send(req.query.callback + '(' + JSON.stringify(dest) + ')');
100 }).catch(next); 96 }).catch(next);
@@ -153,10 +149,6 @@ const cart = (req, res, next) => { @@ -153,10 +149,6 @@ const cart = (req, res, next) => {
153 service.getCartData(uid, shoppingKey) 149 service.getCartData(uid, shoppingKey)
154 .then(ret => { 150 .then(ret => {
155 151
156 - if (req.query.json === '1') {  
157 - return res.send(ret);  
158 - }  
159 -  
160 return res.render('cart', { 152 return res.render('cart', {
161 title: '购物车 | ' + (res.locals.title || ''), 153 title: '购物车 | ' + (res.locals.title || ''),
162 module: 'cart', 154 module: 'cart',
@@ -140,7 +140,7 @@ const formatCartGoods = (cartGoods, isAdvanceCart, inValid, isOffShelves, analys @@ -140,7 +140,7 @@ const formatCartGoods = (cartGoods, isAdvanceCart, inValid, isOffShelves, analys
140 if (it.min_buy_number) { 140 if (it.min_buy_number) {
141 goods.minBuyNumber = Number(it.min_buy_number); 141 goods.minBuyNumber = Number(it.min_buy_number);
142 142
143 - if(goods.minBuyNumber > 1) { 143 + if (goods.minBuyNumber > 1) {
144 goods.tipMessage = goods.minBuyNumber + '件起购'; 144 goods.tipMessage = goods.minBuyNumber + '件起购';
145 } 145 }
146 } 146 }
@@ -535,6 +535,9 @@ const formatCart = (cartDataRet, uid, shoppingKey, cartDelList) => { @@ -535,6 +535,9 @@ const formatCart = (cartDataRet, uid, shoppingKey, cartDelList) => {
535 let advCartData = _.get(cartData, 'advance_cart_data'); 535 let advCartData = _.get(cartData, 'advance_cart_data');
536 let ordCartData = _.get(cartData, 'ordinary_cart_data'); 536 let ordCartData = _.get(cartData, 'ordinary_cart_data');
537 537
  538 + // 移除的商品列表
  539 + result.deleteShop = cartDelList;
  540 +
538 // 接口异常时,购物车置为空 541 // 接口异常时,购物车置为空
539 if (!cartData) { 542 if (!cartData) {
540 result.isEmpty = true; 543 result.isEmpty = true;
@@ -595,12 +598,19 @@ const formatCart = (cartDataRet, uid, shoppingKey, cartDelList) => { @@ -595,12 +598,19 @@ const formatCart = (cartDataRet, uid, shoppingKey, cartDelList) => {
595 598
596 if (!result.advanceCart && !result.ordinaryCart) { 599 if (!result.advanceCart && !result.ordinaryCart) {
597 result.isEmpty = true; 600 result.isEmpty = true;
  601 + return result;
  602 + }
  603 +
  604 + if (_.get(result, 'ordinaryCart.promotionInfos')) {
  605 + result.ordinaryCart.promotionInfos = _.filter(result.ordinaryCart.promotionInfos, pinfo => {
  606 + return pinfo && pinfo.tag && pinfo.promotionId > 0;
  607 + });
598 } 608 }
599 609
600 // promotionInfos, gifts, priceGifts 放一起展示 610 // promotionInfos, gifts, priceGifts 放一起展示
601 - let hasGifts = result.ordinaryCart.gifts && result.ordinaryCart.gifts.length;  
602 - let hasPrices = result.ordinaryCart.priceGifts && result.ordinaryCart.priceGifts.length;  
603 - let hasPromo = result.ordinaryCart.promotionInfos && result.ordinaryCart.promotionInfos.length; 611 + let hasGifts = _.get(result, 'ordinaryCart.gifts') && _.get(result, 'ordinaryCart.gifts').length;
  612 + let hasPrices = _.get(result, 'ordinaryCart.priceGifts') && _.get(result, 'ordinaryCart.priceGifts').length;
  613 + let hasPromo = _.get(result, 'ordinaryCart.promotionInfos') && _.get(result, 'ordinaryCart.promotionInfos').length;
604 let orderAmount = (parseFloat(_.get(advStat, 'orderAmount', 0)) + 614 let orderAmount = (parseFloat(_.get(advStat, 'orderAmount', 0)) +
605 parseFloat(_.get(ordStat, 'orderAmount', 0))).toFixed(2); 615 parseFloat(_.get(ordStat, 'orderAmount', 0))).toFixed(2);
606 let lastOrderAmount = (parseFloat(_.get(advStat, 'lastOrderAmount', 0)) + 616 let lastOrderAmount = (parseFloat(_.get(advStat, 'lastOrderAmount', 0)) +
@@ -618,9 +628,6 @@ const formatCart = (cartDataRet, uid, shoppingKey, cartDelList) => { @@ -618,9 +628,6 @@ const formatCart = (cartDataRet, uid, shoppingKey, cartDelList) => {
618 selectedGoodsCount: _.get(advStat, 'selectedGoodsCount', 0) + _.get(ordStat, 'selectedGoodsCount', 0) 628 selectedGoodsCount: _.get(advStat, 'selectedGoodsCount', 0) + _.get(ordStat, 'selectedGoodsCount', 0)
619 }; 629 };
620 630
621 - // 移除的商品列表  
622 - result.deleteShop = cartDelList;  
623 -  
624 // 普通购物车和预售购物车都为空 631 // 普通购物车和预售购物车都为空
625 /* if (ordinaryCount === 0 && advanceCount === 0 && ordinarySoldOut && advanceSoldOut) { 632 /* if (ordinaryCount === 0 && advanceCount === 0 && ordinarySoldOut && advanceSoldOut) {
626 result.isEmpty = true; 633 result.isEmpty = true;
@@ -11,6 +11,7 @@ const _ = require('lodash'); @@ -11,6 +11,7 @@ const _ = require('lodash');
11 const guangModel = require('../models/index'); 11 const guangModel = require('../models/index');
12 const headerModel = require('../../../doraemon/models/header'); 12 const headerModel = require('../../../doraemon/models/header');
13 const ghelper = require('../models/guang-helper'); 13 const ghelper = require('../models/guang-helper');
  14 +const urlHelper = require('../models/url-helper');
14 const querystring = require('querystring'); 15 const querystring = require('querystring');
15 const helpers = global.yoho.helpers; 16 const helpers = global.yoho.helpers;
16 17
@@ -58,7 +59,7 @@ exports.index = (req, res, next) => { @@ -58,7 +59,7 @@ exports.index = (req, res, next) => {
58 pageSize: pageSize, 59 pageSize: pageSize,
59 type: type, 60 type: type,
60 pathNav: pathNav, 61 pathNav: pathNav,
61 - baseUrl: helpers.urlFormat('/' + channel + `-t${type}`, null, 'guang'), 62 + baseUrl: urlHelper.listUrl(channel, type),
62 page: page, 63 page: page,
63 total: (ret[2] && ret[2].total) || 0 64 total: (ret[2] && ret[2].total) || 0
64 }, 65 },
@@ -169,7 +170,7 @@ exports.editor = (req, res, next) => { @@ -169,7 +170,7 @@ exports.editor = (req, res, next) => {
169 exRecos: ret[4], 170 exRecos: ret[4],
170 171
171 gender: gender, 172 gender: gender,
172 - baseUrl: helpers.urlFormat('/' + channel + `-author-i${authorId}`, null, 'guang'), 173 + baseUrl: urlHelper.editorUrl(channel, authorId),
173 pageSize: pageSize, 174 pageSize: pageSize,
174 pathNav: pathNav, 175 pathNav: pathNav,
175 page: page, 176 page: page,
@@ -38,7 +38,7 @@ exports.spager = function() { @@ -38,7 +38,7 @@ exports.spager = function() {
38 pageSizeVar = options.hash.pageSizeVar || 'pageSize'; 38 pageSizeVar = options.hash.pageSizeVar || 'pageSize';
39 39
40 // 清除原来page(page=1&) 重新定义page 40 // 清除原来page(page=1&) 重新定义page
41 - let clearPageReg = new RegExp(pageVar + '=[^&]*(&|$)'), 41 + let clearPageReg = /\/$/,
42 clearSizeReg = new RegExp(pageSizeVar + '=[^&]*(&|$)'), 42 clearSizeReg = new RegExp(pageSizeVar + '=[^&]*(&|$)'),
43 base = baseUrl.replace(clearPageReg, ''); 43 base = baseUrl.replace(clearPageReg, '');
44 44
@@ -8,7 +8,7 @@ @@ -8,7 +8,7 @@
8 const _ = require('lodash'); 8 const _ = require('lodash');
9 const moment = require('moment'); 9 const moment = require('moment');
10 const ghelper = require('./guang-helper'); 10 const ghelper = require('./guang-helper');
11 -const urlHelper = require('./urlHelper'); 11 +const urlHelper = require('./url-helper');
12 12
13 const helpers = global.yoho.helpers; 13 const helpers = global.yoho.helpers;
14 const serviceApi = global.yoho.ServiceAPI; 14 const serviceApi = global.yoho.ServiceAPI;
@@ -7,7 +7,7 @@ @@ -7,7 +7,7 @@
7 const helpers = global.yoho.helpers; 7 const helpers = global.yoho.helpers;
8 8
9 module.exports.editorUrl = function(channel, authorId) { 9 module.exports.editorUrl = function(channel, authorId) {
10 - return helpers.urlFormat(`/${channel}-author-i${authorId}/`, null, 'guang'); 10 + return helpers.urlFormat(`/author-${channel}-${authorId}/`, null, 'guang');
11 }; 11 };
12 12
13 module.exports.listUrl = function(channel, type) { 13 module.exports.listUrl = function(channel, type) {
@@ -17,7 +17,7 @@ module.exports = [ @@ -17,7 +17,7 @@ module.exports = [
17 return req.path === '/'; 17 return req.path === '/';
18 }, 18 },
19 target: (req) => { 19 target: (req) => {
20 - return helpers.urlFormat(`/${req.query.channel || 'boys'}/`, null, 'guang'); 20 + return helpers.urlFormat(`/${req.yoho.channel}/`, null, 'guang');
21 } 21 }
22 }, 22 },
23 23
@@ -25,9 +25,22 @@ module.exports = [ @@ -25,9 +25,22 @@ module.exports = [
25 { 25 {
26 type: TYPE.rewrite, 26 type: TYPE.rewrite,
27 origin: /^\/(boys|girls|kids|lifestyle)(\/*)$/, 27 origin: /^\/(boys|girls|kids|lifestyle)(\/*)$/,
28 - target: (req, match, p1) => {  
29 - req.query.channel = p1;  
30 - return `/guang/?chanel=${p1}`; 28 + target: (req, match, channel) => {
  29 + req.query.channel = channel;
  30 + return `/guang/?chanel=${channel}`;
  31 + }
  32 + },
  33 +
  34 + // 老的首页 + 类型 + 翻页
  35 + {
  36 + type: TYPE.redirect,
  37 + origin: req => /index\/index/i.test(req.path),
  38 + target: (req) => {
  39 + return helpers.urlFormat(
  40 + `/${req.yoho.channel}-t${req.query.type || 0}${req.query.page ? '-p' + req.query.page : ''}/`,
  41 + null,
  42 + 'guang'
  43 + );
31 } 44 }
32 }, 45 },
33 46
@@ -35,10 +48,10 @@ module.exports = [ @@ -35,10 +48,10 @@ module.exports = [
35 { 48 {
36 type: TYPE.rewrite, 49 type: TYPE.rewrite,
37 origin: /^\/(boys|girls|kids|lifestyle)-t([\d]+)(\/*)$/, 50 origin: /^\/(boys|girls|kids|lifestyle)-t([\d]+)(\/*)$/,
38 - target: (req, match, p1, p2) => {  
39 - req.query.channel = p1;  
40 - req.query.type = p2;  
41 - return `/guang/?chanel=${p1}&type=${p2}`; 51 + target: (req, match, channel, type) => {
  52 + req.query.channel = channel;
  53 + req.query.type = type;
  54 + return `/guang/?chanel=${channel}&type=${type}`;
42 } 55 }
43 }, 56 },
44 57
@@ -46,11 +59,11 @@ module.exports = [ @@ -46,11 +59,11 @@ module.exports = [
46 { 59 {
47 type: TYPE.rewrite, 60 type: TYPE.rewrite,
48 origin: /^\/(boys|girls|kids|lifestyle)-t([\d]+)-p([\d]+)(\/*)$/, 61 origin: /^\/(boys|girls|kids|lifestyle)-t([\d]+)-p([\d]+)(\/*)$/,
49 - target: (req, match, p1, p2, p3) => {  
50 - req.query.channel = p1;  
51 - req.query.type = p2;  
52 - req.query.page = p3;  
53 - return `/guang/index/index/?type=${p2}&channel=${p3}`; 62 + target: (req, match, channel, type, page) => {
  63 + req.query.channel = channel;
  64 + req.query.type = type;
  65 + req.query.page = page;
  66 + return `/guang/index/index/?type=${type}&channel=${page}`;
54 } 67 }
55 }, 68 },
56 69
@@ -62,39 +75,39 @@ module.exports = [ @@ -62,39 +75,39 @@ module.exports = [
62 }, 75 },
63 target: (req) => { 76 target: (req) => {
64 let channel = req.yoho.channel; 77 let channel = req.yoho.channel;
65 - let aid = req.query.author_id; 78 + let authorId = req.query.author_id;
  79 + let page = req.query.page;
66 80
67 - if (!aid) { 81 + if (!authorId) {
68 return helpers.urlFormat(`/${channel}/`, null, 'guang'); 82 return helpers.urlFormat(`/${channel}/`, null, 'guang');
69 } 83 }
70 84
71 - req.mobileUrl = `${MOBILE_DOMAIN}/author/${aid}/`;  
72 - return helpers.urlFormat(`/${channel}-author-i${aid}/`, null, 'guang'); 85 + return helpers.urlFormat(`/author-${channel}-${authorId}${page ? '-p' + page : ''}/`, null, 'guang');
73 } 86 }
74 }, 87 },
75 88
76 // 编缉首页 89 // 编缉首页
77 { 90 {
78 type: TYPE.rewrite, 91 type: TYPE.rewrite,
79 - origin: /^\/(boys|girls|kids|lifestyle)-author-i([\d]+)(\/*)$/,  
80 - target: (req, match, p1, p2) => {  
81 - req.query.channel = p1;  
82 - req.query.author_id = p2;  
83 - req.mobileUrl = `${MOBILE_DOMAIN}/author/${p2}/`;  
84 - return `/guang/index/editor?channel=${p1}&author_id=${p2}`; 92 + origin: /^\/author-(boys|girls|kids|lifestyle)-([\d]+)(\/*)$/,
  93 + target: (req, match, channel, authorId) => {
  94 + req.query.channel = channel;
  95 + req.query.author_id = authorId;
  96 + req.mobileUrl = `${MOBILE_DOMAIN}/author-${channel}-${authorId}/`;
  97 + return `/guang/index/editor?channel=${channel}&author_id=${authorId}`;
85 } 98 }
86 }, 99 },
87 100
88 // 编缉首页 + 翻页 101 // 编缉首页 + 翻页
89 { 102 {
90 type: TYPE.rewrite, 103 type: TYPE.rewrite,
91 - origin: /^\/(boys|girls|kids|lifestyle)-author-i([\d]+)-p([\d]+)(\/*)$/,  
92 - target: (req, match, p1, p2, p3) => {  
93 - req.query.channel = p1;  
94 - req.query.author_id = p2;  
95 - req.query.page = p3;  
96 - req.mobileUrl = `${MOBILE_DOMAIN}/author/${p2}`;  
97 - return `/guang/index/editor?channel=${p1}&author_id=${p2}&page=${p3}`; 104 + origin: /^\/author-(boys|girls|kids|lifestyle)-([\d]+)-p([\d]+)(\/*)$/,
  105 + target: (req, match, channel, authorId, page) => {
  106 + req.query.channel = channel;
  107 + req.query.author_id = authorId;
  108 + req.query.page = page;
  109 + req.mobileUrl = `${MOBILE_DOMAIN}/author-${channel}-${authorId}-p${page}/`;
  110 + return `/guang/index/editor?channel=${channel}&author_id=${authorId}&page=${page}`;
98 } 111 }
99 } 112 }
100 113
@@ -55,7 +55,8 @@ module.exports = () => { @@ -55,7 +55,8 @@ module.exports = () => {
55 if (guangDetailReg.test(url)) { 55 if (guangDetailReg.test(url)) {
56 data.mobileRefer += url.replace(/\/guang\/info\/index/, '/info/index'); 56 data.mobileRefer += url.replace(/\/guang\/info\/index/, '/info/index');
57 } else if (url === '/guang/index/editor') { 57 } else if (url === '/guang/index/editor') {
58 - data.mobileRefer += `/author/${req.query.author_id}/`; 58 + data.mobileRefer += `/author-${req.yoho.channel}-${req.query.author_id}/`;
  59 + req.query = {};
59 } 60 }
60 } else if (proRegNew.test(url)) { 61 } else if (proRegNew.test(url)) {
61 data.mobileRefer = url.replace(proRegNew, `//${domain}/product/pro_$1_1/1.html$2`); 62 data.mobileRefer = url.replace(proRegNew, `//${domain}/product/pro_$1_1/1.html$2`);
@@ -209,7 +209,11 @@ @@ -209,7 +209,11 @@
209 </div> 209 </div>
210 {{/stat}} 210 {{/stat}}
211 211
212 - {{#if deleteShop}} 212 + {{> mix/cart/cart-pre-sell-tpl }}
  213 + </div>
  214 +{{/if}}
  215 +
  216 +{{#if deleteShop}}
213 <div class="cart-del-goods"> 217 <div class="cart-del-goods">
214 <div class="cart-del-goods-title">已删除商品,您可以重新购买或移入收藏:</div> 218 <div class="cart-del-goods-title">已删除商品,您可以重新购买或移入收藏:</div>
215 <ul id="Y_delReselWrap"> 219 <ul id="Y_delReselWrap">
@@ -230,8 +234,4 @@ @@ -230,8 +234,4 @@
230 {{/each}} 234 {{/each}}
231 </ul> 235 </ul>
232 </div> 236 </div>
233 - {{/if}}  
234 -  
235 - {{> mix/cart/cart-pre-sell-tpl }}  
236 - </div>  
237 {{/if}} 237 {{/if}}
@@ -1025,7 +1025,7 @@ @@ -1025,7 +1025,7 @@
1025 background: transparent; 1025 background: transparent;
1026 font-size: 14px; 1026 font-size: 14px;
1027 font-weight: 300; 1027 font-weight: 300;
1028 - margin-top: 5px; 1028 + margin-top: 3px;
1029 color:#ff575c; 1029 color:#ff575c;
1030 &.tip-message-coin { 1030 &.tip-message-coin {
1031 color: #000; 1031 color: #000;