Authored by 梁志锋

加价购链接改成hammer

@@ -14,6 +14,8 @@ var chosePanel = require('./chose-panel'), @@ -14,6 +14,8 @@ var chosePanel = require('./chose-panel'),
14 var $cartContent = $('.cart-content'); 14 var $cartContent = $('.cart-content');
15 15
16 var navHammer, 16 var navHammer,
  17 + advanceBuyHammer,
  18 + freebieHammer,
17 cartType = $('#cartType').val(); 19 cartType = $('#cartType').val();
18 20
19 var hasChecked = $('.cart-content:not(.hide) .icon-cb-checked').length > 0 ? true : false; //是否有选中商品 21 var hasChecked = $('.cart-content:not(.hide) .icon-cb-checked').length > 0 ? true : false; //是否有选中商品
@@ -56,13 +58,27 @@ if ($('.cart-nav').length > 0) { @@ -56,13 +58,27 @@ if ($('.cart-nav').length > 0) {
56 }, 3000); 58 }, 3000);
57 } 59 }
58 60
59 -$('.advance-buy').on('touchend', function() {  
60 - window.location.href = '/cart/index/advanceBuy?cartType=' + cartType;  
61 -}); 61 +if ($('.advance-buy').length > 0) {
  62 + advanceBuyHammer = new Hammer(document.getElementsByClassName('advance-buy')[0]);
  63 + advanceBuyHammer.on('tap', function(e) {
  64 + window.location.href = '/cart/index/advanceBuy?cartType=' + cartType;
  65 + });
  66 +}
62 67
63 -$('.freebie').on('touchend', function() {  
64 - window.location.href = '/cart/index/gift?cartType=' + cartType;  
65 -}); 68 +if ($('.freebie').length > 0) {
  69 + freebieHammer = new Hammer(document.getElementsByClassName('freebie')[0]);
  70 + freebieHammer.on('tap', function(e) {
  71 + window.location.href = '/cart/index/gift?cartType=' + cartType;
  72 + });
  73 +}
  74 +
  75 +//$('.advance-buy').on('touchend', function() {
  76 +// window.location.href = '/cart/index/advanceBuy?cartType=' + cartType;
  77 +//});
  78 +//
  79 +//$('.freebie').on('touchend', function() {
  80 +// window.location.href = '/cart/index/gift?cartType=' + cartType;
  81 +//});
66 82
67 $('.btn-balance').on('touchend', function() { 83 $('.btn-balance').on('touchend', function() {
68 if ($('.low-stocks').length > 0) { 84 if ($('.low-stocks').length > 0) {
@@ -78,8 +94,6 @@ $('.btn-balance').on('touchend', function() { @@ -78,8 +94,6 @@ $('.btn-balance').on('touchend', function() {
78 }); 94 });
79 95
80 $('.chose').on('touchend', function() { 96 $('.chose').on('touchend', function() {
81 -  
82 - //var id = $(this).closest('.gift-advance-good').data('id');  
83 chosePanel.show(); 97 chosePanel.show();
84 }); 98 });
85 99
@@ -208,11 +208,11 @@ $yohoPage.on('touchstart', '.color-list .block', function() { @@ -208,11 +208,11 @@ $yohoPage.on('touchstart', '.color-list .block', function() {
208 curColorIndex = index; 208 curColorIndex = index;
209 $('#good-num').val(1); 209 $('#good-num').val(1);
210 210
211 - // 设置按钮的样式和文字  
212 - updateConformButtonClassAndText();  
213 -  
214 // 修改颜色时修改商品图片 211 // 修改颜色时修改商品图片
215 changeGoodImgWhenClickColor(); 212 changeGoodImgWhenClickColor();
  213 +
  214 + // 设置按钮的样式和文字
  215 + updateConformButtonClassAndText();
216 }).on('touchstart', '.size-list .block', function() { 216 }).on('touchstart', '.size-list .block', function() {
217 var $this = $(this), 217 var $this = $(this),
218 index, 218 index,
@@ -232,11 +232,12 @@ $yohoPage.on('touchstart', '.color-list .block', function() { @@ -232,11 +232,12 @@ $yohoPage.on('touchstart', '.color-list .block', function() {
232 $allChoseItems.find('.num .left-num').html(''); 232 $allChoseItems.find('.num .left-num').html('');
233 $('#left-num').val(0); 233 $('#left-num').val(0);
234 hasChooseSize = false; 234 hasChooseSize = false;
  235 + curSizeIndex = null;
  236 + $curSizeBlock = null;
235 237
236 // 当前尺码不是选中状态,选中时 238 // 当前尺码不是选中状态,选中时
237 } else { 239 } else {
238 hasChooseSize = true; 240 hasChooseSize = true;
239 -  
240 curGoodNum = $this.data('num'); 241 curGoodNum = $this.data('num');
241 242
242 // 之前选中的尺码去掉勾选样式 243 // 之前选中的尺码去掉勾选样式
@@ -253,18 +254,21 @@ $yohoPage.on('touchstart', '.color-list .block', function() { @@ -253,18 +254,21 @@ $yohoPage.on('touchstart', '.color-list .block', function() {
253 $('#left-num').val(0); 254 $('#left-num').val(0);
254 } 255 }
255 256
  257 + if (curGoodNum === 0 && hasChooseColor) {
  258 + $this.addClass('zero-stock');
  259 + }
  260 + curSizeIndex = index;
  261 + $curSizeBlock = $this;
256 } 262 }
257 263
258 $this.toggleClass('chosed'); 264 $this.toggleClass('chosed');
259 - curSizeIndex = index;  
260 - $curSizeBlock = $this;  
261 $('#good-num').val(1); 265 $('#good-num').val(1);
262 266
263 - // 设置按钮的样式和文字  
264 - updateConformButtonClassAndText();  
265 -  
266 // 重置颜色块的样式 267 // 重置颜色块的样式
267 resetColorZeroStock($siblingBlock); 268 resetColorZeroStock($siblingBlock);
  269 +
  270 + // 设置按钮的样式和文字
  271 + updateConformButtonClassAndText();
268 }); 272 });
269 273
270 $yohoPage.on('touchstart', '.btn-minus', function() { 274 $yohoPage.on('touchstart', '.btn-minus', function() {
@@ -281,7 +285,7 @@ $yohoPage.on('touchstart', '.btn-minus', function() { @@ -281,7 +285,7 @@ $yohoPage.on('touchstart', '.btn-minus', function() {
281 return; 285 return;
282 } 286 }
283 if (num < 0) { 287 if (num < 0) {
284 - tip.show('您选择的数量不能为~'); 288 + tip.show('您选择的数量不能为负数~');
285 return; 289 return;
286 } 290 }
287 291
@@ -295,7 +299,6 @@ $yohoPage.on('touchstart', '.btn-minus', function() { @@ -295,7 +299,6 @@ $yohoPage.on('touchstart', '.btn-minus', function() {
295 return; 299 return;
296 } 300 }
297 301
298 -  
299 if (num - 0 === leftNum || 0 === leftNum) { 302 if (num - 0 === leftNum || 0 === leftNum) {
300 return; 303 return;
301 } 304 }