Authored by 梁志锋

购物车功能修改 code review by bikai

... ... @@ -20,9 +20,7 @@ var panelTmpl,
$chosed,
re = /\d+/,
leftNum,
$colorList,
$sizeList,
firstColorId,
colorIndex,
confirming,
hasChooseColor = false,
... ... @@ -45,6 +43,7 @@ $.get('/cart/index/giftinfoTpl', function(html) {
//初始化购物车面板显示
function init() {
//$colorList = $('.chose-panel .color-list ul>li');
//$sizeList = $('.chose-panel .size-list ul>li');
//firstColorId = $colorList.eq(0).data('id');
... ... @@ -55,8 +54,10 @@ function init() {
// $(this).removeClass('hide');
// }
//});
var $firstRow = $sizeRowList.eq(0);
//$firstRow.toggleClass('hide');
$firstRow.toggleClass('hide');
$curSizeRow = $firstRow;
}
... ... @@ -100,6 +101,8 @@ $('.color-list').on('touchstart', '.block', function(e) {
numArray,
index,
curSelectedSizeBlock,
$sizeChosed,
scindex,
i;
var $siblingBlock = $this.closest('.block-list').siblings(':first'),
... ... @@ -108,8 +111,8 @@ $('.color-list').on('touchstart', '.block', function(e) {
$this.siblings('.chosed').removeClass('chosed');
index = $this.index();
var $sizeChosed = $siblingBlock.find('.chosed');
var scindex = $sizeChosed.index();
$sizeChosed = $siblingBlock.find('.chosed');
scindex = $sizeChosed.index();
$curSizeRow = $sizeRowList.eq(index);
// 当前颜色已经是选中状态,再点击时
... ... @@ -163,18 +166,15 @@ $('.color-list').on('touchstart', '.block', function(e) {
}
});
} else if ($chosed.length === 1 && $this.hasClass('chosed')) {
//if ($this.closest('.block-list').hasClass('color-list')) {
$sizeList.addClass('hide');
$sizeList.addClass('hide');
//切换尺码信息
$sizeList.each(function() {
colorIndex = $(this).data('colorid');
if (colorIndex === $this.data('id')) {
$(this).removeClass('hide');
}
});
//}
//切换尺码信息
$sizeList.each(function() {
colorIndex = $(this).data('colorid');
if (colorIndex === $this.data('id')) {
$(this).removeClass('hide');
}
});
numArray = ($chosed.data('numstr') + '').split('/');
$siblingBlock.find('.block').removeClass('zero-stock');
... ...