Authored by yyq

Merge branch 'feature/shoppingCart' of git.yoho.cn:fe/yohobuy-node into feature/shoppingCart

@@ -68,11 +68,6 @@ @@ -68,11 +68,6 @@
68 </div> 68 </div>
69 </div> 69 </div>
70 70
71 -  
72 -<script type="text/javascript">  
73 - /*<textarea data-role="gifts-cansel" class="hide" data-promotionid="{{promotionId}}">{{{giftGoodsListStr}}}</textarea>*/  
74 -</script>  
75 -  
76 <!-- 商品详细信息窗口 --> 71 <!-- 商品详细信息窗口 -->
77 <!-- 72 <!--
78 <script type="text/javascript"> 73 <script type="text/javascript">
@@ -38,7 +38,7 @@ @@ -38,7 +38,7 @@
38 </div> 38 </div>
39 39
40 {{#advanceCart}} 40 {{#advanceCart}}
41 - <div class="mb40"> 41 + <div class="mb40" data-role="advance">
42 <!-- 预售商品 --> 42 <!-- 预售商品 -->
43 <div class="pre-sell"> 43 <div class="pre-sell">
44 <code>预售商品</code>预售商品不参加活动,不可使用优惠券,不同上市期的商品我们将为您先到先发。 44 <code>预售商品</code>预售商品不参加活动,不可使用优惠券,不同上市期的商品我们将为您先到先发。
@@ -76,7 +76,7 @@ @@ -76,7 +76,7 @@
76 </div> 76 </div>
77 {{/if}} 77 {{/if}}
78 78
79 - <!--{{#if promotionInfos}}--> 79 + {{!--{{#if promotionInfos}}
80 <!--<div class="gift-sell">--> 80 <!--<div class="gift-sell">-->
81 <!--{{#promotionInfos}}--> 81 <!--{{#promotionInfos}}-->
82 <!--<p class="gift-sell-info"><code class="order-pay-mark">{{tag}}</code>{{promotionTitle}}--> 82 <!--<p class="gift-sell-info"><code class="order-pay-mark">{{tag}}</code>{{promotionTitle}}-->
@@ -84,11 +84,12 @@ @@ -84,11 +84,12 @@
84 <!--</p>--> 84 <!--</p>-->
85 <!--{{/promotionInfos}}--> 85 <!--{{/promotionInfos}}-->
86 <!--</div>--> 86 <!--</div>-->
87 - <!--{{/if}}--> 87 + {{/if}}--}}
88 </div> 88 </div>
89 {{/advanceCart}} 89 {{/advanceCart}}
90 90
91 {{#ordinaryCart}} 91 {{#ordinaryCart}}
  92 + <div data-role="ordinary">
92 {{#pools}} 93 {{#pools}}
93 <div class="promotion-pool {{#unless @first}}mt20{{/unless}}" data-role="promotion-pool"> 94 <div class="promotion-pool {{#unless @first}}mt20{{/unless}}" data-role="promotion-pool">
94 {{#if promotionInfos}} 95 {{#if promotionInfos}}
@@ -181,6 +182,7 @@ @@ -181,6 +182,7 @@
181 </ul> 182 </ul>
182 </div> 183 </div>
183 {{/if}} 184 {{/if}}
  185 + </div>
184 {{/ordinaryCart}} 186 {{/ordinaryCart}}
185 187
186 {{#stat}} 188 {{#stat}}
@@ -35,7 +35,7 @@ @@ -35,7 +35,7 @@
35 </div> 35 </div>
36 </div> 36 </div>
37 </div> 37 </div>
38 - <a class="btn-account" href="{{ensureUrl}}">去结算</a> 38 + <a class="btn-account" data-url="{{ensureUrl}}" data-type="A">去结算</a>
39 {{/advanceCart}} 39 {{/advanceCart}}
40 {{#ordinaryCart}} 40 {{#ordinaryCart}}
41 <div class="slide-img"> 41 <div class="slide-img">
@@ -81,7 +81,7 @@ @@ -81,7 +81,7 @@
81 </div> 81 </div>
82 </div> 82 </div>
83 </div> 83 </div>
84 - <a class="btn-account" href="{{ensureUrl}}">去结算</a> 84 + <a class="btn-account" data-url="{{ensureUrl}}" data-type="O">去结算</a>
85 {{/ordinaryCart}} 85 {{/ordinaryCart}}
86 <p class="pre-sell-tip">温馨提示:您需要分开结算【预售商品】和【普通商品】</p> 86 <p class="pre-sell-tip">温馨提示:您需要分开结算【预售商品】和【普通商品】</p>
87 </div> 87 </div>
@@ -7,6 +7,7 @@ var $ = require('yoho-jquery'), @@ -7,6 +7,7 @@ var $ = require('yoho-jquery'),
7 RConfirm = rDialog.RConfirm, 7 RConfirm = rDialog.RConfirm,
8 RAlert = rDialog.RAlert, 8 RAlert = rDialog.RAlert,
9 capi = require('./cart-api'), 9 capi = require('./cart-api'),
  10 + yas = require('../common/data-yas'),
10 Cart; 11 Cart;
11 12
12 var $cartnewTips = $('.cartnew-tips'), 13 var $cartnewTips = $('.cartnew-tips'),
@@ -29,6 +30,32 @@ function toastNoStore(parent, info) { @@ -29,6 +30,32 @@ function toastNoStore(parent, info) {
29 }, 2000); 30 }, 2000);
30 } 31 }
31 32
  33 +function submitPoint(type) {
  34 +
  35 + // 添加埋点
  36 + var productId = [];
  37 + var $wrap = $('#Y_CartListWrap');
  38 +
  39 + if (type === 'A') {
  40 + $wrap = $wrap.find('[data-role=advance]');
  41 + } else if (type === 'O') {
  42 + $wrap = $wrap.find('[data-role=ordinary]');
  43 + }
  44 +
  45 + $wrap.find('.cart-item-check.cart-item-checked').each(function() {
  46 + var $this = $(this);
  47 + var $t = $this.closest('li[data-role=pitem]');
  48 + var pid = $t.data('pid');
  49 +
  50 + if (pid) {
  51 + productId.push(pid);
  52 + }
  53 + });
  54 +
  55 + // 结算点击埋点
  56 + yas.givePoint('YB_SC_TOBUY_CLICK', {PRD_ID: productId.join(',')});
  57 +}
  58 +
32 Cart = { 59 Cart = {
33 60
34 toggleSelectOne: function() { // 单选 61 toggleSelectOne: function() { // 单选
@@ -310,6 +337,9 @@ Cart = { @@ -310,6 +337,9 @@ Cart = {
310 if ($t.data('mix')) { 337 if ($t.data('mix')) {
311 return capi.showMDialog('#Y_CartSelectDialog'); 338 return capi.showMDialog('#Y_CartSelectDialog');
312 } 339 }
  340 +
  341 + submitPoint();
  342 +
313 window.location = $t.data('ensureurl') || '//www.yohobuy.com/cart/ensure'; 343 window.location = $t.data('ensureurl') || '//www.yohobuy.com/cart/ensure';
314 }, 344 },
315 submit: function() { 345 submit: function() {
@@ -334,50 +364,14 @@ Cart = { @@ -334,50 +364,14 @@ Cart = {
334 }, '去选择', '不要赠品'); 364 }, '去选择', '不要赠品');
335 } else { 365 } else {
336 Cart._submit($this); 366 Cart._submit($this);
337 -  
338 - // window.location = '//www.yohobuy.com';  
339 } 367 }
  368 + },
  369 + submitSingle: function() {
  370 + var $t = $(this);
  371 + var type = $t.data('type');
340 372
341 - // $('.cart-preSell-dialog').show();  
342 -  
343 - // $('.cart-togetherGoods').show();  
344 -  
345 - /* understock = '';  
346 - if ($('.pay-wapper input:checked').parents('tr').find('.tipNoStore').length > 0) {  
347 - shopName = $('.pay-wapper input:checked').parents('tr').find('.tipNoStore');  
348 - $.each(shopName.parents('tr').find('.pay-pro-info a'), function() {  
349 - understock += $(this).html();  
350 - });  
351 - new Alert(understock + '库存不足').show();  
352 - } else {  
353 - if ($('.zp').length > 0 && !$(this).attr('title')) {  
354 - $(this).attr('title', '1');  
355 - new Alert('您有赠品没有选择,请选择完再结算!').show();  
356 - } else {  
357 - if ($('input:checked').length > 0) {  
358 -  
359 - // 添加埋点  
360 - var productId = [];  
361 - $('.pay-wapper input:checked').parents('tr').each(function() {  
362 - if ($(this).attr('data-pid')) {  
363 - productId.push($(this).attr('data-pid'));  
364 - }  
365 - });  
366 -  
367 - // 结算点击埋点  
368 - window.addPoint('YB_SC_TOBUY_CLICK', {PRD_ID: productId.join(',')});  
369 -  
370 -  
371 - if ($('.pre-sell-box input:checked').length > 0) {  
372 - window.location.href = '/cart/index/orderEnsure?type=2';  
373 - } else {  
374 - window.location.href = '/cart/index/orderEnsure?type=1';  
375 - }  
376 - } else {  
377 - new Alert('请至少选择一件商品').show();  
378 - }  
379 - }  
380 - }*/ 373 + submitPoint(type);
  374 + window.location = $t.data('url');
381 } 375 }
382 }; 376 };
383 377
@@ -391,6 +385,7 @@ $cartListWrap.on('click', '.cartnew-sum .delete-all-sel', Cart.delAll); // @@ -391,6 +385,7 @@ $cartListWrap.on('click', '.cartnew-sum .delete-all-sel', Cart.delAll); //
391 $cartListWrap.on('click', '.cartnew-sum .remove-all-2fav', Cart.toFavAll); // 批量移入收藏夹商品 385 $cartListWrap.on('click', '.cartnew-sum .remove-all-2fav', Cart.toFavAll); // 批量移入收藏夹商品
392 $cartListWrap.on('click', '.cartnew-sum .clean-all-disable', Cart.cleanAllDisable); 386 $cartListWrap.on('click', '.cartnew-sum .clean-all-disable', Cart.cleanAllDisable);
393 $cartListWrap.on('click', '#Y_SubmitBtn', Cart.submit); // 结算 387 $cartListWrap.on('click', '#Y_SubmitBtn', Cart.submit); // 结算
  388 +$cartListWrap.on('click', '#Y_CartSelectDialog .btn-account', Cart.submitSingle);
394 389
395 // 重新加入购物车 390 // 重新加入购物车
396 $cartListWrap.on('click', '#Y_delReselWrap [data-role=readd2cart]', Cart.reAdd2Cart); 391 $cartListWrap.on('click', '#Y_delReselWrap [data-role=readd2cart]', Cart.reAdd2Cart);
  1 +/**
  2 + * Created by yoho on 2017-01-13.
  3 + */
  4 +
  5 +var $ = require('yoho-jquery');
  6 +
  7 +function pyStat() {
  8 +
  9 + var money = $('.cartnew-sum .num strong').text();
  10 + var items = [];
  11 +
  12 + $('#Y_CartListWrap li[data-role=pitem]').each(function() {
  13 + var $t = $(this);
  14 +
  15 + if ($t.data('id')) {
  16 + items.push({
  17 + id: $t.data('skn'),
  18 + count: $t.data('productnum'),
  19 + price: $t.find('.product-price').text()
  20 + });
  21 + }
  22 + });
  23 +
  24 + window.py('event', 'viewCart', {
  25 + money: money,
  26 + items: items
  27 + }).track('MC.Ok.7NFMIlCH_F_LE2riRlF2r_');
  28 +}
  29 +
  30 +$(function() {
  31 + setTimeout(pyStat, 0);
  32 +});
@@ -18,3 +18,6 @@ require('./cart-goods-win'); @@ -18,3 +18,6 @@ require('./cart-goods-win');
18 require('./cart-together'); 18 require('./cart-together');
19 19
20 $(capi.cartInit); 20 $(capi.cartInit);
  21 +
  22 +// 第三方统计
  23 +require('./cart-stat');