...
|
...
|
@@ -3,17 +3,18 @@ |
|
|
*/
|
|
|
|
|
|
var $ = require('yoho-jquery');
|
|
|
|
|
|
// var Dialog = require('../common/dialog').Dialog;
|
|
|
var Alert = require('../common/dialog').Alert;
|
|
|
var Confirm = require('../common/dialog').Confirm;
|
|
|
var dialog = require('../common/dialog');
|
|
|
var Dialog = dialog.Dialog;
|
|
|
var Alert = dialog.Alert;
|
|
|
var Confirm = dialog.Confirm;
|
|
|
|
|
|
var $cartnewTips = $('.cartnew-tips'),
|
|
|
$payWapper = $('.pay-wapper'),
|
|
|
$cartnewSum = $('.cartnew-sum'),
|
|
|
CART_ITEM_DEL_URL = '/cart/index/remove',
|
|
|
CART_ITEM_FAV_URL = '/cart/index/fav',
|
|
|
selColorWinTpl = require('hbs/cart/select-color-panel.hbs');
|
|
|
selColorWinTpl = require('hbs/cart/select-color-panel.hbs'),
|
|
|
giftsWinTpl = require('hbs/cart/cart-gifts-win-tpl.hbs');
|
|
|
|
|
|
// 关闭温馨提示
|
|
|
$cartnewTips.find('.btn_close').click(function() {
|
...
|
...
|
@@ -188,6 +189,7 @@ function addcart(data, cookieList) { |
|
|
}
|
|
|
|
|
|
function parseProductInfo(productInfo, defaultInfo) {
|
|
|
|
|
|
var index = 0;
|
|
|
var colors;
|
|
|
var colorsLen;
|
...
|
...
|
@@ -230,7 +232,6 @@ function parseProductInfo(productInfo, defaultInfo) { |
|
|
// 默认选中用户选择的sku,若已售罄或下架,则选中列表中第一个非售罄的sku
|
|
|
for (index = 0; index < filterSet.length; index++) {
|
|
|
curColor = filterSet[index];
|
|
|
|
|
|
if (!hasActiveColor && String(curColor.name) === String(defaultInfo.color)) {
|
|
|
curColor.active = true;
|
|
|
curColor.hasActiveColor = hasActiveColor = true;
|
...
|
...
|
@@ -241,9 +242,10 @@ function parseProductInfo(productInfo, defaultInfo) { |
|
|
curSize = curColor.sizes;
|
|
|
|
|
|
for (sizeIdx = 0; sizeIdx < curSize.length; sizeIdx++) {
|
|
|
|
|
|
if (curColor.hasActiveColor && curSize[sizeIdx].sku === defaultInfo.sku) {
|
|
|
// console.log(curSize[sizeIdx]);
|
|
|
curSize[sizeIdx].sizeFocus = true;
|
|
|
curSize[sizeIdx].sizeActive = true;
|
|
|
break;
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -294,6 +296,28 @@ function renderAndShowSelWin($item, pinfo) { |
|
|
$selWin.show();
|
|
|
}
|
|
|
|
|
|
function getProductByPromotionId(promotionId) {
|
|
|
return $.ajax({
|
|
|
type: 'GET',
|
|
|
url: '/cart/index/queryPromotionGift',
|
|
|
data: {
|
|
|
promotionId: promotionId
|
|
|
}
|
|
|
}).done(function(res) {
|
|
|
return res;
|
|
|
});
|
|
|
}
|
|
|
|
|
|
function renderAndShowGiftWin(plist) {
|
|
|
|
|
|
var d = new Dialog({
|
|
|
content: giftsWinTpl(plist),
|
|
|
className: 'cart-togetherGoods'
|
|
|
});
|
|
|
|
|
|
d.show();
|
|
|
}
|
|
|
|
|
|
var Cart = {
|
|
|
addToCart: function(params) {
|
|
|
|
...
|
...
|
@@ -580,7 +604,7 @@ var Cart = { |
|
|
},
|
|
|
selectColor: function() {
|
|
|
var $this = $(this);
|
|
|
var index = $this.index('.dt');
|
|
|
var index = $this.index($this.parent().find('.dt'));
|
|
|
var $srows = $this.closest('.goods-info').find('.choose-size .size-row');
|
|
|
var $bigImgs = $this.closest('.goods-choose-box').find('.goods-info-bigImg .bigImg');
|
|
|
|
...
|
...
|
@@ -603,6 +627,31 @@ var Cart = { |
|
|
$this.siblings('.dt').removeClass('active');
|
|
|
$this.addClass('active');
|
|
|
},
|
|
|
showGiftWin: function () {
|
|
|
|
|
|
var $this = $(this);
|
|
|
var $wrap = $this.closest('[data-role="promotion-wrap"]');
|
|
|
var promotionid = $wrap.data('promotionid');
|
|
|
var productList = $wrap.data('_giftList');
|
|
|
|
|
|
console.log($this);
|
|
|
console.log($wrap);
|
|
|
console.log(promotionid);
|
|
|
if(!productList) {
|
|
|
getProductByPromotionId(promotionid).done(function(plist) {
|
|
|
|
|
|
productList = plist;
|
|
|
|
|
|
$wrap.data('_giftList', productList);
|
|
|
renderAndShowGiftWin(productList);
|
|
|
}).fail(function() {
|
|
|
new Alert('获取商品失败,请稍后再试!').show();
|
|
|
});
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
renderAndShowGiftWin(productList);
|
|
|
},
|
|
|
submit: function() {
|
|
|
/* understock = '';
|
|
|
if ($('.pay-wapper input:checked').parents('tr').find('.tipNoStore').length > 0) {
|
...
|
...
|
@@ -659,8 +708,9 @@ $('.btn_account').on('click', Cart.submit); // 结算 |
|
|
$payWapper.on('click', 'li[data-role="pitem"] .pay-pro-detail', Cart.showColorSizePanel);
|
|
|
$payWapper.on('click', 'li[data-role="pitem"] .button-cancel', Cart.hideColorSizePanel);
|
|
|
$payWapper.on('click', 'li[data-role="pitem"] .button-sure', Cart.editColorOrSize);
|
|
|
$payWapper.on('click', 'li[data-role="pitem"] .goods-choose-box .choose-color .dt', Cart.selectColor);
|
|
|
$payWapper.on('click', 'li[data-role="pitem"] .goods-choose-box .choose-size .dt', Cart.selectSize);
|
|
|
$payWapper.find('li[data-role="pitem"]').on('click', '.goods-choose-box .choose-color .dt', Cart.selectColor);
|
|
|
$payWapper.find('li[data-role="pitem"]').on('click', '.goods-choose-box .choose-size .dt', Cart.selectSize);
|
|
|
|
|
|
|
|
|
/** 赠品加价购弹窗 **/
|
|
|
// 显示赠品
|
...
|
...
|
@@ -670,6 +720,8 @@ var giftBtn = ['[data-role=gift-view-btn]', |
|
|
'[data-role=pg-sel-btn]',
|
|
|
'[data-role=pg-resel-btn]'];
|
|
|
|
|
|
$payWapper.on('click', giftBtn.join(','), Cart.showGiftWin);
|
|
|
/*
|
|
|
$('.shop-cart').on('click', giftBtn.join(','), function() {
|
|
|
|
|
|
var $this = $(this);
|
...
|
...
|
@@ -681,4 +733,4 @@ $('.shop-cart').on('click', giftBtn.join(','), function() { |
|
|
|
|
|
$('.shop-cart').on('click', '[data-role="cart-gift-win"] .close', function() {
|
|
|
$(this).closest('[data-role="cart-gift-win"]').hide();
|
|
|
}); |
|
|
});*/ |
...
|
...
|
|