...
|
...
|
@@ -2,33 +2,39 @@ |
|
|
* Created by yoho on 2017-01-05.
|
|
|
*/
|
|
|
|
|
|
var $ = require('yoho-jquery');
|
|
|
var dialog = require('../common/dialog');
|
|
|
var Alert = dialog.Alert;
|
|
|
var $payWapper = $('.pay-wapper'),
|
|
|
var $ = require('yoho-jquery'),
|
|
|
dialog = require('../common/dialog'),
|
|
|
Alert = dialog.Alert,
|
|
|
$payWapper = $('.pay-wapper'),
|
|
|
giftsWinTpl = require('hbs/cart/cart-gifts-win-tpl.hbs'),
|
|
|
productInfoTpl = require('hbs/cart/cart-product-info-tpl.hbs'),
|
|
|
$goodsSelWin = $('#Y_goodsSelectWin');
|
|
|
$ModalOverflow = $('.modal-overflow');
|
|
|
|
|
|
var capi = require('./cart-api');
|
|
|
$(function () {
|
|
|
$(".body-modal-black").css({
|
|
|
$goodsSelWin = $('#Y_goodsSelectWin'),
|
|
|
capi = require('./cart-api'),
|
|
|
// 显示赠品
|
|
|
giftBtn = ['[data-role=gift-view-btn]',
|
|
|
'[data-role=gift-resel-btn]',
|
|
|
'[data-role=gift-sel-btn]',
|
|
|
'[data-role=pg-sel-btn]',
|
|
|
'[data-role=pg-resel-btn]'];
|
|
|
|
|
|
$(function() {
|
|
|
$('.body-modal-black').css({
|
|
|
height: $(document).height(),
|
|
|
width: $(document).width()
|
|
|
});
|
|
|
})
|
|
|
});
|
|
|
function renderAndShowGiftWin(plist) {
|
|
|
$goodsSelWin.find('.content').empty().html(giftsWinTpl(plist));
|
|
|
|
|
|
capi.showMDialog('#Y_goodsSelectWinDialog');/*
|
|
|
$ModalOverflow.show();
|
|
|
$ModalOverflow.closest('body').css({"overflow":'hidden',"position":"relative"});
|
|
|
$ModalOverflow.closest('body').css({'overflow': 'hidden', 'position': 'relative'});*/
|
|
|
}
|
|
|
|
|
|
/** 赠品加价购弹窗 **/
|
|
|
|
|
|
var GoodsWinAction = {
|
|
|
showGiftWin: function () {
|
|
|
showGiftWin: function() {
|
|
|
|
|
|
var $this = $(this);
|
|
|
var $wrap = $this.closest('[data-role="promotion-wrap"]');
|
...
|
...
|
@@ -57,7 +63,7 @@ var GoodsWinAction = { |
|
|
|
|
|
$promotionPool.find('[data-role=pitem][data-ispricegift], [data-role=pitem][data-isgift]');
|
|
|
if (!promotionInfo) {
|
|
|
capi.getProductByPromotionId(promotionid).done(function (pinfo) {
|
|
|
capi.getProductByPromotionId(promotionid).done(function(pinfo) {
|
|
|
|
|
|
|
|
|
if (!pinfo && pinfo.code !== 200) {
|
...
|
...
|
@@ -72,7 +78,7 @@ var GoodsWinAction = { |
|
|
|
|
|
$wrap.data('_promotionInfo', promotionInfo);
|
|
|
renderAndShowGiftWin(promotionInfo);
|
|
|
}).fail(function () {
|
|
|
}).fail(function() {
|
|
|
new Alert('获取商品失败,请稍后再试!').show();
|
|
|
});
|
|
|
return;
|
...
|
...
|
@@ -80,23 +86,23 @@ var GoodsWinAction = { |
|
|
|
|
|
renderAndShowGiftWin(promotionInfo);
|
|
|
},
|
|
|
closeWin: function () {
|
|
|
/*closeWin: function() {
|
|
|
$ModalOverflow.hide();
|
|
|
},
|
|
|
changeGoods: function () {
|
|
|
},*/
|
|
|
changeGoods: function() {
|
|
|
|
|
|
var $this = $(this);
|
|
|
var id = $this.data('id');
|
|
|
var skn = $this.data('skn');
|
|
|
|
|
|
$this.sibling('li').removeClass('active');
|
|
|
$this.siblings('li').removeClass('active');
|
|
|
$this.addClass('active');
|
|
|
|
|
|
capi.getProductInfo(id, skn).then(res => {
|
|
|
$goodsSelWin.find('.product-detail-info').empty().append(productInfoTpl(res));
|
|
|
});
|
|
|
},
|
|
|
selThumb: function () {
|
|
|
selThumb: function() {
|
|
|
var $this = $(this);
|
|
|
var idx = $(this).index();
|
|
|
|
...
|
...
|
@@ -104,7 +110,7 @@ var GoodsWinAction = { |
|
|
$this.addClass('active');
|
|
|
$goodsSelWin.find('.detail-bigpic:not(.none) .bigpic').hide().eq(idx).show();
|
|
|
},
|
|
|
selThumbPrevNext: function () {
|
|
|
selThumbPrevNext: function() {
|
|
|
var $this = $(this);
|
|
|
var $detailBigpic = $this.closest('.detail-bigpic');
|
|
|
var curIndex = Number($detailBigpic.data('_index') || 0);
|
...
|
...
|
@@ -127,7 +133,7 @@ var GoodsWinAction = { |
|
|
$lis.removeClass('active').eq(curIndex).addClass('active');
|
|
|
$detailBigpic.find('.bigpic').hide().eq(curIndex).show();
|
|
|
},
|
|
|
selColor: function () {
|
|
|
selColor: function() {
|
|
|
|
|
|
var $this = $(this);
|
|
|
var idx = $this.index();
|
...
|
...
|
@@ -159,7 +165,7 @@ var GoodsWinAction = { |
|
|
$curDetailBig.find('.con li').removeClass('active');
|
|
|
$curDetailBig.find('.con li').eq(bigPicIndex).addClass('active');
|
|
|
|
|
|
$sizes.eq(idx).find('span').each(function () {
|
|
|
$sizes.eq(idx).find('span').each(function() {
|
|
|
if ($(this).hasClass('null-atcivec')) {
|
|
|
$goodsSelWin.find('.addcart').addClass('none');
|
|
|
$goodsSelWin.find('.btn_sellout').removeClass('none');
|
...
|
...
|
@@ -170,7 +176,7 @@ var GoodsWinAction = { |
|
|
}
|
|
|
});
|
|
|
},
|
|
|
selSize: function () {
|
|
|
selSize: function() {
|
|
|
|
|
|
var $this = $(this);
|
|
|
|
...
|
...
|
@@ -188,7 +194,7 @@ var GoodsWinAction = { |
|
|
$goodsSelWin.find('.btn_sellout').removeClass('none');
|
|
|
}
|
|
|
},
|
|
|
changeNum: function () {
|
|
|
changeNum: function() {
|
|
|
|
|
|
var $this = $(this);
|
|
|
var $pinfo = $this.closest('.product-detail-info');
|
...
|
...
|
@@ -220,13 +226,14 @@ var GoodsWinAction = { |
|
|
}
|
|
|
|
|
|
},
|
|
|
add2Cart: function () {
|
|
|
add2Cart: function() {
|
|
|
|
|
|
var $this = $(this);
|
|
|
var $curSize = $goodsSelWin.find('[data-role=sizes] .size-row:not(.none) .active');
|
|
|
var $num = $goodsSelWin.find('#num');
|
|
|
var allNum = $curSize.data('num');
|
|
|
var sku = $curSize.data('sku');
|
|
|
var skn = $this.closest('.detail-goods').data('skn');
|
|
|
var promotionId = $this.closest('.product-detail-info').data('promotionid') || 0;
|
|
|
var isSwap = $this.closest('.product-detail-info').data('swap');
|
|
|
|
...
|
...
|
@@ -246,7 +253,7 @@ var GoodsWinAction = { |
|
|
|
|
|
// 替换促销商品
|
|
|
if (isSwap) {
|
|
|
capi.updateCartGiftItem(promotionId, newSkn, sku);
|
|
|
capi.updateCartGiftItem(promotionId, skn, sku);
|
|
|
} else {
|
|
|
capi.addcart({
|
|
|
productSku: sku,
|
...
|
...
|
@@ -259,16 +266,10 @@ var GoodsWinAction = { |
|
|
};
|
|
|
|
|
|
/** 弹窗事件绑定 **/
|
|
|
// 显示赠品
|
|
|
var giftBtn = ['[data-role=gift-view-btn]',
|
|
|
'[data-role=gift-resel-btn]',
|
|
|
'[data-role=gift-sel-btn]',
|
|
|
'[data-role=pg-sel-btn]',
|
|
|
'[data-role=pg-resel-btn]'];
|
|
|
|
|
|
$payWapper./* find('li[data-role="pitem"]').*/on('click', giftBtn.join(','), GoodsWinAction.showGiftWin);
|
|
|
|
|
|
$goodsSelWin.on('click', '.close', GoodsWinAction.closeWin);
|
|
|
// $goodsSelWin.on('click', '.close', GoodsWinAction.closeWin);
|
|
|
$goodsSelWin.on('click', '.slide-img .img-list .img-item', GoodsWinAction.changeGoods);
|
|
|
$goodsSelWin.on('click', '.piclist li', GoodsWinAction.selThumb);
|
|
|
$goodsSelWin.on('click', '.pre, .next', GoodsWinAction.selThumbPrevNext);
|
...
|
...
|
|