Authored by 刘传洋

m

... ... @@ -343,8 +343,8 @@ const swapGift = (req, res, next) => {
let shoppingKey = helper.getShoppingKeyByCookie(req);
let promotionId = req.body.promotionId;
let newSkn = req.body.new_skn;
let newSku = req.body.new_sku;
let newSkn = req.body.newSkn;
let newSku = req.body.newSku;
service.swapGift(uid, shoppingKey, promotionId, newSkn, newSku)
.then(ret => {
... ...
... ... @@ -627,7 +627,7 @@ const swapGift = (uid, shoppingKey, promotionId, newSkn, newSku) => {
};
/**
* 查询所有可选的赠品或者加价购的商品
* 查询所有可选的赠品或者加价购活动下的商品
* @param promotionId
* @returns {*}
*/
... ...
... ... @@ -18,6 +18,11 @@ const PROMOTION_TYPE_TAG_MAP = {
FreeShippingCost: '免运费'
};
const GOODS_TYPE_TAG_MAP = {
gift: '赠品',
price_gift: '加价购'
};
/**
* 从用户加入购物车的COOKIE取出购物车凭证
*/
... ... @@ -139,6 +144,8 @@ const formatCartGoods = (cartGoods, isAdvanceCart, inValid, isOffShelves, analys
}
}
goods.tag = GOODS_TYPE_TAG_MAP[it.goods_type];
// 商品类型:预售或普通
goods.goodsType = isAdvanceCart ? 'advance' : 'ordinary';
... ... @@ -324,7 +331,7 @@ const formatPromotion = (it, selectedGiftsList) => {
isGift: it.promotion_type === 'Gift',
isPriceGift: it.promotion_type === 'Needpaygift',
isNotReach: status === 0, // 未满足
isReach: status === 10, // 满足条件
isReach: status === 10 || status === 30, // 满足条件
isEmpty: status === 20, // 已售完
isSelected: status === 30 // 已选择,可更换
};
... ...
... ... @@ -188,17 +188,6 @@
</div>
{{/if}}
<!-- 全场已选择的 加价购+赠品 -->
{{#if goodsList}}
<div class="cart-table">
<ul class="table">
{{#each goodsList}}
{{> cart-item}}
{{/each}}
</ul>
</div>
{{/if}}
<!--可选的加价购商品 -->
<!--priceGifts-->
<!--可选择的赠品-->
... ... @@ -264,6 +253,16 @@
{{/promotionInfos}}
</div>
{{/if}}
<!-- 全场已选择的 加价购+赠品 -->
{{#if goodsList}}
<div class="cart-table">
<ul class="table">
{{#each goodsList}}
{{> cart-item}}
{{/each}}
</ul>
</div>
{{/if}}
{{/ordinaryCart}}
{{#stat}}
... ... @@ -375,6 +374,10 @@
{{/unless}}
<div class="loading"><span></span>请稍后...</div>
<div class="">
</div>
</div>
... ...
... ... @@ -6,7 +6,7 @@
{{#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}}
... ... @@ -15,7 +15,9 @@
<div class="con">
<ul>
{{#thumbs}}
<li><img src="{{img}}"></li>
<li {{#if @first}}class="active"{{/if}}>
<img src="{{img}}">
</li>
{{/thumbs}}
</ul>
</div>
... ...
... ... @@ -5,17 +5,25 @@
{{#if sku}}data-sku="{{sku}}"{{/if}}
{{#if productNum}}data-productnum="{{productNum}}"{{/if}}
{{#if goodsType}}data-goodstype="{{goodsType}}"{{/if}}
data-promotionid="{{promotionId}}"
data-color="{{productColor}}"
data-size="{{productSize}}">
data-size="{{productSize}}"
{{#if isGift}} data-isgift="true"{{/if}}
{{#if isPriceGift}}data-ispricegift="true"{{/if}} >
<div class="pay-pro td" style="width: 45%;">
<i class="cart-item-check iconfont {{#isChecked}}cart-item-checked{{/isChecked}}"
readonly="readonly" data-goodstype="{{goodsType}}"
{{#if isChecked}}checked{{/if}}></i>
{{#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}}
{{/unless}}
<a class="pay-pro-icon" href="{{link}}" target="_blank">
<img src="{{imgCover}}">
{{#if isAdvance}}<span class="incentive red">预售</span>{{/if}}
</a>
<p class="pay-pro-info">
{{#if tag}}<code class="order-pay-mark">{{tag}}</code>{{/if}}
<a href="{{link}}" target="_blank">{{productTitle}}</a>
<em class="pay-pro-detail"><span><b title="{{productColor}}">颜色:{{productColor}}</b> 尺码:{{productSize}}<i class="iconfont">&#xe6c7;</i></span></em>
</p>
... ...
... ... @@ -49,7 +49,7 @@
<dd class="colorBox">选颜色:</dd>
<dt>
<div class="colorBox">
<ul>
<ul data-role="colors">
{{#each colors}}
<li class="color"><!--active-->
<p class="{{#if focus}}active{{/if}}">
... ... @@ -62,12 +62,12 @@
</ul>
</div>
</dt>
<!-- </dl>
<dl>-->
</dl>
<dl>
<dd class="showSizeBox">选尺码:</dd>
<dt>
<dt data-role="sizes">
{{#each colors}}
<div class="showSizeBox">
<div class="showSizeBox size-row">
{{#each size}}
<span data-sku="{{sku}}" data-num="{{num}}">{{name}}</span>
{{/each}}
... ... @@ -75,8 +75,8 @@
{{/each}}
<!--<p class="size-p">内长&nbsp;25.5com</p>-->
</dt>
<!-- </dl>
<dl>-->
</dl>
<dl>
<dd>选件数:</dd>
<dt>
<div class="amount_wrapper">
... ... @@ -88,7 +88,7 @@
</dl>
</div>
<div class="submit">
<button class="btn-red"><i class="addCart iconfont">&#xe600;</i>添加到购物车</button>
<button class="btn-red addcart"><i class="addCart iconfont">&#xe600;</i>添加到购物车</button>
<button class="btn-favCount"><i class="favCount iconfont">&#xe68f;</i>收藏商品</button>
</div>
</div>
... ...
<div class="goods-choose-box">
<div class="goods-info">
<div class="goods-info" data-skn="{{skn}}">
<div class="dl choose-color">
<div class="dd">颜色:</div>
{{#each colors}}
... ...
... ... @@ -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) {
... ...
... ... @@ -11,6 +11,7 @@ var $ = require('yoho-jquery'),
require('../plugins/slider');
require('../common/center-slider');
require('../common');
var Dialog = dialog.Dialog,
... ... @@ -85,7 +86,7 @@ function cartDel(data, delUrl, cookieList) {
}
// 购物车表单 删除商品
$payWapper.on('click', '.cart-del-btn', function() {
/*$payWapper.on('click', '.cart-del-btn', function() {
// new Confirm({
// className: 'shopCart-del-dialog',
// content: '<h4><i class="iconfont">&#xe684;</i>删除商品</h4>' +
... ... @@ -102,7 +103,7 @@ $payWapper.on('click', '.cart-del-btn', function() {
}).fail();
}
);
});
});*/
// 凑单图片懒加载
var togetherDialog = {};
... ... @@ -205,7 +206,7 @@ $(function() {
// ----------------底部 为你优选,最近浏览 end--------------
// 凑单弹框 详情切换
/*$('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');
... ... @@ -317,7 +318,7 @@ $cartGoodsDetail.on('click', '.btn-favCount', function() {
// 购物车列表 赠品
// 购物车列表 显示
/*$('.shop-cart').on('click', '.gift-sell .btn-clear', function() {
/* $('.shop-cart').on('click', '.gift-sell .btn-clear', function() {
var tid = $(this).attr('data-together-id');
showPromotion(tid);
... ...