Authored by 梁志锋

购物车尺码颜色选择

... ... @@ -98,7 +98,7 @@ function hide() {
$('body').css('overflow', 'auto');
}
$('.yoho-page').on('touchstart', '.infos', function(e) {
$('.yoho-page').on('touchstart', '.chose-panel', function(e) {
var $cur = $(e.target);
if ($cur.closest('.main').length > 0) {
... ... @@ -132,6 +132,7 @@ $('.color-list').on('touchstart', '.block', function(e) {
//颜色原来已经是勾选时,要清空剩余件数的提示
$that.find('.num .left-num').html('');
$('#left-num').val(0);
hasChooseColor = false;
// 当前颜色不是选中状态,选中时
... ... @@ -161,9 +162,11 @@ $('.color-list').on('touchstart', '.block', function(e) {
//如果当前有尺码被选中,且数量等于0,则颜色块添加数量为0的样式
if (curGoodNum > 0) {
$that.find('.num .left-num').html('剩余' + curGoodNum + '件');
$('#left-num').val(curGoodNum);
} else {
$(curSelectedSizeBlock).removeClass('zero-stock').addClass('zero-stock');
$that.find('.num .left-num').html('');
$('#left-num').val(0);
}
}
}
... ... @@ -250,7 +253,6 @@ $('.size-list').on('touchstart', '.block', function(e) {
$that = $(e.target).closest('.chose-items'),
index,
$colorChosed,
selectedColorindex,
curGoodNum;
var $siblingBlock = $this.closest('.block-list').siblings(':first');
... ... @@ -259,7 +261,6 @@ $('.size-list').on('touchstart', '.block', function(e) {
index = $this.index();
$colorChosed = $siblingBlock.find('.chosed');
selectedColorindex = $colorChosed.index();
$curSizeRow = $sizeRowList.eq(index);
// 当前尺码已经是选中状态,再点击时
... ... @@ -267,6 +268,7 @@ $('.size-list').on('touchstart', '.block', function(e) {
//尺码原来已经是勾选时,要清空剩余件数的提示
$that.find('.num .left-num').html('');
$('#left-num').val(0);
hasChooseSize = false;
// 去掉已经选中颜色的 数量为0的样式
... ... @@ -288,9 +290,11 @@ $('.size-list').on('touchstart', '.block', function(e) {
// 如果当前有尺码被选中,且数量等于0,则颜色块添加数量为0的样式, 否则显示剩余件数
if (curGoodNum > 0 && hasChooseColor) {
$that.find('.num .left-num').html('剩余' + curGoodNum + '件');
$('#left-num').val(curGoodNum);
} else {
$colorChosed.removeClass('zero-stock').addClass('zero-stock');
$that.find('.num .left-num').html('');
$('#left-num').val(0);
}
}
... ... @@ -375,8 +379,9 @@ $('.size-list').on('touchstart', '.block', function(e) {
});
$('.btn-minus').on('touchstart', function() {
var num = $num.val(),
leftNum = re.exec($('.num .left-num').html());
var num = $num.val();
leftNum = $('#left-num').val();
if (!checkColorSizeNum()) {
return;
... ... @@ -392,12 +397,14 @@ $('.btn-minus').on('touchstart', function() {
$('.btn-plus').on('touchstart', function() {
var num = $num.val();
leftNum = $('#left-num').val();
if (!checkColorSizeNum()) {
return;
}
leftNum = re.exec($('.num .left-num').html());
if (num - 0 === leftNum - 0 || 0 === leftNum - 0) {
if (num - 0 === leftNum || 0 === leftNum) {
return;
}
... ... @@ -405,7 +412,7 @@ $('.btn-plus').on('touchstart', function() {
$num.val(num + 1);
});
$('#chose-btn-sure').on('touchend', function() {
$('#chose-btn-sure').on('touchstart', function() {
var productSku,
buyNumber = $('#good-num').val() - 0,
... ... @@ -419,7 +426,11 @@ $('#chose-btn-sure').on('touchend', function() {
return;
}
leftNum = re.exec($('.num .left-num').html());
if ($('#chose-btn-sure').html() === '已售罄') {
return;
}
leftNum = $('#left-num').val();;
if (num > leftNum) {
tip.show('您选择的数量超过了最大库存量~');
... ... @@ -429,7 +440,7 @@ $('#chose-btn-sure').on('touchend', function() {
$chosed = $('.block-list>ul>li.chosed');
if (2 === $chosed.length && 0 === $chosed.closest('.zero-stock').length) {
productSku = $sizeList.closest('.chosed').data('skuid');
productSku = $curSizeBlock.data('skuid');
promotionId = $('[data-id="' + productSku + '"]').closest('.advance-block').data('promotion-id');
if (confirming) {
return false;
... ...