...
|
...
|
@@ -37,7 +37,9 @@ var $chosePanel = $('#chose-panel'), |
|
|
$choseArea,
|
|
|
$cartBar,
|
|
|
$soonSoldOut = $('.soonSoldOut-tag'),
|
|
|
$yohoPage = $('.yoho-page');
|
|
|
$yohoPage = $('.yoho-page'),
|
|
|
//门票 限购数量
|
|
|
ticketsLimit = $('#limitNum').val();
|
|
|
|
|
|
// 购物车编辑标相关变量
|
|
|
var isEdit,
|
...
|
...
|
@@ -173,7 +175,7 @@ function updateConformButtonClassAndText() { |
|
|
$chosed = $allChoseItems.find('.chosed');
|
|
|
if (2 === $chosed.closest('.zero-stock').length) {
|
|
|
$('#chose-btn-sure').css('background-color', '#c0c0c0').html('已售罄');
|
|
|
} else if (limitProductCode) {
|
|
|
} else if (limitProductCode || ticketsLimit) {
|
|
|
$('#chose-btn-sure').css('background-color', '#eb0313').html('立即购买');
|
|
|
} else {
|
|
|
$('#chose-btn-sure').css('background-color', '#eb0313').html(isEdit ? '确认' : '加入购物车');
|
...
|
...
|
@@ -183,7 +185,14 @@ function updateConformButtonClassAndText() { |
|
|
//显示剩余件数
|
|
|
function displayGoodNum(curGoodNum) {
|
|
|
|
|
|
//数量大于0
|
|
|
//门票限购
|
|
|
if (ticketsLimit && curGoodNum > ticketsLimit) {
|
|
|
$allChoseItems.find('.num .left-num').html('限购' + ticketsLimit + '件');
|
|
|
$leftNum.val(curGoodNum);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
//数量大于
|
|
|
if (curGoodNum > 0) {
|
|
|
if ($soonSoldOut.length > 0) {
|
|
|
$allChoseItems.find('.num .left-num').html('即将售罄');
|
...
|
...
|
@@ -247,6 +256,30 @@ function changeColorChosed(newColorIndex) { |
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
//添加门票
|
|
|
function addTickets(productSku, buyNumber) {
|
|
|
var data = {
|
|
|
productSku: productSku,
|
|
|
buyNumber: buyNumber
|
|
|
}
|
|
|
|
|
|
//添加电子票
|
|
|
$.ajax({
|
|
|
url: '/cart/index/cart',
|
|
|
dataType: 'json',
|
|
|
data: data,
|
|
|
type: 'post',
|
|
|
success: function (addRestult) {
|
|
|
//调整订单确认页
|
|
|
window.location.href = '/cart/index/orderEnsure?cartType=tickets';
|
|
|
},
|
|
|
error: function () {
|
|
|
tip.show('网络异常~');
|
|
|
}
|
|
|
|
|
|
});
|
|
|
}
|
|
|
|
|
|
init();
|
|
|
|
|
|
|
...
|
...
|
@@ -296,7 +329,6 @@ $yohoPage.on('touchstart', '.color-list .block', function() { |
|
|
|
|
|
//老的选中尺码去掉勾选,新的选中尺码加上勾选
|
|
|
curGoodNum = changeSizeChosed(index + 1);
|
|
|
|
|
|
// 显示剩余数量
|
|
|
displayGoodNum(curGoodNum);
|
|
|
|
...
|
...
|
@@ -402,9 +434,10 @@ $yohoPage.on('touchstart', '.btn-minus', function() { |
|
|
|
|
|
$num.val(num - 1);
|
|
|
}).on('touchstart', '.btn-plus', function() {
|
|
|
var num = parseInt($num.val(), 10);
|
|
|
var num = parseInt($num.val(), 10),
|
|
|
maxTips = ticketsLimit ? '每人只可购买' + ticketsLimit + '张当日门票' : '您选择的数量超过了最大库存量~';
|
|
|
|
|
|
leftNum = $('#left-num').val();
|
|
|
leftNum = ticketsLimit || $('#left-num').val();
|
|
|
|
|
|
if (!checkColorSizeNum()) {
|
|
|
return;
|
...
|
...
|
@@ -416,7 +449,7 @@ $yohoPage.on('touchstart', '.btn-minus', function() { |
|
|
|
|
|
//TODO:库存数验证
|
|
|
if (num > leftNum - 1) {
|
|
|
tip.show('您选择的数量超过了最大库存量~');
|
|
|
tip.show(maxTips);
|
|
|
return;
|
|
|
}
|
|
|
$num.val(num + 1);
|
...
|
...
|
@@ -461,6 +494,12 @@ $yohoPage.on('touchstart', '.btn-minus', function() { |
|
|
confirming = true;
|
|
|
loading.showLoadingMask();
|
|
|
|
|
|
//立即购买门票
|
|
|
if (ticketsLimit) {
|
|
|
addTickets(productSku, buyNumber);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
//针对是否处于编辑模式设置不同的url和需要post的数据
|
|
|
if (isEdit) {
|
|
|
cartGoodData = {
|
...
|
...
|
|