Showing
3 changed files
with
32 additions
and
7 deletions
@@ -8,17 +8,22 @@ var $ = require('jquery'), | @@ -8,17 +8,22 @@ var $ = require('jquery'), | ||
8 | tip = require('../../plugin/tip'); | 8 | tip = require('../../plugin/tip'); |
9 | 9 | ||
10 | var likeHammer = new Hammer(document.getElementById('likeBtn')); | 10 | var likeHammer = new Hammer(document.getElementById('likeBtn')); |
11 | + addToCartHammer = new Hammer(document.getElementById('addtoCart')); | ||
11 | 12 | ||
12 | likeHammer.on('tap', function(e) { | 13 | likeHammer.on('tap', function(e) { |
13 | var productId = $('#productId').val(), | 14 | var productId = $('#productId').val(), |
14 | - opt; | 15 | + opt, |
16 | + favorite; | ||
17 | + | ||
15 | 18 | ||
16 | var $this = $(this); | 19 | var $this = $(this); |
17 | 20 | ||
18 | if ($this.hasClass('liked')) { | 21 | if ($this.hasClass('liked')) { |
19 | opt = 'cancel'; | 22 | opt = 'cancel'; |
23 | + favorite = 0; | ||
20 | } else { | 24 | } else { |
21 | opt = 'ok'; | 25 | opt = 'ok'; |
26 | + favorite = 1; | ||
22 | } | 27 | } |
23 | 28 | ||
24 | $.ajax({ | 29 | $.ajax({ |
@@ -36,6 +41,14 @@ likeHammer.on('tap', function(e) { | @@ -36,6 +41,14 @@ likeHammer.on('tap', function(e) { | ||
36 | } else { | 41 | } else { |
37 | tip.show(data.message); | 42 | tip.show(data.message); |
38 | } | 43 | } |
44 | + | ||
45 | + // 统计代码:用于统计用户加入或取消商品收藏的动作 | ||
46 | + if (window._yas) { | ||
47 | + window._yas.sendCustomInfo({ | ||
48 | + pd: productId, | ||
49 | + fa: favorite | ||
50 | + }); | ||
51 | + } | ||
39 | }, | 52 | }, |
40 | error: function() { | 53 | error: function() { |
41 | tip.show('网络断开连接了~'); | 54 | tip.show('网络断开连接了~'); |
@@ -44,6 +57,15 @@ likeHammer.on('tap', function(e) { | @@ -44,6 +57,15 @@ likeHammer.on('tap', function(e) { | ||
44 | 57 | ||
45 | }); | 58 | }); |
46 | 59 | ||
47 | -// $('#likeBtn').on('click', function(e) { | ||
48 | -// return false; | ||
49 | -// }); | ||
60 | +addToCartHammer.on('tap', function(e) { | ||
61 | + | ||
62 | + // 统计代码:用于统计用户加入购物车的动作 | ||
63 | + if (window._yas) { | ||
64 | + window._yas.sendCustomInfo({ | ||
65 | + pd: productId, | ||
66 | + by: 1 | ||
67 | + }); | ||
68 | + } | ||
69 | +}); | ||
70 | + | ||
71 | + |
@@ -442,3 +442,8 @@ $listNav.on('touchstart', 'li', function() { | @@ -442,3 +442,8 @@ $listNav.on('touchstart', 'li', function() { | ||
442 | }).on('touchend touchcancel', 'li', function() { | 442 | }).on('touchend touchcancel', 'li', function() { |
443 | $listNav.find('li').removeClass('bytouch'); | 443 | $listNav.find('li').removeClass('bytouch'); |
444 | }); | 444 | }); |
445 | + | ||
446 | +// 用于统计点击了商品列表的第几个商品,序号从1开始计算。 | ||
447 | +if (window._yas) { | ||
448 | + window._yas(1 * new Date(), '1.0.13.1', 'yohobuy_m', uid, '#goods-container >div >div .good-thumb >img'); | ||
449 | +} |
@@ -116,7 +116,7 @@ | @@ -116,7 +116,7 @@ | ||
116 | {{/if}} | 116 | {{/if}} |
117 | <a href="/shoppingCart" class="num-incart iconfont"></a> | 117 | <a href="/shoppingCart" class="num-incart iconfont"></a> |
118 | {{#if goodsInstore}} | 118 | {{#if goodsInstore}} |
119 | - <a href="/shoppingCart" class="addto-cart ">加入购物车</a> | 119 | + <a href="/shoppingCart" id="addtoCart" class="addto-cart">加入购物车</a> |
120 | {{else}} | 120 | {{else}} |
121 | <a href="javascript:;" class="sold-out">已售罄</a> | 121 | <a href="javascript:;" class="sold-out">已售罄</a> |
122 | {{/if}} | 122 | {{/if}} |
@@ -124,11 +124,9 @@ | @@ -124,11 +124,9 @@ | ||
124 | <a href="javascript:;" id="likeBtn" class="favorite iconfont {{#isCollect}}liked{{/isCollect}}"></a> | 124 | <a href="javascript:;" id="likeBtn" class="favorite iconfont {{#isCollect}}liked{{/isCollect}}"></a> |
125 | </div> | 125 | </div> |
126 | {{/cartInfo}} | 126 | {{/cartInfo}} |
127 | - | ||
128 | {{#if introUrl}} | 127 | {{#if introUrl}} |
129 | <input id="introUrl" type="hidden" value={{introUrl}}> | 128 | <input id="introUrl" type="hidden" value={{introUrl}}> |
130 | {{/if}} | 129 | {{/if}} |
131 | - | ||
132 | {{#if id}} | 130 | {{#if id}} |
133 | <input id="productId" type="hidden" value={{id}}> | 131 | <input id="productId" type="hidden" value={{id}}> |
134 | {{/if}} | 132 | {{/if}} |
-
Please register or login to post a comment