商品详情页 加入购物车 code review by hf
Showing
1 changed file
with
9 additions
and
16 deletions
@@ -6,23 +6,16 @@ | @@ -6,23 +6,16 @@ | ||
6 | 6 | ||
7 | 7 | ||
8 | var $ = require('jquery'), | 8 | var $ = require('jquery'), |
9 | - Hammer = require('yoho.hammer'), | ||
10 | tip = require('../../plugin/tip'), | 9 | tip = require('../../plugin/tip'), |
11 | chosePanel = require('../../cart/chose-panel'); | 10 | chosePanel = require('../../cart/chose-panel'); |
12 | 11 | ||
13 | -var likeEle = document.getElementById('likeBtn'), | ||
14 | - likeHammer = likeEle && new Hammer(likeEle); | 12 | +var productId = $('#productId').val(); |
15 | 13 | ||
16 | -var addToCartEle = document.getElementById('addtoCart'), | ||
17 | - addToCartHammer = addToCartEle && new Hammer(addToCartEle), | ||
18 | - productId = $('#productId').val(); | ||
19 | - | ||
20 | -if (likeHammer) { | ||
21 | - likeHammer.on('tap', function(e) { | 14 | +$('#likeBtn').on('click', function() { |
22 | var opt, | 15 | var opt, |
23 | favorite; | 16 | favorite; |
24 | 17 | ||
25 | - var $this = $(e.target); | 18 | + var $this = $(this); |
26 | 19 | ||
27 | if ($this.hasClass('liked')) { | 20 | if ($this.hasClass('liked')) { |
28 | opt = 'cancel'; | 21 | opt = 'cancel'; |
@@ -66,11 +59,11 @@ if (likeHammer) { | @@ -66,11 +59,11 @@ if (likeHammer) { | ||
66 | fa: favorite | 59 | fa: favorite |
67 | }, true); | 60 | }, true); |
68 | } | 61 | } |
69 | - }); | ||
70 | -} | ||
71 | 62 | ||
72 | -if (addToCartHammer) { | ||
73 | - addToCartHammer.on('tap', function(e) { | 63 | + return false; |
64 | +}); | ||
65 | + | ||
66 | +$('#addtoCart').on('click', function() { | ||
74 | chosePanel.show(); | 67 | chosePanel.show(); |
75 | 68 | ||
76 | //统计代码:用于统计用户加入购物车的动作 | 69 | //统计代码:用于统计用户加入购物车的动作 |
@@ -81,5 +74,5 @@ if (addToCartHammer) { | @@ -81,5 +74,5 @@ if (addToCartHammer) { | ||
81 | }, true); | 74 | }, true); |
82 | } | 75 | } |
83 | 76 | ||
84 | - }); | ||
85 | -} | 77 | + return false; |
78 | +}); |
-
Please register or login to post a comment