Authored by Lynnic

修改了收藏商品的bug

@@ -27,14 +27,11 @@ goodsSwiper = new Swiper('.banner-swiper', { @@ -27,14 +27,11 @@ goodsSwiper = new Swiper('.banner-swiper', {
27 }); 27 });
28 28
29 29
30 -(function() {  
31 -  
32 - //初始化goods-discount  
33 - if (0 === $('.goods-discount .discount-folder').children().length) {  
34 - $('.goods-discount .discount-folder').css('display', 'none');  
35 - $('.goods-discount .first-item span').html('');  
36 - }  
37 -})(); 30 +//初始化goods-discount
  31 +if (0 === $('.goods-discount .discount-folder').children().length) {
  32 + $('.goods-discount .discount-folder').css('display', 'none');
  33 + $('.goods-discount .first-item span').html('');
  34 +}
38 35
39 //goods-discount下拉按钮点击事件 36 //goods-discount下拉按钮点击事件
40 $('.goodsDiscount .dropdown').on('click', function() { 37 $('.goodsDiscount .dropdown').on('click', function() {
@@ -50,5 +47,4 @@ $('.goodsDiscount .dropdown').on('click', function() { @@ -50,5 +47,4 @@ $('.goodsDiscount .dropdown').on('click', function() {
50 $('.goodsDiscount .discount-folder').slideUp(); 47 $('.goodsDiscount .discount-folder').slideUp();
51 } 48 }
52 }); 49 });
53 -  
54 require('./like'); 50 require('./like');
@@ -3,12 +3,14 @@ @@ -3,12 +3,14 @@
3 * @author: Lynnic 3 * @author: Lynnic
4 * @date: 2015/11/24 4 * @date: 2015/11/24
5 */ 5 */
  6 +
  7 +
6 var $ = require('jquery'), 8 var $ = require('jquery'),
7 Hammer = require('yoho.hammer'), 9 Hammer = require('yoho.hammer'),
8 tip = require('../../plugin/tip'); 10 tip = require('../../plugin/tip');
9 11
10 -var likeHammer = new Hammer(document.getElementById('likeBtn')),  
11 - addToCartHammer = new Hammer(document.getElementById('addtoCart')); 12 +var likeHammer = new Hammer(document.getElementById('likeBtn'));
  13 +var addToCartHammer = new Hammer(document.getElementById('addtoCart'));
12 14
13 var productId = $('#productId').val(); 15 var productId = $('#productId').val();
14 16
@@ -16,8 +18,7 @@ likeHammer.on('tap', function(e) { @@ -16,8 +18,7 @@ likeHammer.on('tap', function(e) {
16 var opt, 18 var opt,
17 favorite; 19 favorite;
18 20
19 -  
20 - var $this = $(this); 21 + var $this = $(e.target);
21 22
22 if ($this.hasClass('liked')) { 23 if ($this.hasClass('liked')) {
23 opt = 'cancel'; 24 opt = 'cancel';
@@ -26,7 +27,6 @@ likeHammer.on('tap', function(e) { @@ -26,7 +27,6 @@ likeHammer.on('tap', function(e) {
26 opt = 'ok'; 27 opt = 'ok';
27 favorite = 1; 28 favorite = 1;
28 } 29 }
29 -  
30 $.ajax({ 30 $.ajax({
31 type: 'POST', 31 type: 'POST',
32 url: '/product/opt/favoriteProduct', 32 url: '/product/opt/favoriteProduct',
@@ -124,11 +124,10 @@ @@ -124,11 +124,10 @@
124 {{/if}} 124 {{/if}}
125 <a href="{{cartUrl}}" class="num-incart iconfont">&#xe62c;</a> 125 <a href="{{cartUrl}}" class="num-incart iconfont">&#xe62c;</a>
126 {{#if goodsInstore}} 126 {{#if goodsInstore}}
127 - <a href="{{cartUrl}}" id="addtoCart" class="addto-cart">加入购物车</a> 127 + <a id="addtoCart" href="{{cartUrl}}" class="addto-cart">加入购物车</a>
128 {{else}} 128 {{else}}
129 - <a href="javascript:;" class="sold-out">已售罄</a> 129 + <a href="javascript:;" id="addtoCart" class="sold-out">已售罄</a>
130 {{/if}} 130 {{/if}}
131 -  
132 <a href="javascript:;" id="likeBtn" class="favorite iconfont {{#isCollect}}liked{{/isCollect}}">&#xe605;</a> 131 <a href="javascript:;" id="likeBtn" class="favorite iconfont {{#isCollect}}liked{{/isCollect}}">&#xe605;</a>
133 </div> 132 </div>
134 {{/cartInfo}} 133 {{/cartInfo}}