Authored by yyq

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

... ... @@ -68,11 +68,6 @@
</div>
</div>
<script type="text/javascript">
/*<textarea data-role="gifts-cansel" class="hide" data-promotionid="{{promotionId}}">{{{giftGoodsListStr}}}</textarea>*/
</script>
<!-- 商品详细信息窗口 -->
<!--
<script type="text/javascript">
... ...
... ... @@ -38,7 +38,7 @@
</div>
{{#advanceCart}}
<div class="mb40">
<div class="mb40" data-role="advance">
<!-- 预售商品 -->
<div class="pre-sell">
<code>预售商品</code>预售商品不参加活动,不可使用优惠券,不同上市期的商品我们将为您先到先发。
... ... @@ -76,7 +76,7 @@
</div>
{{/if}}
<!--{{#if promotionInfos}}-->
{{!--{{#if promotionInfos}}
<!--<div class="gift-sell">-->
<!--{{#promotionInfos}}-->
<!--<p class="gift-sell-info"><code class="order-pay-mark">{{tag}}</code>{{promotionTitle}}-->
... ... @@ -84,11 +84,12 @@
<!--</p>-->
<!--{{/promotionInfos}}-->
<!--</div>-->
<!--{{/if}}-->
{{/if}}--}}
</div>
{{/advanceCart}}
{{#ordinaryCart}}
<div data-role="ordinary">
{{#pools}}
<div class="promotion-pool {{#unless @first}}mt20{{/unless}}" data-role="promotion-pool">
{{#if promotionInfos}}
... ... @@ -181,6 +182,7 @@
</ul>
</div>
{{/if}}
</div>
{{/ordinaryCart}}
{{#stat}}
... ...
... ... @@ -35,7 +35,7 @@
</div>
</div>
</div>
<a class="btn-account" href="{{ensureUrl}}">去结算</a>
<a class="btn-account" data-url="{{ensureUrl}}" data-type="A">去结算</a>
{{/advanceCart}}
{{#ordinaryCart}}
<div class="slide-img">
... ... @@ -81,7 +81,7 @@
</div>
</div>
</div>
<a class="btn-account" href="{{ensureUrl}}">去结算</a>
<a class="btn-account" data-url="{{ensureUrl}}" data-type="O">去结算</a>
{{/ordinaryCart}}
<p class="pre-sell-tip">温馨提示:您需要分开结算【预售商品】和【普通商品】</p>
</div>
... ...
... ... @@ -7,6 +7,7 @@ var $ = require('yoho-jquery'),
RConfirm = rDialog.RConfirm,
RAlert = rDialog.RAlert,
capi = require('./cart-api'),
yas = require('../common/data-yas'),
Cart;
var $cartnewTips = $('.cartnew-tips'),
... ... @@ -29,6 +30,32 @@ function toastNoStore(parent, info) {
}, 2000);
}
function submitPoint(type) {
// 添加埋点
var productId = [];
var $wrap = $('#Y_CartListWrap');
if (type === 'A') {
$wrap = $wrap.find('[data-role=advance]');
} else if (type === 'O') {
$wrap = $wrap.find('[data-role=ordinary]');
}
$wrap.find('.cart-item-check.cart-item-checked').each(function() {
var $this = $(this);
var $t = $this.closest('li[data-role=pitem]');
var pid = $t.data('pid');
if (pid) {
productId.push(pid);
}
});
// 结算点击埋点
yas.givePoint('YB_SC_TOBUY_CLICK', {PRD_ID: productId.join(',')});
}
Cart = {
toggleSelectOne: function() { // 单选
... ... @@ -310,6 +337,9 @@ Cart = {
if ($t.data('mix')) {
return capi.showMDialog('#Y_CartSelectDialog');
}
submitPoint();
window.location = $t.data('ensureurl') || '//www.yohobuy.com/cart/ensure';
},
submit: function() {
... ... @@ -334,50 +364,14 @@ Cart = {
}, '去选择', '不要赠品');
} else {
Cart._submit($this);
// window.location = '//www.yohobuy.com';
}
},
submitSingle: function() {
var $t = $(this);
var type = $t.data('type');
// $('.cart-preSell-dialog').show();
// $('.cart-togetherGoods').show();
/* understock = '';
if ($('.pay-wapper input:checked').parents('tr').find('.tipNoStore').length > 0) {
shopName = $('.pay-wapper input:checked').parents('tr').find('.tipNoStore');
$.each(shopName.parents('tr').find('.pay-pro-info a'), function() {
understock += $(this).html();
});
new Alert(understock + '库存不足').show();
} else {
if ($('.zp').length > 0 && !$(this).attr('title')) {
$(this).attr('title', '1');
new Alert('您有赠品没有选择,请选择完再结算!').show();
} else {
if ($('input:checked').length > 0) {
// 添加埋点
var productId = [];
$('.pay-wapper input:checked').parents('tr').each(function() {
if ($(this).attr('data-pid')) {
productId.push($(this).attr('data-pid'));
}
});
// 结算点击埋点
window.addPoint('YB_SC_TOBUY_CLICK', {PRD_ID: productId.join(',')});
if ($('.pre-sell-box input:checked').length > 0) {
window.location.href = '/cart/index/orderEnsure?type=2';
} else {
window.location.href = '/cart/index/orderEnsure?type=1';
}
} else {
new Alert('请至少选择一件商品').show();
}
}
}*/
submitPoint(type);
window.location = $t.data('url');
}
};
... ... @@ -391,6 +385,7 @@ $cartListWrap.on('click', '.cartnew-sum .delete-all-sel', Cart.delAll); //
$cartListWrap.on('click', '.cartnew-sum .remove-all-2fav', Cart.toFavAll); // 批量移入收藏夹商品
$cartListWrap.on('click', '.cartnew-sum .clean-all-disable', Cart.cleanAllDisable);
$cartListWrap.on('click', '#Y_SubmitBtn', Cart.submit); // 结算
$cartListWrap.on('click', '#Y_CartSelectDialog .btn-account', Cart.submitSingle);
// 重新加入购物车
$cartListWrap.on('click', '#Y_delReselWrap [data-role=readd2cart]', Cart.reAdd2Cart);
... ...
/**
* Created by yoho on 2017-01-13.
*/
var $ = require('yoho-jquery');
function pyStat() {
var money = $('.cartnew-sum .num strong').text();
var items = [];
$('#Y_CartListWrap li[data-role=pitem]').each(function() {
var $t = $(this);
if ($t.data('id')) {
items.push({
id: $t.data('skn'),
count: $t.data('productnum'),
price: $t.find('.product-price').text()
});
}
});
window.py('event', 'viewCart', {
money: money,
items: items
}).track('MC.Ok.7NFMIlCH_F_LE2riRlF2r_');
}
$(function() {
setTimeout(pyStat, 0);
});
... ...
... ... @@ -18,3 +18,6 @@ require('./cart-goods-win');
require('./cart-together');
$(capi.cartInit);
// 第三方统计
require('./cart-stat');
... ...