Authored by hf

code review by hf: fixes some bugs to help detail page

@@ -5670,7 +5670,6 @@ function show(html, cb) { @@ -5670,7 +5670,6 @@ function show(html, cb) {
5670 init(); 5670 init();
5671 } 5671 }
5672 $('.chose-panel').show(); 5672 $('.chose-panel').show();
5673 - $('body').css('overflow', 'hidden');  
5674 $num = $('#good-num'); 5673 $num = $('#good-num');
5675 cbFn = cb; 5674 cbFn = cb;
5676 } 5675 }
@@ -5678,7 +5677,6 @@ function show(html, cb) { @@ -5678,7 +5677,6 @@ function show(html, cb) {
5678 //隐藏当前Panel 5677 //隐藏当前Panel
5679 function hide() { 5678 function hide() {
5680 $('.chose-panel').hide(); 5679 $('.chose-panel').hide();
5681 - $('body').css('overflow', 'auto');  
5682 } 5680 }
5683 5681
5684 //修改加入购物车的文字和背景 5682 //修改加入购物车的文字和背景
@@ -5808,11 +5806,11 @@ $yohoPage.on('touchstart', '.color-list .block', function() { @@ -5808,11 +5806,11 @@ $yohoPage.on('touchstart', '.color-list .block', function() {
5808 curColorIndex = index; 5806 curColorIndex = index;
5809 $('#good-num').val(1); 5807 $('#good-num').val(1);
5810 5808
5811 - // 设置按钮的样式和文字  
5812 - updateConformButtonClassAndText();  
5813 -  
5814 // 修改颜色时修改商品图片 5809 // 修改颜色时修改商品图片
5815 changeGoodImgWhenClickColor(); 5810 changeGoodImgWhenClickColor();
  5811 +
  5812 + // 设置按钮的样式和文字
  5813 + updateConformButtonClassAndText();
5816 }).on('touchstart', '.size-list .block', function() { 5814 }).on('touchstart', '.size-list .block', function() {
5817 var $this = $(this), 5815 var $this = $(this),
5818 index, 5816 index,
@@ -5832,11 +5830,12 @@ $yohoPage.on('touchstart', '.color-list .block', function() { @@ -5832,11 +5830,12 @@ $yohoPage.on('touchstart', '.color-list .block', function() {
5832 $allChoseItems.find('.num .left-num').html(''); 5830 $allChoseItems.find('.num .left-num').html('');
5833 $('#left-num').val(0); 5831 $('#left-num').val(0);
5834 hasChooseSize = false; 5832 hasChooseSize = false;
  5833 + curSizeIndex = null;
  5834 + $curSizeBlock = null;
5835 5835
5836 // 当前尺码不是选中状态,选中时 5836 // 当前尺码不是选中状态,选中时
5837 } else { 5837 } else {
5838 hasChooseSize = true; 5838 hasChooseSize = true;
5839 -  
5840 curGoodNum = $this.data('num'); 5839 curGoodNum = $this.data('num');
5841 5840
5842 // 之前选中的尺码去掉勾选样式 5841 // 之前选中的尺码去掉勾选样式
@@ -5853,18 +5852,21 @@ $yohoPage.on('touchstart', '.color-list .block', function() { @@ -5853,18 +5852,21 @@ $yohoPage.on('touchstart', '.color-list .block', function() {
5853 $('#left-num').val(0); 5852 $('#left-num').val(0);
5854 } 5853 }
5855 5854
  5855 + if (curGoodNum === 0 && hasChooseColor) {
  5856 + $this.addClass('zero-stock');
  5857 + }
  5858 + curSizeIndex = index;
  5859 + $curSizeBlock = $this;
5856 } 5860 }
5857 5861
5858 $this.toggleClass('chosed'); 5862 $this.toggleClass('chosed');
5859 - curSizeIndex = index;  
5860 - $curSizeBlock = $this;  
5861 $('#good-num').val(1); 5863 $('#good-num').val(1);
5862 5864
5863 - // 设置按钮的样式和文字  
5864 - updateConformButtonClassAndText();  
5865 -  
5866 // 重置颜色块的样式 5865 // 重置颜色块的样式
5867 resetColorZeroStock($siblingBlock); 5866 resetColorZeroStock($siblingBlock);
  5867 +
  5868 + // 设置按钮的样式和文字
  5869 + updateConformButtonClassAndText();
5868 }); 5870 });
5869 5871
5870 $yohoPage.on('touchstart', '.btn-minus', function() { 5872 $yohoPage.on('touchstart', '.btn-minus', function() {
@@ -5881,7 +5883,7 @@ $yohoPage.on('touchstart', '.btn-minus', function() { @@ -5881,7 +5883,7 @@ $yohoPage.on('touchstart', '.btn-minus', function() {
5881 return; 5883 return;
5882 } 5884 }
5883 if (num < 0) { 5885 if (num < 0) {
5884 - tip.show('您选择的数量不能为~'); 5886 + tip.show('您选择的数量不能为负数~');
5885 return; 5887 return;
5886 } 5888 }
5887 5889
@@ -5895,7 +5897,6 @@ $yohoPage.on('touchstart', '.btn-minus', function() { @@ -5895,7 +5897,6 @@ $yohoPage.on('touchstart', '.btn-minus', function() {
5895 return; 5897 return;
5896 } 5898 }
5897 5899
5898 -  
5899 if (num - 0 === leftNum || 0 === leftNum) { 5900 if (num - 0 === leftNum || 0 === leftNum) {
5900 return; 5901 return;
5901 } 5902 }
@@ -8634,6 +8635,8 @@ var chosePanel = require("js/cart/chose-panel"), @@ -8634,6 +8635,8 @@ var chosePanel = require("js/cart/chose-panel"),
8634 var $cartContent = $('.cart-content'); 8635 var $cartContent = $('.cart-content');
8635 8636
8636 var navHammer, 8637 var navHammer,
  8638 + advanceBuyHammer,
  8639 + freebieHammer,
8637 cartType = $('#cartType').val(); 8640 cartType = $('#cartType').val();
8638 8641
8639 var hasChecked = $('.cart-content:not(.hide) .icon-cb-checked').length > 0 ? true : false; //是否有选中商品 8642 var hasChecked = $('.cart-content:not(.hide) .icon-cb-checked').length > 0 ? true : false; //是否有选中商品
@@ -8667,6 +8670,8 @@ if ($('.cart-nav').length > 0) { @@ -8667,6 +8670,8 @@ if ($('.cart-nav').length > 0) {
8667 //切换普通商品和预售商品购物车显示 8670 //切换普通商品和预售商品购物车显示
8668 $cartContent.toggleClass('hide'); 8671 $cartContent.toggleClass('hide');
8669 8672
  8673 + hasChecked = $('.cart-content:not(.hide) .icon-cb-checked').length > 0 ? true : false;
  8674 +
8670 //trigger lazyload 8675 //trigger lazyload
8671 $(window).trigger('scroll'); 8676 $(window).trigger('scroll');
8672 }); 8677 });
@@ -8676,13 +8681,27 @@ if ($('.cart-nav').length > 0) { @@ -8676,13 +8681,27 @@ if ($('.cart-nav').length > 0) {
8676 }, 3000); 8681 }, 3000);
8677 } 8682 }
8678 8683
8679 -$('.advance-buy').on('touchend', function() {  
8680 - window.location.href = '/cart/index/advanceBuy?cartType=' + cartType;  
8681 -}); 8684 +if ($('.advance-buy').length > 0) {
  8685 + advanceBuyHammer = new Hammer(document.getElementsByClassName('advance-buy')[0]);
  8686 + advanceBuyHammer.on('tap', function(e) {
  8687 + window.location.href = '/cart/index/advanceBuy?cartType=' + cartType;
  8688 + });
  8689 +}
8682 8690
8683 -$('.freebie').on('touchend', function() {  
8684 - window.location.href = '/cart/index/gift?cartType=' + cartType;  
8685 -}); 8691 +if ($('.freebie').length > 0) {
  8692 + freebieHammer = new Hammer(document.getElementsByClassName('freebie')[0]);
  8693 + freebieHammer.on('tap', function(e) {
  8694 + window.location.href = '/cart/index/gift?cartType=' + cartType;
  8695 + });
  8696 +}
  8697 +
  8698 +//$('.advance-buy').on('touchend', function() {
  8699 +// window.location.href = '/cart/index/advanceBuy?cartType=' + cartType;
  8700 +//});
  8701 +//
  8702 +//$('.freebie').on('touchend', function() {
  8703 +// window.location.href = '/cart/index/gift?cartType=' + cartType;
  8704 +//});
8686 8705
8687 $('.btn-balance').on('touchend', function() { 8706 $('.btn-balance').on('touchend', function() {
8688 if ($('.low-stocks').length > 0) { 8707 if ($('.low-stocks').length > 0) {
@@ -8698,8 +8717,6 @@ $('.btn-balance').on('touchend', function() { @@ -8698,8 +8717,6 @@ $('.btn-balance').on('touchend', function() {
8698 }); 8717 });
8699 8718
8700 $('.chose').on('touchend', function() { 8719 $('.chose').on('touchend', function() {
8701 -  
8702 - //var id = $(this).closest('.gift-advance-good').data('id');  
8703 chosePanel.show(); 8720 chosePanel.show();
8704 }); 8721 });
8705 8722
@@ -9051,7 +9068,8 @@ var dispatchModeHammer, @@ -9051,7 +9068,8 @@ var dispatchModeHammer,
9051 payType, 9068 payType,
9052 priceTmpl = Handlebars.compile($('#tmpl-price').html()), 9069 priceTmpl = Handlebars.compile($('#tmpl-price').html()),
9053 queryString = $.queryString(), 9070 queryString = $.queryString(),
9054 - orderInfo = order.orderInfo; 9071 + orderInfo = order.orderInfo,
  9072 + isSubmiting;
9055 9073
9056 lazyLoad(); 9074 lazyLoad();
9057 9075
@@ -9155,6 +9173,9 @@ function submitOrder() { @@ -9155,6 +9173,9 @@ function submitOrder() {
9155 var invoiceText = $invoice.find('[name="invoice-title"]').val() || orderInfo('invoiceText'), 9173 var invoiceText = $invoice.find('[name="invoice-title"]').val() || orderInfo('invoiceText'),
9156 msg = $('#msg').find('input').val() || orderInfo('msg'); 9174 msg = $('#msg').find('input').val() || orderInfo('msg');
9157 9175
  9176 + if (isSubmiting) {
  9177 + return false;
  9178 + }
9158 if (orderInfo('invoice')) { 9179 if (orderInfo('invoice')) {
9159 if (!invoiceText) { 9180 if (!invoiceText) {
9160 tip.show('请输入发票抬头'); 9181 tip.show('请输入发票抬头');
@@ -9172,6 +9193,7 @@ function submitOrder() { @@ -9172,6 +9193,7 @@ function submitOrder() {
9172 } 9193 }
9173 } 9194 }
9174 loading.showLoadingMask(); 9195 loading.showLoadingMask();
  9196 + isSubmiting = true;
9175 $.ajax({ 9197 $.ajax({
9176 method: 'POST', 9198 method: 'POST',
9177 url: '/cart/index/orderSub', 9199 url: '/cart/index/orderSub',
@@ -9212,6 +9234,7 @@ function submitOrder() { @@ -9212,6 +9234,7 @@ function submitOrder() {
9212 }).fail(function() { 9234 }).fail(function() {
9213 tip.show('网络出错'); 9235 tip.show('网络出错');
9214 }).always(function() { 9236 }).always(function() {
  9237 + isSubmiting = false;
9215 loading.hideLoadingMask(); 9238 loading.hideLoadingMask();
9216 }); 9239 });
9217 } 9240 }
@@ -9279,6 +9302,10 @@ $('.pay-mode').on('click', 'li', function() { @@ -9279,6 +9302,10 @@ $('.pay-mode').on('click', 'li', function() {
9279 submitOrder(); 9302 submitOrder();
9280 }); 9303 });
9281 9304
  9305 +$('form').on('submit', function() {
  9306 + return false;
  9307 +});
  9308 +
9282 }); 9309 });
9283 define("js/cart/select-coupon", ["jquery","handlebars","source-map","mlellipsis"], function(require, exports, module){ 9310 define("js/cart/select-coupon", ["jquery","handlebars","source-map","mlellipsis"], function(require, exports, module){
9284 /** 9311 /**
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.