Authored by 周少峰

Merge branch 'feature/cartTips' into release/5.5

@@ -189,7 +189,7 @@ const formatCartGoods = (cartGoods, isAdvanceCart, inValid, isOffShelves, analys @@ -189,7 +189,7 @@ const formatCartGoods = (cartGoods, isAdvanceCart, inValid, isOffShelves, analys
189 189
190 // 分析用: 商品ID列表 190 // 分析用: 商品ID列表
191 if (_.isArray(_.get(analysis, 'ids'))) { 191 if (_.isArray(_.get(analysis, 'ids'))) {
192 - analysis.ids.push(it.product_id); 192 + analysis.ids.push(it.product_skn);
193 } 193 }
194 194
195 // 分析用: CRITEO 195 // 分析用: CRITEO
@@ -203,7 +203,7 @@ const formatCartGoods = (cartGoods, isAdvanceCart, inValid, isOffShelves, analys @@ -203,7 +203,7 @@ const formatCartGoods = (cartGoods, isAdvanceCart, inValid, isOffShelves, analys
203 } else { 203 } else {
204 // 分析用: 商品ID列表 204 // 分析用: 商品ID列表
205 if (_.isArray(_.get(analysis, 'ids'))) { 205 if (_.isArray(_.get(analysis, 'ids'))) {
206 - analysis.ids.push(it.product_id); 206 + analysis.ids.push(it.product_skn);
207 } 207 }
208 208
209 // 分析用: CRITEO 209 // 分析用: CRITEO
@@ -460,13 +460,13 @@ const formatPoolPromotionInfos = (infoList, selectedGiftsList) => { @@ -460,13 +460,13 @@ const formatPoolPromotionInfos = (infoList, selectedGiftsList) => {
460 /** 460 /**
461 * 格式化子优惠池信息,返回商品列表,子优惠列表放在每个商品中 461 * 格式化子优惠池信息,返回商品列表,子优惠列表放在每个商品中
462 */ 462 */
463 -const formatSubPromotionPools = (pools, selectedGiftsList, isAdvance) => { 463 +const formatSubPromotionPools = (pools, selectedGiftsList, isAdvance, analysis) => {
464 464
465 let goodsListPool = _.map(pools, p => { 465 let goodsListPool = _.map(pools, p => {
466 let pool = { 466 let pool = {
467 poolType: p.pool_type, 467 poolType: p.pool_type,
468 isBrandGroup: Number(p.pool_type) === 1, 468 isBrandGroup: Number(p.pool_type) === 1,
469 - goodsList: formatCartGoods(p.goods_list, isAdvance), 469 + goodsList: formatCartGoods(p.goods_list, isAdvance, false, false, analysis),
470 promotionInfos: formatPoolPromotionInfos(p.promotion_list, selectedGiftsList) 470 promotionInfos: formatPoolPromotionInfos(p.promotion_list, selectedGiftsList)
471 }; 471 };
472 472
@@ -492,19 +492,19 @@ const formatSubPromotionPools = (pools, selectedGiftsList, isAdvance) => { @@ -492,19 +492,19 @@ const formatSubPromotionPools = (pools, selectedGiftsList, isAdvance) => {
492 * giftsList, priceGifts 已选择的赠品和加价购,判断可选的赠品和加价购是否被选中 492 * giftsList, priceGifts 已选择的赠品和加价购,判断可选的赠品和加价购是否被选中
493 * 优惠池 493 * 优惠池
494 */ 494 */
495 -const formatPromotionPools = (pools, selectedGiftsList, isAdvance) => { 495 +const formatPromotionPools = (pools, selectedGiftsList, isAdvance, analysis) => {
496 return _.map(pools, p => { 496 return _.map(pools, p => {
497 497
498 let pool = { 498 let pool = {
499 poolTitle: p.pool_title, 499 poolTitle: p.pool_title,
500 poolType: p.pool_type, 500 poolType: p.pool_type,
501 isBrandGroup: Number(p.pool_type) === 1, 501 isBrandGroup: Number(p.pool_type) === 1,
502 - goodsList: formatCartGoods(p.goods_list, isAdvance), 502 + goodsList: formatCartGoods(p.goods_list, isAdvance, false, false, analysis),
503 promotionInfos: formatPoolPromotionInfos(p.promotion_list, selectedGiftsList) 503 promotionInfos: formatPoolPromotionInfos(p.promotion_list, selectedGiftsList)
504 }; 504 };
505 505
506 if (p.sub_pool) { 506 if (p.sub_pool) {
507 - pool.subs = formatSubPromotionPools(p.sub_pool, selectedGiftsList, isAdvance); 507 + pool.subs = formatSubPromotionPools(p.sub_pool, selectedGiftsList, isAdvance, analysis);
508 508
509 /* 509 /*
510 if (_.isArray(goodsWithPromotion) && goodsWithPromotion.length) { 510 if (_.isArray(goodsWithPromotion) && goodsWithPromotion.length) {
@@ -560,7 +560,7 @@ const formatCart = (cartDataRet, uid, shoppingKey, cartDelList) => { @@ -560,7 +560,7 @@ const formatCart = (cartDataRet, uid, shoppingKey, cartDelList) => {
560 result.advanceCart = { 560 result.advanceCart = {
561 // 未参加活动的商品 561 // 未参加活动的商品
562 // goodsList: chelper.formatCartGoods(_.get(advCartData, 'goods_list'), true, false, false, analysisData), 562 // goodsList: chelper.formatCartGoods(_.get(advCartData, 'goods_list'), true, false, false, analysisData),
563 - pools: formatPromotionPools(_.get(advCartData, 'goods_pool_list'), null, true), 563 + pools: formatPromotionPools(_.get(advCartData, 'goods_pool_list'), null, true, analysisData),
564 offShelves: formatOffShelves(_.get(advCartData, 'off_shelves_goods_list'), true, analysisData), 564 offShelves: formatOffShelves(_.get(advCartData, 'off_shelves_goods_list'), true, analysisData),
565 soldOuts: formatSoldOuts(_.get(advCartData, 'sold_out_goods_list'), true, analysisData), 565 soldOuts: formatSoldOuts(_.get(advCartData, 'sold_out_goods_list'), true, analysisData),
566 promotionInfos: formatPromotionInfos(_.get(advCartData, 'promotion_info')), 566 promotionInfos: formatPromotionInfos(_.get(advCartData, 'promotion_info')),
@@ -585,7 +585,7 @@ const formatCart = (cartDataRet, uid, shoppingKey, cartDelList) => { @@ -585,7 +585,7 @@ const formatCart = (cartDataRet, uid, shoppingKey, cartDelList) => {
585 // 已选择的全场加价购和赠品 585 // 已选择的全场加价购和赠品
586 goodsList: goodsList, 586 goodsList: goodsList,
587 587
588 - pools: formatPromotionPools(_.get(ordCartData, 'goods_pool_list'), goodsList), 588 + pools: formatPromotionPools(_.get(ordCartData, 'goods_pool_list'), goodsList, false, analysisData),
589 589
590 offShelves: formatOffShelves(_.get(ordCartData, 'off_shelves_goods_list'), false, analysisData), 590 offShelves: formatOffShelves(_.get(ordCartData, 'off_shelves_goods_list'), false, analysisData),
591 soldOuts: formatSoldOuts(_.get(ordCartData, 'sold_out_goods_list'), false, analysisData), 591 soldOuts: formatSoldOuts(_.get(ordCartData, 'sold_out_goods_list'), false, analysisData),
@@ -68,39 +68,4 @@ @@ -68,39 +68,4 @@
68 </div> 68 </div>
69 </div> 69 </div>
70 70
71 -<!-- 商品详细信息窗口 -->  
72 -<!--  
73 -<script type="text/javascript">  
74 - (function (d) {  
75 - window.bd_cpro_rtid = "P1fsPWc";  
76 - var s = d.createElement("script");  
77 - s.type = "text/javascript";  
78 - s.async = true;  
79 - s.src = location.protocol + "//cpro.baidu.com/cpro/ui/rt.js";  
80 - var s0 = d.getElementsByTagName("script")[0];  
81 - s0.parentNode.insertBefore(s, s0);  
82 - })(document);  
83 -</script>  
84 -<script type="text/javascript" src="//static.criteo.net/js/ld/ld.js" async="true"></script>  
85 -<script type="text/javascript">  
86 - window.criteo_q = window.criteo_q || [];  
87 - window.criteo_q.push(  
88 - {event: "setAccount", account: 16184},  
89 - {event: "setCustomerId", id: "{{uid}}"},  
90 - {event: "setSiteType", type: "d"},  
91 - {event: "viewBasket", item: {{{cart.criteo}}} }  
92 - );  
93 -</script>  
94 --->  
95 -<!-- 聚效 -->  
96 -<!--  
97 -<script type="text/javascript">  
98 - var _mvq = window._mvq || [];  
99 - window._mvq = _mvq;  
100 - _mvq.push(['$setAccount', 'm-23428-1']);  
101 - _mvq.push(['$setGeneral', 'cartview', '', /*用户名*/ '', '{{uid}}']);  
102 - _mvq.push(['$logConversion']);  
103 - _mvq.push(['$addItem', '', /*商品id*/ '{{cart.ids}}', '', '']);  
104 - _mvq.push(['$logData']);  
105 -</script>  
106 ---> 71 + {{> cart-analysis}}
  1 +<!-- 商品详细信息窗口 -->
  2 +<script type="text/javascript">
  3 + (function (d) {
  4 + window.bd_cpro_rtid = "P1fsPWc";
  5 + var s = d.createElement("script");
  6 + s.type = "text/javascript";
  7 + s.async = true;
  8 + s.src = location.protocol + "//cpro.baidu.com/cpro/ui/rt.js";
  9 + var s0 = d.getElementsByTagName("script")[0];
  10 + s0.parentNode.insertBefore(s, s0);
  11 + })(document);
  12 +</script>
  13 +<script type="text/javascript" src="//static.criteo.net/js/ld/ld.js" async="true"></script>
  14 +<script type="text/javascript">
  15 + window.criteo_q = window.criteo_q || [];
  16 + window.criteo_q.push(
  17 + {event: "setAccount", account: 16184},
  18 + {event: "setCustomerId", id: "{{uid}}"},
  19 + {event: "setSiteType", type: "d"},
  20 + {event: "viewBasket", item: [
  21 + {{# cart.criteo}}
  22 + {"id":"{{id}}","quantity":"{{quantity}}","price":"{{price}}"},
  23 + {{/ cart.criteo}}
  24 + ]}
  25 + );
  26 +</script>
  27 +<!-- 聚效 -->
  28 +<script type="text/javascript">
  29 + var _mvq = window._mvq || [];
  30 + window._mvq = _mvq;
  31 + _mvq.push(['$setAccount', 'm-23428-1']);
  32 + _mvq.push(['$setGeneral', 'cartview', '', /*用户名*/ '', '{{uid}}']);
  33 + _mvq.push(['$logConversion']);
  34 + _mvq.push(['$addItem', '', /*商品id*/ '{{cart.ids}}', '', '']);
  35 + _mvq.push(['$logData']);
  36 +</script>
@@ -8,7 +8,7 @@ @@ -8,7 +8,7 @@
8 </div> 8 </div>
9 {{^}} 9 {{^}}
10 <!-- 购物车商品列表 --> 10 <!-- 购物车商品列表 -->
11 - <div class="pay-wapper"> 11 + <div class="pay-wapper" data-role="order-cart">
12 <div class="cart-title"> 12 <div class="cart-title">
13 <p class="left" style="width:6%;"> 13 <p class="left" style="width:6%;">
14 <i class="cart-item-check-title cart-item-check iconfont"></i>&nbsp;&nbsp;全选 14 <i class="cart-item-check-title cart-item-check iconfont"></i>&nbsp;&nbsp;全选
@@ -23,7 +23,8 @@ @@ -23,7 +23,8 @@
23 {{#advanceCart}} 23 {{#advanceCart}}
24 <div class="mb20" data-role="advance"> 24 <div class="mb20" data-role="advance">
25 <!-- 预售商品 --> 25 <!-- 预售商品 -->
26 - <div class="pre-sell"> 26 + <div class="pre-sell pre-sell-title">
  27 + <i class="cart-item-check iconfont {{#isChecked}}cart-item-checked{{/isChecked}}" data-role="cart-item-check"></i>
27 <code>预售商品</code>预售商品不参加活动,不可使用优惠券,不同上市期的商品我们将为您先到先发。 28 <code>预售商品</code>预售商品不参加活动,不可使用优惠券,不同上市期的商品我们将为您先到先发。
28 </div> 29 </div>
29 30
@@ -73,8 +74,9 @@ @@ -73,8 +74,9 @@
73 74
74 {{#ordinaryCart}} 75 {{#ordinaryCart}}
75 <div data-role="ordinary"> 76 <div data-role="ordinary">
76 - <!-- 预售商品 -->  
77 - <div class="pre-sell ordinary-sell"> 77 + <!-- 普通商品 -->
  78 + <div class="pre-sell ord-sell-title">
  79 + <i class="cart-item-check iconfont {{#isChecked}}cart-item-checked{{/isChecked}}" data-role="cart-item-check"></i>
78 <code>普通商品</code> {{tips}} 80 <code>普通商品</code> {{tips}}
79 </div> 81 </div>
80 82
1 { 1 {
2 "name": "yohobuy-node", 2 "name": "yohobuy-node",
3 - "version": "5.4.19", 3 + "version": "5.4.20",
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": {
@@ -55,42 +55,16 @@ function submitPoint(type) { @@ -55,42 +55,16 @@ function submitPoint(type) {
55 yas.givePoint('YB_SC_TOBUY_CLICK', {PRD_ID: productId.join(',')}); 55 yas.givePoint('YB_SC_TOBUY_CLICK', {PRD_ID: productId.join(',')});
56 } 56 }
57 57
58 -Cart = {  
59 -  
60 - toggleSelectOne: function() { // 单选  
61 -  
62 - var $this = $(this);  
63 - var $pitem = $this.closest('li[data-role="pitem"]');  
64 - var item;  
65 -  
66 - if (!$this.hasClass('cart-item-checked') && $this.data('tipnostore')) { // 无库存提示  
67 - toastNoStore($pitem);  
68 - return;  
69 - }  
70 -  
71 - // $this.toggleClass('cart-item-checked');  
72 -  
73 - item = {  
74 - product_sku: $pitem.data('id'),  
75 - selected: $this.hasClass('cart-item-checked') ? 'N' : 'Y', // 'Y' : 'N',  
76 - buy_number: $pitem.data('productnum'),  
77 - goods_type: $pitem.data('goodstype'),  
78 - promotion_id: $pitem.data('promotionid') ? $pitem.data('promotionid') : 0  
79 - };  
80 -  
81 - return capi.choiceOut(item);  
82 - },  
83 - toggleSelectAll: function() { // 全选  
84 -  
85 - var $this = $(this); 58 +function toggleAll(obj, roleType) {
  59 + var $this = obj;
86 var selected; 60 var selected;
87 var selectArray = []; 61 var selectArray = [];
88 - var $noStores = $cartListWrap.find('[data-role=cart-item-check][data-tipnostore]'); 62 + var $noStores = $cartListWrap.find('[data-role=' + roleType + '] [data-role=cart-item-check][data-tipnostore]');
89 63
90 $this.toggleClass('cart-item-checked'); 64 $this.toggleClass('cart-item-checked');
91 selected = $this.hasClass('cart-item-checked') ? 'Y' : 'N'; 65 selected = $this.hasClass('cart-item-checked') ? 'Y' : 'N';
92 66
93 - $cartListWrap.find('li[data-role=pitem]').each(function() { 67 + $cartListWrap.find('[data-role=' + roleType + '] li[data-role=pitem]').each(function() {
94 var $t = $(this); 68 var $t = $(this);
95 69
96 if ($t.data('id')) { 70 if ($t.data('id')) {
@@ -118,6 +92,41 @@ Cart = { @@ -118,6 +92,41 @@ Cart = {
118 } else { 92 } else {
119 capi.choiceOut(selectArray); 93 capi.choiceOut(selectArray);
120 } 94 }
  95 +}
  96 +Cart = {
  97 +
  98 + toggleSelectOne: function() { // 单选
  99 +
  100 + var $this = $(this);
  101 + var $pitem = $this.closest('li[data-role="pitem"]');
  102 + var item;
  103 +
  104 + if (!$this.hasClass('cart-item-checked') && $this.data('tipnostore')) { // 无库存提示
  105 + toastNoStore($pitem);
  106 + return;
  107 + }
  108 +
  109 + // $this.toggleClass('cart-item-checked');
  110 +
  111 + item = {
  112 + product_sku: $pitem.data('id'),
  113 + selected: $this.hasClass('cart-item-checked') ? 'N' : 'Y', // 'Y' : 'N',
  114 + buy_number: $pitem.data('productnum'),
  115 + goods_type: $pitem.data('goodstype'),
  116 + promotion_id: $pitem.data('promotionid') ? $pitem.data('promotionid') : 0
  117 + };
  118 +
  119 + return capi.choiceOut(item);
  120 + },
  121 +
  122 + toggleSelectAll: function() { // 全部
  123 + toggleAll($(this), 'order-cart');
  124 + },
  125 + togglePreAll: function() { // 预售全选
  126 + toggleAll($(this), 'advance');
  127 + },
  128 + toggleOrdAll: function() { // 普通全选
  129 + toggleAll($(this), 'ordinary');
121 }, 130 },
122 del: function() { 131 del: function() {
123 132
@@ -395,6 +404,8 @@ $cartListWrap.on('click', '[data-role=cart-mov2fav-btn]', Cart.toFav); // 移 @@ -395,6 +404,8 @@ $cartListWrap.on('click', '[data-role=cart-mov2fav-btn]', Cart.toFav); // 移
395 $cartListWrap.on('click', '.minus, .plus', Cart.modNum); // 修改购物车数量 404 $cartListWrap.on('click', '.minus, .plus', Cart.modNum); // 修改购物车数量
396 $cartListWrap.on('click', '.cart-title .cart-item-check', Cart.toggleSelectAll); // 全选 405 $cartListWrap.on('click', '.cart-title .cart-item-check', Cart.toggleSelectAll); // 全选
397 $cartListWrap.on('click', '.cartnew-sum .cart-item-check', Cart.toggleSelectAll); // 全选 406 $cartListWrap.on('click', '.cartnew-sum .cart-item-check', Cart.toggleSelectAll); // 全选
  407 +$cartListWrap.on('click', '.pre-sell-title .cart-item-check', Cart.togglePreAll); // 预售全选
  408 +$cartListWrap.on('click', '.ord-sell-title .cart-item-check', Cart.toggleOrdAll); // 预售全选
398 $cartListWrap.on('click', '.cartnew-sum .delete-all-sel', Cart.delAll); // 批量删除商品 409 $cartListWrap.on('click', '.cartnew-sum .delete-all-sel', Cart.delAll); // 批量删除商品
399 $cartListWrap.on('click', '.cartnew-sum .remove-all-2fav', Cart.toFavAll); // 批量移入收藏夹商品 410 $cartListWrap.on('click', '.cartnew-sum .remove-all-2fav', Cart.toFavAll); // 批量移入收藏夹商品
400 $cartListWrap.on('click', '.cartnew-sum .clean-all-disable', Cart.cleanAllDisable); 411 $cartListWrap.on('click', '.cartnew-sum .clean-all-disable', Cart.cleanAllDisable);
@@ -35,6 +35,47 @@ function isCheckAll() { @@ -35,6 +35,47 @@ function isCheckAll() {
35 } 35 }
36 } 36 }
37 37
  38 +// 预售商品是否全选
  39 +function isPreCheckAll() {
  40 + var isAllCheck = true;
  41 +
  42 + $('[data-role=advance] [data-role=pitem] [data-role=cart-item-check]').each(function() {
  43 +
  44 + var $chk = $(this);
  45 +
  46 + // 有一个没选中,跳出循环
  47 + if (!$(this).hasClass('cart-item-checked') && !$chk.data('tipnostore')) {
  48 + isAllCheck = false;
  49 + return false;
  50 + }
  51 + });
  52 +
  53 + if (isAllCheck) {
  54 + // 头部全选
  55 + $('.pre-sell-title .cart-item-check').addClass('cart-item-checked');
  56 + }
  57 +}
  58 +
  59 +// 普通商品是否全选
  60 +function isOrdCheckAll() {
  61 + var isAllCheck = true;
  62 +
  63 + $('[data-role=ordinary] [data-role=pitem] [data-role=cart-item-check]').each(function() {
  64 +
  65 + var $chk = $(this);
  66 +
  67 + // 有一个没选中,跳出循环
  68 + if (!$(this).hasClass('cart-item-checked') && !$chk.data('tipnostore')) {
  69 + isAllCheck = false;
  70 + return false;
  71 + }
  72 + });
  73 +
  74 + if (isAllCheck) {
  75 + $('.ord-sell-title .cart-item-check').addClass('cart-item-checked');
  76 + }
  77 +}
  78 +
38 // 判断商品是否已收藏,是否全选 79 // 判断商品是否已收藏,是否全选
39 function isCheckFav() { 80 function isCheckFav() {
40 var pidArray = []; 81 var pidArray = [];
@@ -86,6 +127,8 @@ function cartInit() { @@ -86,6 +127,8 @@ function cartInit() {
86 }); 127 });
87 128
88 isCheckAll(); 129 isCheckAll();
  130 + isPreCheckAll();
  131 + isOrdCheckAll();
89 isCheckFav(); 132 isCheckFav();
90 } 133 }
91 134
@@ -264,8 +264,10 @@ @@ -264,8 +264,10 @@
264 font-weight: 300; 264 font-weight: 300;
265 height: 30px; 265 height: 30px;
266 line-height: 30px; 266 line-height: 30px;
267 - padding-left: 30px; 267 + padding-left: 55px;
268 padding-top :20px; 268 padding-top :20px;
  269 + position: relative;
  270 + margin-bottom: 1px;
269 span { 271 span {
270 margin-right: 10px; 272 margin-right: 10px;
271 } 273 }
@@ -274,7 +276,7 @@ @@ -274,7 +276,7 @@
274 margin-right: 30px; 276 margin-right: 30px;
275 } 277 }
276 } 278 }
277 - .ordinary-sell { 279 + .ord-sell {
278 padding-top: 0px; 280 padding-top: 0px;
279 } 281 }
280 282