...
|
...
|
@@ -12,7 +12,25 @@ var $ = require('jquery'); |
|
|
// var $page = $('.yoho-page');
|
|
|
|
|
|
var $num,
|
|
|
$chosed;
|
|
|
$chosed,
|
|
|
re = /\d+/,
|
|
|
leftNum,
|
|
|
$colorList = $('.color-list ul>li'),
|
|
|
$sizeList = $('.size-list ul>li'),
|
|
|
firstColorId = $colorList.eq(0).data('id'),
|
|
|
colorIndex;
|
|
|
|
|
|
//初始化购物车面板显示
|
|
|
$sizeList.each(function() {
|
|
|
colorIndex = $(this).data('colorid');
|
|
|
|
|
|
|
|
|
if (colorIndex === firstColorId) {
|
|
|
$(this).removeClass('hide');
|
|
|
}
|
|
|
});
|
|
|
|
|
|
// confirm;
|
|
|
|
|
|
// var tpl;
|
|
|
|
...
|
...
|
@@ -35,8 +53,11 @@ var $num, |
|
|
// $num = $('#good-num');
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
function show() {
|
|
|
$('.chose-panel').show();
|
|
|
|
|
|
$('body').css('overflow', 'hidden');
|
|
|
$num = $('#good-num');
|
|
|
}
|
...
|
...
|
@@ -58,10 +79,43 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) { |
|
|
remove();
|
|
|
}).on('touchstart', '#chose-btn-sure', function() {
|
|
|
|
|
|
//确定
|
|
|
}).on('touchstart', '.block', function(e) {
|
|
|
// var productSku,
|
|
|
// buyNumber = $('#good-num') - 0;
|
|
|
// promotionId,
|
|
|
// goodsType,
|
|
|
// isEdit;
|
|
|
|
|
|
// //确定
|
|
|
// $chosed = $('.block-list>ul>li.chosed');
|
|
|
|
|
|
// if (2 === $chosed.length && 2 !== $chosed.closest('.zero-stock').length) {
|
|
|
|
|
|
// if (confirm) {
|
|
|
// return false;
|
|
|
// }
|
|
|
|
|
|
// confirm = true;
|
|
|
// loading.showLoadingMask();
|
|
|
// $.ajax({
|
|
|
// method: 'POST',
|
|
|
// url: '/cart/index/add',
|
|
|
// data: {
|
|
|
// product_id: productId,
|
|
|
// content: content
|
|
|
// }
|
|
|
// }).done(function(res) {
|
|
|
// if (res.code === 200) {
|
|
|
// loading.hideLoadingMask();
|
|
|
// confirm = false;
|
|
|
// remove();
|
|
|
// }
|
|
|
// }).fail(function() {
|
|
|
// tip.show('网络出了点问题~');
|
|
|
// confirm = false;
|
|
|
// });
|
|
|
// }
|
|
|
|
|
|
//尺寸颜色点选
|
|
|
}).on('touchstart', '.block', function(e) {
|
|
|
var $this = $(this),
|
|
|
$that = $(e.target).closest('.chose-items'),
|
|
|
numArray,
|
...
|
...
|
@@ -96,6 +150,19 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) { |
|
|
}
|
|
|
});
|
|
|
} else if ($chosed.length === 1 && $this.hasClass('chosed')) {
|
|
|
if ($this.closest('.block-list').hasClass('color-list')) {
|
|
|
|
|
|
$sizeList.addClass('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');
|
|
|
for (i = 0; i < numArray.length; i++) {
|
...
|
...
|
@@ -104,6 +171,9 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) { |
|
|
}
|
|
|
}
|
|
|
} else if ($chosed.length === 1 && !$this.hasClass('chosed')) {
|
|
|
$('#chose-btn-sure').css('background-color', '#eb0313');
|
|
|
$('#chose-btn-sure').html('确定');
|
|
|
|
|
|
$siblingBlock.find('ul>li').each(function() {
|
|
|
$(this).removeClass('zero-stock');
|
|
|
if (0 === $(this).data('num') - 0) {
|
...
|
...
|
@@ -123,19 +193,23 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) { |
|
|
if (2 === $chosed.closest('.zero-stock').length) {
|
|
|
$('#chose-btn-sure').css('background-color', '#c0c0c0');
|
|
|
$('#chose-btn-sure').html('已售罄');
|
|
|
} else {
|
|
|
$('#chose-btn-sure').css('background-color', '#eb0313');
|
|
|
$('#chose-btn-sure').html('确定');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}).on('touchstart', '.btn-minus', function() {
|
|
|
var num = +$num.val(),
|
|
|
$chosed = $('.block-list>ul>li.chosed');
|
|
|
$chosed = $('.block-list>ul>li.chosed'),
|
|
|
leftNum = re.exec($('.num .left-num').html());
|
|
|
|
|
|
//若颜色和尺码没有被同时选中,则不能点击
|
|
|
if ($chosed.length < 2) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (num === 0) {
|
|
|
if (num === 1 || 0 === leftNum - 0) {
|
|
|
return;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -147,6 +221,10 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) { |
|
|
if ($('.block-list>ul>li.chosed').length < 2) {
|
|
|
return;
|
|
|
}
|
|
|
leftNum = re.exec($('.num .left-num').html());
|
|
|
if (num - 0 === leftNum - 0 || 0 === leftNum - 0) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
//TODO:库存数验证
|
|
|
$num.val(num + 1);
|
...
|
...
|
|