Authored by hf

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

... ... @@ -14,6 +14,8 @@ var chosePanel = require('./chose-panel'),
var $cartContent = $('.cart-content');
var navHammer,
advanceBuyHammer,
freebieHammer,
cartType = $('#cartType').val();
var hasChecked = $('.cart-content:not(.hide) .icon-cb-checked').length > 0 ? true : false; //是否有选中商品
... ... @@ -47,6 +49,8 @@ if ($('.cart-nav').length > 0) {
//切换普通商品和预售商品购物车显示
$cartContent.toggleClass('hide');
hasChecked = $('.cart-content:not(.hide) .icon-cb-checked').length > 0 ? true : false;
//trigger lazyload
$(window).trigger('scroll');
});
... ... @@ -56,13 +60,27 @@ if ($('.cart-nav').length > 0) {
}, 3000);
}
$('.advance-buy').on('touchend', function() {
window.location.href = '/cart/index/advanceBuy?cartType=' + cartType;
});
if ($('.advance-buy').length > 0) {
advanceBuyHammer = new Hammer(document.getElementsByClassName('advance-buy')[0]);
advanceBuyHammer.on('tap', function(e) {
window.location.href = '/cart/index/advanceBuy?cartType=' + cartType;
});
}
$('.freebie').on('touchend', function() {
window.location.href = '/cart/index/gift?cartType=' + cartType;
});
if ($('.freebie').length > 0) {
freebieHammer = new Hammer(document.getElementsByClassName('freebie')[0]);
freebieHammer.on('tap', function(e) {
window.location.href = '/cart/index/gift?cartType=' + cartType;
});
}
//$('.advance-buy').on('touchend', function() {
// window.location.href = '/cart/index/advanceBuy?cartType=' + cartType;
//});
//
//$('.freebie').on('touchend', function() {
// window.location.href = '/cart/index/gift?cartType=' + cartType;
//});
$('.btn-balance').on('touchend', function() {
if ($('.low-stocks').length > 0) {
... ... @@ -78,8 +96,6 @@ $('.btn-balance').on('touchend', function() {
});
$('.chose').on('touchend', function() {
//var id = $(this).closest('.gift-advance-good').data('id');
chosePanel.show();
});
... ...
... ... @@ -70,7 +70,6 @@ function show(html, cb) {
init();
}
$('.chose-panel').show();
$('body').css('overflow', 'hidden');
$num = $('#good-num');
cbFn = cb;
}
... ... @@ -78,7 +77,6 @@ function show(html, cb) {
//隐藏当前Panel
function hide() {
$('.chose-panel').hide();
$('body').css('overflow', 'auto');
}
//修改加入购物车的文字和背景
... ... @@ -208,11 +206,11 @@ $yohoPage.on('touchstart', '.color-list .block', function() {
curColorIndex = index;
$('#good-num').val(1);
// 设置按钮的样式和文字
updateConformButtonClassAndText();
// 修改颜色时修改商品图片
changeGoodImgWhenClickColor();
// 设置按钮的样式和文字
updateConformButtonClassAndText();
}).on('touchstart', '.size-list .block', function() {
var $this = $(this),
index,
... ... @@ -232,11 +230,12 @@ $yohoPage.on('touchstart', '.color-list .block', function() {
$allChoseItems.find('.num .left-num').html('');
$('#left-num').val(0);
hasChooseSize = false;
curSizeIndex = null;
$curSizeBlock = null;
// 当前尺码不是选中状态,选中时
} else {
hasChooseSize = true;
curGoodNum = $this.data('num');
// 之前选中的尺码去掉勾选样式
... ... @@ -253,18 +252,21 @@ $yohoPage.on('touchstart', '.color-list .block', function() {
$('#left-num').val(0);
}
if (curGoodNum === 0 && hasChooseColor) {
$this.addClass('zero-stock');
}
curSizeIndex = index;
$curSizeBlock = $this;
}
$this.toggleClass('chosed');
curSizeIndex = index;
$curSizeBlock = $this;
$('#good-num').val(1);
// 设置按钮的样式和文字
updateConformButtonClassAndText();
// 重置颜色块的样式
resetColorZeroStock($siblingBlock);
// 设置按钮的样式和文字
updateConformButtonClassAndText();
});
$yohoPage.on('touchstart', '.btn-minus', function() {
... ... @@ -281,7 +283,7 @@ $yohoPage.on('touchstart', '.btn-minus', function() {
return;
}
if (num < 0) {
tip.show('您选择的数量不能为~');
tip.show('您选择的数量不能为负数~');
return;
}
... ... @@ -295,7 +297,6 @@ $yohoPage.on('touchstart', '.btn-minus', function() {
return;
}
if (num - 0 === leftNum || 0 === leftNum) {
return;
}
... ...
... ... @@ -23,7 +23,8 @@ var dispatchModeHammer,
payType,
priceTmpl = Handlebars.compile($('#tmpl-price').html()),
queryString = $.queryString(),
orderInfo = order.orderInfo;
orderInfo = order.orderInfo,
isSubmiting;
lazyLoad();
... ... @@ -127,6 +128,9 @@ function submitOrder() {
var invoiceText = $invoice.find('[name="invoice-title"]').val() || orderInfo('invoiceText'),
msg = $('#msg').find('input').val() || orderInfo('msg');
if (isSubmiting) {
return false;
}
if (orderInfo('invoice')) {
if (!invoiceText) {
tip.show('请输入发票抬头');
... ... @@ -144,6 +148,7 @@ function submitOrder() {
}
}
loading.showLoadingMask();
isSubmiting = true;
$.ajax({
method: 'POST',
url: '/cart/index/orderSub',
... ... @@ -184,6 +189,7 @@ function submitOrder() {
}).fail(function() {
tip.show('网络出错');
}).always(function() {
isSubmiting = false;
loading.hideLoadingMask();
});
}
... ... @@ -250,3 +256,7 @@ $('.pay-mode').on('click', 'li', function() {
payType = $this.data('pay-type');
submitOrder();
});
$('form').on('submit', function() {
return false;
});
... ...
... ... @@ -5,15 +5,6 @@
margin-left: 34rem / $pxConvertRem;
height: 160rem / $pxConvertRem;
border-bottom: 1px solid #e0e0e0;
&:last-child {
border-bottom: none;
}
}
.advance-block .gift-advance-good:last-child {
border-bottom: none;
}
.advance-block:last-child .gift-advance-good:last-child {
... ...
... ... @@ -111,6 +111,11 @@
.price {
font-size: 0.6rem;
color: $cartRed;
display: inline;
.sale-price{
color: #b0b0b0;
text-decoration: line-through;
}
}
.count {
... ...
... ... @@ -140,10 +140,11 @@
> li {
box-sizing: border-box;
height: 90rem / $pxConvertRem;
line-height: 90rem / $pxConvertRem;
height: 80rem / $pxConvertRem;
line-height: 80rem / $pxConvertRem;
margin-bottom: 10rem / $pxConvertRem;
padding: 0 20rem / $pxConvertRem;
background: #f1f1f1;
&:last-child {
margin-bottom: 0;
... ...
... ... @@ -49,7 +49,7 @@
.not-use {
display: block;
width: pxToRem(560px);
margin: pxToRem(30px) auto;
margin: pxToRem(30px) auto 0;
text-align: center;
font-size: pxToRem(32px);
line-height: 2.5;
... ...
... ... @@ -41,10 +41,12 @@
</p>
</div>
<p class="row">
<span class="price">
¥{{price}}
</span>
<p class="price">
<span class="market-price">¥{{price}}</span>
{{#if isAdvanceBuy}}
<span class="sale-price">¥{{salesPrice}}</span>
{{/if}}
</p>
{{#if isVipPrice}}
<span class="vip">
VIP
... ...
... ... @@ -555,8 +555,8 @@ class CartModel
$notAvailableRes = self::searchCoupon($uid, $val['couponCode']);
// 处理可用的优惠券
if ($val['isValidity'] === 'N' || (isset($notAvailableRes['code']) && $notAvailableRes['code'] !== 200)) {
// $val['notAvailable'] = true;
continue;
$val['notAvailable'] = true;
// continue;
}
$result[] = $val;
}
... ...