...
|
...
|
@@ -318,6 +318,7 @@ function parseProductInfo(productInfo, defaultInfo) { |
|
|
}
|
|
|
|
|
|
return {
|
|
|
skn: productInfo.skn,
|
|
|
colors: filterSet,
|
|
|
defaultColor: defaultColor,
|
|
|
defaultSize: defaultSize,
|
...
|
...
|
@@ -347,6 +348,25 @@ function updateCartItem(newSku, oldSku) { |
|
|
});
|
|
|
}
|
|
|
|
|
|
function updateCartGiftItem(promotionId, newSkn, newSku) {
|
|
|
|
|
|
$.ajax({
|
|
|
type: 'POST',
|
|
|
url: '/cart/index/swapGift',
|
|
|
data: {
|
|
|
promotionId: promotionId,
|
|
|
newSkn: newSkn,
|
|
|
newSku: newSku
|
|
|
}
|
|
|
}).then(function(d) {
|
|
|
if (d.code === 200) {
|
|
|
window.history.go(0);
|
|
|
} else {
|
|
|
new Alert(d.message === '' ? '修改商品失败哦~~' : d.message).show();
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
function renderAndShowSelWin($item, pinfo) {
|
|
|
|
|
|
$item.find('.goods-choose-box').remove();
|
...
|
...
|
@@ -368,8 +388,6 @@ function getProductByPromotionId(promotionId) { |
|
|
|
|
|
function bindGiftWinAction($el) {
|
|
|
|
|
|
var pacList = 0;
|
|
|
|
|
|
$el.on('click', '.slide-img .img-list .img-item', function() {
|
|
|
|
|
|
var id = $(this).data('id');
|
...
|
...
|
@@ -389,7 +407,7 @@ function bindGiftWinAction($el) { |
|
|
$el.find('.detail-bigpic:not(.none) .bigpic').hide().eq(idx).show();
|
|
|
});
|
|
|
|
|
|
$el.on('click', '.pre, .next', function(){
|
|
|
$el.on('click', '.pre, .next', function() {
|
|
|
var $this = $(this);
|
|
|
var $detailBigpic = $this.closest('.detail-bigpic');
|
|
|
var curIndex = Number($detailBigpic.data('_index') || 0);
|
...
|
...
|
@@ -413,16 +431,17 @@ function bindGiftWinAction($el) { |
|
|
$detailBigpic.find('.bigpic').hide().eq(curIndex).show();
|
|
|
});
|
|
|
|
|
|
$el.on('click', '.color', function(){
|
|
|
$el.on('click', '[data-role=colors] .color', function() {
|
|
|
|
|
|
var $this = $(this);
|
|
|
var idx = $this.index();
|
|
|
console.log(idx);
|
|
|
var $detail = $this.closest('.detail-goods');
|
|
|
var $sizes = $detail.find('.showSizeBox');
|
|
|
var $sizes = $detail.find('[data-role=sizes] .size-row');
|
|
|
var $detailBigpic = $detail.find('.detail-bigpic');
|
|
|
var $curSize = $sizes.eq(idx);
|
|
|
var $curDetailBig = $detailBigpic.eq(idx);
|
|
|
var bigPicIndex = 0; //默认显示大图中的第一个图
|
|
|
var bigPicIndex = 0; // 默认显示大图中的第一个图
|
|
|
|
|
|
$curDetailBig.data('_index', bigPicIndex);
|
|
|
|
...
|
...
|
@@ -430,7 +449,9 @@ function bindGiftWinAction($el) { |
|
|
$this.find('p').addClass('active');
|
|
|
|
|
|
$sizes.addClass('none').eq(idx).removeClass('none');
|
|
|
// console.log($sizes.addClass('none').eq(idx));
|
|
|
|
|
|
return;
|
|
|
if ($curSize.find('span').length < 2) {
|
|
|
$curSize.find('span:first').addClass('active');
|
|
|
}
|
...
|
...
|
@@ -456,7 +477,7 @@ function bindGiftWinAction($el) { |
|
|
});
|
|
|
});
|
|
|
|
|
|
$el.on('click', '.showSizeBox span', function(){
|
|
|
$el.on('click', '[data-role=sizes] .size-row span', function() {
|
|
|
|
|
|
var $this = $(this);
|
|
|
var idx = $this.index();
|
...
|
...
|
@@ -478,6 +499,7 @@ function bindGiftWinAction($el) { |
|
|
|
|
|
var $this = $(this);
|
|
|
var $pinfo = $this.closest('.product-detail-info');
|
|
|
|
|
|
// var count = $this.hasClass('minus') ? 'decreaseNum' : 'increaseNum';
|
|
|
var promotionId = $pinfo.data('promotionid');
|
|
|
var $num = $el.find('#num');
|
...
|
...
|
@@ -505,6 +527,37 @@ function bindGiftWinAction($el) { |
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
$el.on('click', '.addcart', function(){
|
|
|
|
|
|
var $this = $(this);
|
|
|
var $curSize = $el.find('[data-role=sizes] .size-row:not(.none) .active');
|
|
|
var $num = $el.find('#num');
|
|
|
var allNum = $curSize.data('num');
|
|
|
var sku = $curSize.data('sku');
|
|
|
var promotionId = $this.closest('.product-detail-info').data('promotionid') || 0;
|
|
|
|
|
|
if ($curSize.length <= 0) {
|
|
|
new Alert('请选择尺码').show();
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
if ($num.val() > allNum) {
|
|
|
new Alert('库存不足,目前还有' + allNum + '个库存').show();
|
|
|
} else {
|
|
|
/*if (Number($('#addToCart').val()) === 1) {
|
|
|
addcart(dataJSON);
|
|
|
} else {
|
|
|
new Alert('该商品无法加入购物车').show();
|
|
|
}*/
|
|
|
|
|
|
addcart({
|
|
|
productSku: sku,
|
|
|
buyNumber: $num.val(),
|
|
|
promotionId: promotionId
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
function renderAndShowGiftWin(plist) {
|
...
|
...
|
@@ -784,6 +837,8 @@ var Cart = { |
|
|
var oldSku = $item.data('id');
|
|
|
var $size = $this.closest('.goods-choose-box').find('.choose-size .dt.active');
|
|
|
var newSku = $size.data('sku');
|
|
|
var newSkn = $this.closest('.goods-info').data('skn');
|
|
|
var promotionId = $item.data('promotionid');
|
|
|
|
|
|
// 没有重新选择颜色-尺码,则不用重新请求显示
|
|
|
if (!oldSku || !newSku || oldSku === newSku) {
|
...
|
...
|
@@ -791,6 +846,10 @@ var Cart = { |
|
|
return false;
|
|
|
}
|
|
|
|
|
|
// 加价购更换
|
|
|
if($item.data('isgift') || $item.data('ispricegift')) {
|
|
|
return updateCartGiftItem(promotionId, newSkn,newSku);
|
|
|
}
|
|
|
updateCartItem(newSku, oldSku);
|
|
|
},
|
|
|
_hideColorSizePanel: function($item) {
|
...
|
...
|
|