Authored by 刘传洋

m

... ... @@ -103,7 +103,7 @@ const formatCartGoods = (cartGoods, isAdvanceCart, inValid, isOffShelves, analys
// advanceBuy=>是否加价购,soldOut=>失效商品;
if (!it.goods_type) {
goods.inValid = true;
} else if (it.goods_type === 'gift' && it.isAdvanceBuy) { // gift=>是否赠品
} else if (it.goods_type === 'gift') { // gift=>是否赠品 && it.isAdvanceBuy
goods.isGift = true;
goods.productPrice = transPrice(it.last_price);
goods.productSubtotal = it.subtotal ? transPrice(it.subtotal) : goods.productPrice;
... ... @@ -372,11 +372,11 @@ const formatPoolPromotionInfos = (infoList, selectedGiftsList) => {
/**
* 格式化子优惠池信息,返回商品列表,子优惠列表放在每个商品中
*/
const formatSubPromotionPools = (pools, selectedGiftsList) => {
const formatSubPromotionPools = (pools, selectedGiftsList, isAdvance) => {
let goodsListPool = _.map(pools, p => {
let pool = {
goodsList: formatCartGoods(p.goods_list),
goodsList: formatCartGoods(p.goods_list, isAdvance),
promotionInfos: formatPoolPromotionInfos(p.promotion_list, selectedGiftsList)
};
... ... @@ -400,18 +400,18 @@ const formatSubPromotionPools = (pools, selectedGiftsList) => {
* giftsList, priceGifts 已选择的赠品和加价购,判断可选的赠品和加价购是否被选中
* 优惠池
*/
const formatPromotionPools = (pools, selectedGiftsList) => {
const formatPromotionPools = (pools, selectedGiftsList, isAdvance) => {
return _.map(pools, p => {
let pool = {
poolTitle: p.pool_title,
poolType: p.pool_type,
goodsList: formatCartGoods(p.goods_list),
goodsList: formatCartGoods(p.goods_list, isAdvance),
promotionInfos: formatPoolPromotionInfos(p.promotion_list, selectedGiftsList)
};
if (p.sub_pool) {
let goodsWithPromotion = formatSubPromotionPools(p.sub_pool, selectedGiftsList);
let goodsWithPromotion = formatSubPromotionPools(p.sub_pool, selectedGiftsList, isAdvance);
if (_.isArray(goodsWithPromotion) && goodsWithPromotion.length) {
pool.goodsList = goodsWithPromotion.concat(pool.goodsList);
... ...
... ... @@ -417,9 +417,11 @@ const getCartData = (uid, shoppingKey, cartDelList) => {
result.advanceCart = {
// 未参加活动的商品
goodsList: chelper.formatCartGoods(_.get(advCartData, 'goods_list'), true, false, false, analysisData),
// goodsList: chelper.formatCartGoods(_.get(advCartData, 'goods_list'), true, false, false, analysisData),
pools: chelper.formatPromotionPools(_.get(advCartData, 'goods_pool_list'), null, true),
offShelves: chelper.formatOffShelves(_.get(advCartData, 'off_shelves_goods_list'), true, analysisData),
soldOuts: chelper.formatSoldOuts(_.get(advCartData, 'sold_out_goods_list'), true, analysisData),
promotionInfos: chelper.formatPromotionInfos(_.get(advCartData, 'promotion_info')),
stat: chelper.formatShoppingCartData(_.get(advCartData, 'shopping_cart_data'))
};
... ...
... ... @@ -66,40 +66,54 @@
</div>
{{#advanceCart}}
<div class="mb20">
<!-- 预售商品 -->
<div class="pre-sell">
<code>预售商品</code>预售商品不参加活动,不可使用优惠券,不同上市期的商品我们将为您先到先发。
</div>
{{#if goodsList}}
<div class="cart-table">
<ul class="table table-group">
{{#each goodsList}}
{{>cart-item}}
{{/each}}
</ul>
<div class="pre-sell">
<code>预售商品</code>预售商品不参加活动,不可使用优惠券,不同上市期的商品我们将为您先到先发。
</div>
{{/if}}
{{#if offShelves}}
<div class="cart-table">
<ul class="table table-group">
{{#each offShelves}}
{{>cart-item}}
{{/each}}
</ul>
</div>
{{/if}}
{{#pools}}
{{#if goodsList}}
<div class="cart-table">
<ul class="table">
{{#goodsList}}
{{> cart-item}}
{{/goodsList}}
</ul>
</div>
{{/if}}
{{/pools}}
{{#if soldOuts}}
<div class="cart-table">
<ul class="table table-group">
{{#each soldOuts}}
{{>cart-item}}
{{/each}}
</ul>
</div>
{{/if}}
{{#if offShelves}}
<div class="cart-table">
<ul class="table table-group">
{{#each offShelves}}
{{>cart-item}}
{{/each}}
</ul>
</div>
{{/if}}
{{#if soldOuts}}
<div class="cart-table">
<ul class="table table-group">
{{#each soldOuts}}
{{>cart-item}}
{{/each}}
</ul>
</div>
{{/if}}
{{#if promotionInfos}}
<div class="gift-sell">
{{#promotionInfos}}
<p class="gift-sell-info"><code class="order-pay-mark">{{tag}}</code>{{promotionTitle}}
<!--<a class="btn-clear blue" data-together-id="6">去凑单&nbsp;&gt;</a>-->
</p>
{{/promotionInfos}}
</div>
{{/if}}
</div>
{{/advanceCart}}
{{#ordinaryCart}}
... ... @@ -116,34 +130,9 @@
{{tag}}
</code>{{promotionTitle}}
{{#if isGift}}
{{#if isNotReach}}
<a class="order-pay-link" href="javascript:void(0);"
data-role="gift-view-btn">查看赠品</a>{{/if}}
{{#if isSelected}}
<a class="order-pay-link" href="javascript:void(0);"
data-role="gift-resel-btn">重选赠品</a>
{{else}}
{{#if isReach}}
<a class="order-pay-link" href="javascript:void(0);"
data-role="gift-sel-btn">领赠品</a>{{/if}}
{{/if}}
{{/if}}
{{>cart-promotion-btn}}
{{#if isPriceGift}}
{{!--{{#if isNotReach}}
<a href="javascript:void(0);" data-role="gift-view-btn">查看赠品</a>
{{/if}}--}}
{{#if isSelected}}
<a href="javascript:void(0);"
class="order-pay-link"
data-role="pg-resel-btn">重新换购</a>
{{else}}
{{#if isReach}}<a href="javascript:void(0);"
class="order-pay-link"
data-role="pg-sel-btn">去换购</a>{{/if}}
{{/if}}
{{#if isNotReach}}
<a class="btn-clear blue order-pay-link" target="_blank" href="{{promotionPageUrl}}">去凑单&nbsp;></a>
{{/if}}
... ...
... ... @@ -6,7 +6,7 @@
{{#colors}}
<div class="detail-bigpic {{#unless focus}}none{{/unless}}">
{{#thumbs}}
<div class="bigpic" {{#unless @first}}style="display:none"{{/unless}}>
<div class="bigpic">
<img src="{{shower}}">
</div>
{{/thumbs}}
... ... @@ -15,7 +15,7 @@
<div class="con">
<ul>
{{#thumbs}}
<li {{#if @first}}class="active"{{/if}}>
<li>
<img src="{{img}}">
</li>
{{/thumbs}}
... ...
... ... @@ -12,11 +12,9 @@
{{#if isPriceGift}}data-ispricegift="true"{{/if}} >
<div class="pay-pro td" style="width: 45%;">
{{#unless isGift}}
{{#unless isPriceGift}}
<i class="cart-item-check iconfont {{#isChecked}}cart-item-checked{{/isChecked}}"
readonly="readonly" data-goodstype="{{goodsType}}"
{{#if isChecked}}checked{{/if}}></i>
{{/unless}}
<i class="cart-item-check iconfont {{#isChecked}}cart-item-checked{{/isChecked}}"
readonly="readonly" data-goodstype="{{goodsType}}"
{{#if isChecked}}checked{{/if}}></i>
{{/unless}}
<a class="pay-pro-icon" href="{{link}}" target="_blank">
<img src="{{imgCover}}">
... ... @@ -34,7 +32,9 @@
<span class="sale-info-title">促销信息<i></i></span>
<ul class="none">
{{#promotionInfos}}
<li>{{promotionTitle}}<a href="#">去换购</a></li>
<li>{{promotionTitle}}
{{>cart-promotion-btn}}
</li>
{{/promotionInfos}}
</ul>
</div>
... ...
{{#if isGift}}
{{#if isNotReach}}
<a class="order-pay-link" href="javascript:void(0);"
data-role="gift-view-btn">查看赠品</a>{{/if}}
{{#if isSelected}}
<a class="order-pay-link" href="javascript:void(0);"
data-role="gift-resel-btn">重选赠品</a>
{{else}}
{{#if isReach}}
<a class="order-pay-link" href="javascript:void(0);"
data-role="gift-sel-btn">领赠品</a>{{/if}}
{{/if}}
{{/if}}
{{#if isPriceGift}}
{{#if isSelected}}
<a href="javascript:void(0);"
class="order-pay-link"
data-role="pg-resel-btn">重新换购</a>
{{else}}
{{#if isReach}}
<a href="javascript:void(0);"
class="order-pay-link"
data-role="pg-sel-btn">去换购</a>
{{/if}}
{{/if}}
{{/if}}
... ...
... ... @@ -32,7 +32,7 @@
</div>
</div>
</div>
<div class="product-detail-info" data-promotionid="{{promotionId}}">
<div class="product-detail-info" data-promotionid="{{promotionId}}" {{#if swap}}data-swap="{{swap}}"{{/if}}>
{{#productInfo}}
{{> cart-product-info-tpl}}
{{/productInfo}}
... ...
<div class="detail-goods">
<div class="detail-goods" data-skn="{{skn}}">
{{#colors}}
<div class="detail-bigpic {{#unless focus}}none{{/unless}}">
{{#thumbs}}
<div class="bigpic">
<div class="bigpic" {{#unless @first}}style="display:none"{{/unless}}>
<img src="{{shower}}">
</div>
{{/thumbs}}
... ... @@ -12,7 +12,9 @@
<div class="con">
<ul>
{{#thumbs}}
<li><img src="{{img}}"></li>
<li {{#if @first}}class="active"{{/if}}>
<img src="{{img}}">
</li>
{{/thumbs}}
<!--<li class="active"><img src=""></li>-->
</ul>
... ...
... ... @@ -435,7 +435,6 @@ function bindGiftWinAction($el) {
var $this = $(this);
var idx = $this.index();
console.log(idx);
var $detail = $this.closest('.detail-goods');
var $sizes = $detail.find('[data-role=sizes] .size-row');
var $detailBigpic = $detail.find('.detail-bigpic');
... ... @@ -448,10 +447,9 @@ console.log(idx);
$this.siblings('.color').find('p').removeClass('active');
$this.find('p').addClass('active');
$sizes.addClass('none').eq(idx).removeClass('none');
// console.log($sizes.addClass('none').eq(idx));
$sizes.addClass('none');
$curSize.removeClass('none');
return;
if ($curSize.find('span').length < 2) {
$curSize.find('span:first').addClass('active');
}
... ... @@ -536,6 +534,7 @@ console.log(idx);
var allNum = $curSize.data('num');
var sku = $curSize.data('sku');
var promotionId = $this.closest('.product-detail-info').data('promotionid') || 0;
var isSwap = $this.closest('.product-detail-info').data('swap');
if ($curSize.length <= 0) {
new Alert('请选择尺码').show();
... ... @@ -551,11 +550,16 @@ console.log(idx);
new Alert('该商品无法加入购物车').show();
}*/
addcart({
productSku: sku,
buyNumber: $num.val(),
promotionId: promotionId
});
// 替换促销商品
if(isSwap) {
updateCartGiftItem(promotionId, newSkn, sku);
} else {
addcart({
productSku: sku,
buyNumber: $num.val(),
promotionId: promotionId
});
}
}
});
}
... ... @@ -848,7 +852,7 @@ var Cart = {
// 加价购更换
if($item.data('isgift') || $item.data('ispricegift')) {
return updateCartGiftItem(promotionId, newSkn,newSku);
return updateCartGiftItem(promotionId, newSkn, newSku);
}
updateCartItem(newSku, oldSku);
},
... ... @@ -893,10 +897,9 @@ var Cart = {
var $wrap = $this.closest('[data-role="promotion-wrap"]');
var promotionid = $wrap.data('promotionid');
var promotionInfo = $wrap.data('_promotionInfo');
var role = $this.data('role');
var isSwap = role === 'pg-resel-btn' || role === 'gift-resel-btn';
console.log($this);
console.log($wrap);
console.log(promotionid);
if (!promotionInfo) {
getProductByPromotionId(promotionid).done(function(pinfo) {
... ... @@ -906,6 +909,7 @@ var Cart = {
}
promotionInfo = pinfo.data;
promotionInfo.isSwap = isSwap;
$wrap.data('_promotionInfo', promotionInfo);
renderAndShowGiftWin(promotionInfo);
... ...
... ... @@ -348,7 +348,7 @@ function showPromotion(id) {
}*/
// 购物车列表 大小图切换
$('body').on('click', '.piclist li', function() {
/*$('body').on('click', '.piclist li', function() {
pacList = $(this).index();
$('.detail-bigpic:not(.none) .piclist li').removeClass('active');
$(this).addClass('active');
... ... @@ -431,7 +431,7 @@ $('body').on('click', '.cut, .add', function() {
$('#num').val(shopNum);
}
});
});*/
// 购物车列表 修改 显示隐藏
... ...