...
|
...
|
@@ -22,7 +22,6 @@ var $chosePanel = $('#chose-panel'), |
|
|
confirming,
|
|
|
curColorIndex,
|
|
|
curSizeIndex,
|
|
|
$curSizeRow,
|
|
|
hasChooseColor,
|
|
|
hasChooseSize,
|
|
|
$curSizeBlock,
|
...
|
...
|
@@ -34,8 +33,6 @@ var $chosePanel = $('#chose-panel'), |
|
|
|
|
|
//初始化购物车面板显示
|
|
|
function init() {
|
|
|
var $firstRow;
|
|
|
|
|
|
hasChooseColor = false;
|
|
|
hasChooseSize = false;
|
|
|
$curSizeBlock = null;
|
...
|
...
|
@@ -44,9 +41,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() {
|
...
|
...
|
@@ -69,6 +64,7 @@ function show(html, cb) { |
|
|
init();
|
|
|
}
|
|
|
$('.chose-panel').show();
|
|
|
$('body').css('overflow', 'hidden');
|
|
|
$num = $('#good-num');
|
|
|
cbFn = cb;
|
|
|
}
|
...
|
...
|
@@ -76,6 +72,7 @@ function show(html, cb) { |
|
|
//隐藏当前Panel
|
|
|
function hide() {
|
|
|
$('.chose-panel').hide();
|
|
|
$('body').css('overflow', 'auto');
|
|
|
}
|
|
|
|
|
|
//修改加入购物车的文字和背景
|
...
|
...
|
@@ -90,18 +87,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');
|
...
|
...
|
@@ -130,12 +128,13 @@ $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,
|
|
|
curGoodNum;
|
|
|
|
|
|
var $siblingBlock = $this.closest('.block-list').siblings(':first');
|
...
|
...
|
@@ -144,7 +143,6 @@ $yohoPage.on('touchstart', '.color-list .block', function(e) { |
|
|
index = $this.index();
|
|
|
|
|
|
$preSiblingBlock = $siblingBlock.find('.chosed');
|
|
|
scindex = $preSiblingBlock.index();
|
|
|
$curSizeRow = $sizeRowList.eq(index);
|
|
|
|
|
|
// 当前颜色已经是选中状态,再点击时
|
...
|
...
|
@@ -155,6 +153,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;
|
...
|
...
|
@@ -166,7 +174,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);
|
|
|
}
|
|
|
|
|
|
// 当前选中颜色对应的尺码行,其对应的尺码加上勾选样式 (前提是要判断下这个尺码是否存在)
|
...
|
...
|
@@ -194,11 +202,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');
|
...
|
...
|
@@ -246,7 +253,6 @@ $yohoPage.on('touchstart', '.size-list .block', function(e) { |
|
|
|
|
|
// 重置颜色块的样式
|
|
|
resetColorZeroStock($siblingBlock);
|
|
|
|
|
|
});
|
|
|
|
|
|
$yohoPage.on('touchstart', '.btn-minus', function() {
|
...
|
...
|
@@ -332,7 +338,6 @@ $yohoPage.on('touchstart', '.btn-minus', function() { |
|
|
if (res.code === 200) {
|
|
|
$('.num-tag').html(numInCart + buyNumber).removeClass('hide');
|
|
|
confirming = false;
|
|
|
hide();
|
|
|
|
|
|
if (cbFn) {
|
|
|
cbFn();
|
...
|
...
|
@@ -341,6 +346,8 @@ $yohoPage.on('touchstart', '.btn-minus', function() { |
|
|
if (res.message) {
|
|
|
tip.show(res.message);
|
|
|
}
|
|
|
|
|
|
hide();
|
|
|
}).fail(function() {
|
|
|
tip.show('网络出了点问题~');
|
|
|
}).always(function() {
|
...
|
...
|
|