Authored by hf

code review by hf: do merge liangzhifeng codes

... ... @@ -5202,6 +5202,9 @@ $.ajax({
if (data.code === 200) {
count = data.data.cart_goods_count || 0;
if (count === 0) {
return false;
}
if (count > 99) {
count = '99+';
}
... ... @@ -5603,7 +5606,6 @@ var $chosePanel = $('#chose-panel'),
confirming,
curColorIndex,
curSizeIndex,
$curSizeRow,
hasChooseColor,
hasChooseSize,
$curSizeBlock,
... ... @@ -5615,8 +5617,6 @@ var $chosePanel = $('#chose-panel'),
//初始化购物车面板显示
function init() {
var $firstRow;
hasChooseColor = false;
hasChooseSize = false;
$curSizeBlock = null;
... ... @@ -5625,9 +5625,7 @@ function init() {
$allChoseItems = $('.chose-items');
$sizeRowList = $('.size-list ul');
$leftNum = $('#left-num');
$firstRow = $sizeRowList.eq(0);
$firstRow.toggleClass('hide');
$curSizeRow = $firstRow;
$sizeRowList.eq(0).toggleClass('hide');
}
function checkColorSizeNum() {
... ... @@ -5650,6 +5648,7 @@ function show(html, cb) {
init();
}
$('.chose-panel').show();
$('body').css('overflow', 'hidden');
$num = $('#good-num');
cbFn = cb;
}
... ... @@ -5657,6 +5656,7 @@ function show(html, cb) {
//隐藏当前Panel
function hide() {
$('.chose-panel').hide();
$('body').css('overflow', 'auto');
}
//修改加入购物车的文字和背景
... ... @@ -5671,18 +5671,19 @@ function updateConformButtonClassAndText() {
//重置颜色块的库存为0的样式
function resetColorZeroStock($siblingBlock) {
var numArray = ($curSizeBlock.data('numstr') + '').split('/'),
var numArray,
i;
if (!hasChooseSize) {
$siblingBlock.find('ul>li').each(function() {
$(this).removeClass('zero-stock');
if ('0' === $(this).data('num')) {
if (0 === $(this).data('num')) {
$(this).addClass('zero-stock');
}
});
} else {
numArray = ($curSizeBlock.data('numstr') + '').split('/');
for (i = 0; i < numArray.length; i++) {
if ('0' === numArray[i]) {
$siblingBlock.find('.block').eq(i).addClass('zero-stock');
... ... @@ -5711,12 +5712,14 @@ $yohoPage.on('touchstart', '.chose-panel', function(e) {
hide();
});
$yohoPage.on('touchstart', '.color-list .block', function(e) {
$yohoPage.on('touchstart', '.color-list .block', function() {
var $this = $(this),
index,
curSizeBlock,
$preSiblingBlock,
scindex,
$curSizeRow,
numArray,
i,
curGoodNum;
var $siblingBlock = $this.closest('.block-list').siblings(':first');
... ... @@ -5725,7 +5728,6 @@ $yohoPage.on('touchstart', '.color-list .block', function(e) {
index = $this.index();
$preSiblingBlock = $siblingBlock.find('.chosed');
scindex = $preSiblingBlock.index();
$curSizeRow = $sizeRowList.eq(index);
// 当前颜色已经是选中状态,再点击时
... ... @@ -5736,6 +5738,16 @@ $yohoPage.on('touchstart', '.color-list .block', function(e) {
$leftNum.val(0);
hasChooseColor = false;
$this.removeClass('zero-stock');
if ($curSizeBlock) {
numArray = ($curSizeBlock.data('numstr') + '').split('/');
for (i = 0; i < numArray.length; i++) {
if ('0' === numArray[i]) {
$('.color-list .block').eq(i).addClass('zero-stock');
}
}
}
// 当前颜色不是选中状态,选中时
} else {
hasChooseColor = true;
... ... @@ -5747,7 +5759,7 @@ $yohoPage.on('touchstart', '.color-list .block', function(e) {
// 之前选中的尺码去掉勾选样式
if ($preSiblingBlock.length > 0) {
$preSiblingBlock.removeClass('chosed');
curSizeBlock = $curSizeRow.children().get(scindex);
curSizeBlock = $curSizeRow.children().get(curSizeIndex);
}
// 当前选中颜色对应的尺码行,其对应的尺码加上勾选样式 (前提是要判断下这个尺码是否存在)
... ... @@ -5775,11 +5787,10 @@ $yohoPage.on('touchstart', '.color-list .block', function(e) {
// 修改颜色时修改商品图片
changeGoodImgWhenClickColor();
});
$yohoPage.on('touchstart', '.size-list .block', function(e) {
}).on('touchstart', '.size-list .block', function() {
var $this = $(this),
index,
$curSizeRow,
curGoodNum;
var $siblingBlock = $this.closest('.block-list').siblings(':first');
... ... @@ -5827,7 +5838,6 @@ $yohoPage.on('touchstart', '.size-list .block', function(e) {
// 重置颜色块的样式
resetColorZeroStock($siblingBlock);
});
$yohoPage.on('touchstart', '.btn-minus', function() {
... ... @@ -5913,7 +5923,6 @@ $yohoPage.on('touchstart', '.btn-minus', function() {
if (res.code === 200) {
$('.num-tag').html(numInCart + buyNumber).removeClass('hide');
confirming = false;
hide();
if (cbFn) {
cbFn();
... ... @@ -5922,6 +5931,8 @@ $yohoPage.on('touchstart', '.btn-minus', function() {
if (res.message) {
tip.show(res.message);
}
hide();
}).fail(function() {
tip.show('网络出了点问题~');
}).always(function() {
... ... @@ -8631,6 +8642,10 @@ $('.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 (hasChecked) {
window.location.href = '/cart/index/orderEnsure?cartType=' + cartType;
... ...
This diff could not be displayed because it is too large.