Authored by 梁志锋

增加加入购物车和点击收藏的统计代码

... ... @@ -8,17 +8,22 @@ var $ = require('jquery'),
tip = require('../../plugin/tip');
var likeHammer = new Hammer(document.getElementById('likeBtn'));
addToCartHammer = new Hammer(document.getElementById('addtoCart'));
likeHammer.on('tap', function(e) {
var productId = $('#productId').val(),
opt;
opt,
favorite;
var $this = $(this);
if ($this.hasClass('liked')) {
opt = 'cancel';
favorite = 0;
} else {
opt = 'ok';
favorite = 1;
}
$.ajax({
... ... @@ -36,6 +41,14 @@ likeHammer.on('tap', function(e) {
} else {
tip.show(data.message);
}
// 统计代码:用于统计用户加入或取消商品收藏的动作
if (window._yas) {
window._yas.sendCustomInfo({
pd: productId,
fa: favorite
});
}
},
error: function() {
tip.show('网络断开连接了~');
... ... @@ -44,6 +57,15 @@ likeHammer.on('tap', function(e) {
});
// $('#likeBtn').on('click', function(e) {
// return false;
// });
\ No newline at end of file
addToCartHammer.on('tap', function(e) {
// 统计代码:用于统计用户加入购物车的动作
if (window._yas) {
window._yas.sendCustomInfo({
pd: productId,
by: 1
});
}
});
... ...
... ... @@ -442,3 +442,8 @@ $listNav.on('touchstart', 'li', function() {
}).on('touchend touchcancel', 'li', function() {
$listNav.find('li').removeClass('bytouch');
});
// 用于统计点击了商品列表的第几个商品,序号从1开始计算。
if (window._yas) {
window._yas(1 * new Date(), '1.0.13.1', 'yohobuy_m', uid, '#goods-container >div >div .good-thumb >img');
}
\ No newline at end of file
... ...
... ... @@ -116,7 +116,7 @@
{{/if}}
<a href="/shoppingCart" class="num-incart iconfont">&#xe62c;</a>
{{#if goodsInstore}}
<a href="/shoppingCart" class="addto-cart ">加入购物车</a>
<a href="/shoppingCart" id="addtoCart" class="addto-cart">加入购物车</a>
{{else}}
<a href="javascript:;" class="sold-out">已售罄</a>
{{/if}}
... ... @@ -124,11 +124,9 @@
<a href="javascript:;" id="likeBtn" class="favorite iconfont {{#isCollect}}liked{{/isCollect}}">&#xe605;</a>
</div>
{{/cartInfo}}
{{#if introUrl}}
<input id="introUrl" type="hidden" value={{introUrl}}>
{{/if}}
{{#if id}}
<input id="productId" type="hidden" value={{id}}>
{{/if}}
... ...