...
|
...
|
@@ -22,14 +22,13 @@ var panelTmpl, |
|
|
// re = /\d+/,
|
|
|
leftNum,
|
|
|
confirming,
|
|
|
hasChooseColor = false,
|
|
|
hasChooseSize = false,
|
|
|
hasChooseColor,
|
|
|
hasChooseSize,
|
|
|
curColorIndex,
|
|
|
curSizeIndex,
|
|
|
$curSizeRow,
|
|
|
$curSizeBlock = null,
|
|
|
firstColorId,
|
|
|
$sizeRowList = $('.size-list ul');
|
|
|
$curSizeBlock,
|
|
|
$sizeRowList;
|
|
|
|
|
|
// 读取模板
|
|
|
$.get('/cart/index/giftinfoTpl', function(html) {
|
...
|
...
|
@@ -46,6 +45,11 @@ $.get('/cart/index/giftinfoTpl', function(html) { |
|
|
function init() {
|
|
|
var $firstRow = $sizeRowList.eq(0);
|
|
|
|
|
|
$sizeRowList = $('.size-list ul');
|
|
|
$curSizeBlock = null,
|
|
|
|
|
|
hasChooseSize = false,
|
|
|
hasChooseColor = false,
|
|
|
$firstRow.toggleClass('hide');
|
|
|
$curSizeRow = $firstRow;
|
|
|
}
|
...
|
...
|
@@ -76,7 +80,7 @@ function show(data) { |
|
|
$('body').css('overflow', 'hidden');
|
|
|
$num = $('#good-num');
|
|
|
}
|
|
|
|
|
|
|
|
|
//隐藏当前Panel
|
|
|
function hide() {
|
|
|
$('.chose-panel').hide();
|
...
|
...
|
@@ -97,23 +101,24 @@ function updateConformButtonClassAndText() { |
|
|
|
|
|
//重置颜色块的库存为0的样式
|
|
|
function resetColorZeroStock($siblingBlock) {
|
|
|
|
|
|
var numArray = ($curSizeBlock.data('numstr') + '').split('/');
|
|
|
if (!hasChooseSize) {
|
|
|
$siblingBlock.find('ul>li').each(function() {
|
|
|
$(this).removeClass('zero-stock');
|
|
|
if ('0' === $(this).data('num')) {
|
|
|
$(this).addClass('zero-stock');
|
|
|
}
|
|
|
});
|
|
|
|
|
|
} else {
|
|
|
for (var i = 0; i < numArray.length; i++) {
|
|
|
if ('0' === numArray[i]) {
|
|
|
$siblingBlock.find('.block').eq(i).addClass('zero-stock');
|
|
|
}
|
|
|
}
|
|
|
var numArray = ($curSizeBlock.data('numstr') + '').split('/'),
|
|
|
i;
|
|
|
|
|
|
if (!hasChooseSize) {
|
|
|
$siblingBlock.find('ul>li').each(function() {
|
|
|
$(this).removeClass('zero-stock');
|
|
|
if ('0' === $(this).data('num')) {
|
|
|
$(this).addClass('zero-stock');
|
|
|
}
|
|
|
});
|
|
|
|
|
|
} else {
|
|
|
for (i = 0; i < numArray.length; i++) {
|
|
|
if ('0' === numArray[i]) {
|
|
|
$siblingBlock.find('.block').eq(i).addClass('zero-stock');
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 选择了颜色切换商品图片
|
...
|
...
|
@@ -198,21 +203,21 @@ $('.color-list').on('touchstart', '.block', function(e) { |
|
|
// 设置按钮的样式和文字
|
|
|
updateConformButtonClassAndText();
|
|
|
|
|
|
// 修改颜色时修改商品图片
|
|
|
changeGoodImgWhenClickColor();
|
|
|
|
|
|
});
|
|
|
|
|
|
$('.size-list').on('touchstart', '.block', function(e) {
|
|
|
var $this = $(this),
|
|
|
$that = $(e.target).closest('.chose-items'),
|
|
|
index,
|
|
|
$colorChosed,
|
|
|
curGoodNum;
|
|
|
|
|
|
var $siblingBlock = $this.closest('.block-list').siblings(':first');
|
|
|
|
|
|
$this.siblings('.chosed').removeClass('chosed');
|
|
|
index = $this.index();
|
|
|
|
|
|
//$colorChosed = $siblingBlock.find('.chosed');
|
|
|
$curSizeRow = $sizeRowList.eq(index);
|
|
|
|
|
|
// 当前尺码已经是选中状态,再点击时
|
...
|
...
|
|