Authored by 刘传洋

m

... ... @@ -352,11 +352,20 @@ const swapGift = (req, res, next) => {
}).catch(next);
};
const queryPromotionGift = (req, res, next) => {
/**
* 查询优惠可选择的商品,
* 根据用户购物车数据标记是否选中
* @param req
* @param res
* @param next
*/
const queryUserPromotionGift = (req, res, next) => {
let uid = req.user && req.user.uid;
let shoppingKey = helper.getShoppingKeyByCookie(req);
let promotionId = req.query.promotionId;
service.queryPromotionGift(promotionId)
service.queryUserPromotionGift(promotionId, uid, shoppingKey)
.then(ret => {
res.send(ret);
}).catch(next);
... ... @@ -379,5 +388,5 @@ module.exports = {
getIncreasePurchase,
modifyProduct,
swapGift,
queryPromotionGift
queryUserPromotionGift
};
... ...
... ... @@ -74,7 +74,8 @@ const formatCartGoods = (cartGoods, isAdvanceCart, inValid, isOffShelves, analys
yohoIcon: it.get_yoho_coin || 0,
productSubtotal: transPrice(it.last_vip_price * it.buy_number),
promotionId: it.promotion_id || 0,
isLimitSkn: it.is_limit_skn === 'Y' // is_limit_skn=Y 不支持7天无理由退货
isLimitSkn: it.is_limit_skn === 'Y', // is_limit_skn=Y 不支持7天无理由退货
isAdvance: isAdvanceCart
};
... ... @@ -214,70 +215,77 @@ const formatSoldOuts = (soldOutsList, isAdvanceCart, analysis) => {
};
/**
* 可选加价购
* isGift 是否是赠品:true-赠品
* 格式化单个加价购商品
*/
const formatPriceGifts = (giftList, isGift) => {
const formatPriceGiftOne = (it) => {
let gift = {
// isShowGift: isGift, // 控制是否显示赠品
// isFold: true, // 控制是否[展开]
promotionId: it.promotion_id,
promotionTitle: it.promotion_title.replace('¥', '¥'), // + '(注:您看到的商品可能因为下单时间差已售完)', // subjoinType
maxSelectNumber: it.max_select_number,
promotionType: it.promotion_type,
tag: PROMOTION_TYPE_TAG_MAP[it.promotion_type],
isGift: 'Gift' === it.promotion_type,
isPriceGift: 'Needpaygift' === it.promotion_type
};
return _.map(giftList, (it) => {
gift.goodsList = _.map(it.goods_list, (g) => {
let gift = {
isShowGift: isGift, // 控制是否显示赠品
isFold: true, // 控制是否[展开]
promotionId: it.promotion_id,
promotionTitle: it.promotion_title.replace('¥', '¥') + '(注:您看到的以下商品可能因为下单时间差已售完)', // subjoinType
maxSelectNumber: it.max_select_number,
promotionType: it.promotion_type
let goods = {
id: g.product_id,
skn: g.product_skn,
subjoinTitle: g.product_name,
imgCover: it.goods_images ? helpers.image(it.goods_images, 60, 60) : '',
subjoinPrice: transPrice(g.last_price),
marketPrice: gift.isGift ? '' : transPrice(g.market_price),
yohoIcon: 0,
isGift: gift.isGift,
isPriceGift: gift.isPriceGift
};
gift.goodsList = _.map(it.goods_list, (g) => {
// 商品链接
if (g.goods_id) {
let cnAlphaBet = g.cn_alphabet ? g.cn_alphabet : md5(g.product_name);
let goods = {
id: g.product_id,
skn: g.product_skn,
subjoinTitle: g.product_name,
imgCover: it.goods_images ? helpers.image(it.goods_images, 60, 60) : '',
subjoinPrice: transPrice(g.last_price),
marketPrice: isGift ? '' : transPrice(g.market_price),
yohoIcon: 0
};
goods.subjoinLink = helpers.urlFormat(`/product/pro_${g.product_id}_${g.goods_id}/${cnAlphaBet}.html`,
null, 'item');
} else {
let uri = `/product/show_${g.product_id}_${g.product_skn}/${makeToken(g.product_skn)}.html`;
// 商品链接
if (g.goods_id) {
let cnAlphaBet = g.cn_alphabet ? g.cn_alphabet : md5(g.product_name);
goods.subjoinLink = helpers.urlFormat(uri, null, 'item');
}
goods.subjoinLink = helpers.urlFormat(`/product/pro_${g.product_id}_${g.goods_id}/${cnAlphaBet}.html`,
null, 'item');
} else {
let uri = `/product/show_${g.product_id}_${g.product_skn}/${makeToken(g.product_skn)}.html`;
return goods;
});
goods.subjoinLink = helpers.urlFormat(uri, null, 'item');
}
return gift;
};
// 赠品
if (isGift) {
goods.isGift = true;
} else { // 加价购
goods.isPriceGift = true;
}
/**
* 可选加价购
* isGift 是否是赠品:true-赠品
*/
const formatPriceGifts = (giftList) => {
return goods;
});
return _.map(giftList, (it) => {
return formatPriceGiftOne(it);
});
};
/**
* 购物车赠品
*/
const formatGifts = (giftList) => {
return formatPriceGifts(giftList, true);
};
/*const formatGifts = (giftList) => {
return formatPriceGifts(giftList);
};*/
const checkGoodsIsSel = (goodsList, promotionId, giftsList, pricesGifts) => {
const checkGoodsIsSel = (goodsList, promotionId, selectedGiftsList) => {
return _.map(goodsList, goods => {
_.forEach((giftsList || []).concat(pricesGifts), gift => {
_.forEach((selectedGiftsList || []), gift => {
if (goods.id === gift.id && promotionId === gift.promotionId) {
goods.isCheckedGift = true;
... ... @@ -292,69 +300,76 @@ const checkGoodsIsSel = (goodsList, promotionId, giftsList, pricesGifts) => {
};
/**
* 优惠池头部优惠信息列表
* 格式化promotion 里的数据
*/
const formatPoolPromotionInfos = (infoList, giftsList, priceGifts) => {
const formatPromotion = (it, selectedGiftsList) => {
let status = Number(it.status);
let info = {
status: status,
// "status": 0, // 状态 0 未满足 10 已满足 [20 售光 30 更换 ]
conditionUnit: it.condition_unit, // 0满足,1 件,2金额
conditionValue: it.condition_value,
giftPrice: it.gift_price, // 赠品或加价购商品价格
giftGoodsList: formatCartGoods(it.gift_goods_List), // 可供选择的赠品或加价购商品列表
promotionId: it.promotion_id, // 促销id
promotionTitle: it.promotion_title, // "已满足[满30减10-dev30]",
promotionType: it.promotion_type, // 促销类型
// list.yohobuy.com?pp_id=10408
promotionPageUrl: helpers.urlFormat('', { pp_id: it.promotion_id }, 'list'),
tag: PROMOTION_TYPE_TAG_MAP[it.promotion_type],
isGift: it.promotion_type === 'Gift',
isPriceGift: it.promotion_type === 'Needpaygift',
isNotReach: status === 0, // 未满足
isReach: status === 10, // 满足条件
isEmpty: status === 20, // 已售完
isSelected: status === 30 // 已选择,可更换
};
return _.map(infoList, it => {
// 判断赠品/加价购商品,是否被选中
info.giftGoodsList = checkGoodsIsSel(info.giftGoodsList, info.promotionId, selectedGiftsList);
let status = Number(it.status);
let info = {
status: status,
// "status": 0, // 状态 0 未满足 10 已满足 [20 售光 30 更换 ]
conditionUnit: it.condition_unit, // 0满足,1 件,2金额
conditionValue: it.condition_value,
giftPrice: it.gift_price, // 赠品或加价购商品价格
giftGoodsList: formatCartGoods(it.gift_goods_List), // 可供选择的赠品或加价购商品列表
promotionId: it.promotion_id, // 促销id
promotionTitle: it.promotion_title, // "已满足[满30减10-dev30]",
promotionType: it.promotion_type, // 促销类型
// list.yohobuy.com?pp_id=10408
promotionPageUrl: helpers.urlFormat('', { pp_id: it.promotion_id }, 'list'),
tag: PROMOTION_TYPE_TAG_MAP[it.promotion_type],
isGift: it.promotion_type === 'Gift',
isPriceGift: it.promotion_type === 'Needpaygift',
isNotReach: status === 0, // 未满足
isReach: status === 10, // 满足条件
isEmpty: status === 20, // 已售完
isSelected: status === 30 // 已选择,可更换
};
if (status === 0) {
let tipTxt = `差${ -1 * info.conditionValue}`;
// 判断赠品/加价购商品,是否被选中
info.giftGoodsList = checkGoodsIsSel(info.giftGoodsList, info.promotionId, giftsList, priceGifts);
if (info.conditionUnit === 1) {
tipTxt += '件';
} else if (info.conditionUnit === 2) {
tipTxt += '元';
}
if (status === 0) {
let tipTxt = `差${ -1 * info.conditionValue}`;
info.promotionTitle = tipTxt + info.promotionTitle;
} else if (status === 10) {
info.promotionTitle = '已满足' + info.promotionTitle;
}
if (info.conditionUnit === 1) {
tipTxt += '件';
} else if (info.conditionUnit === 2) {
tipTxt += '元';
}
if (info.giftGoodsList) {
info.giftGoodsListStr = JSON.stringify(info.giftGoodsList);
}
return info;
};
info.promotionTitle = tipTxt + info.promotionTitle;
} else if (status === 10) {
info.promotionTitle = '已满足' + info.promotionTitle;
}
/**
* 优惠池头部优惠信息列表
*/
const formatPoolPromotionInfos = (infoList, selectedGiftsList) => {
if (info.giftGoodsList) {
info.giftGoodsListStr = JSON.stringify(info.giftGoodsList);
}
return info;
return _.map(infoList, it => {
return formatPromotion(it, selectedGiftsList);
});
};
/**
* 格式化子优惠池信息,返回商品列表,子优惠列表放在每个商品中
*/
const formatSubPromotionPools = (pools, gifts, priceGifts) => {
const formatSubPromotionPools = (pools, selectedGiftsList) => {
let goodsListPool = _.map(pools, p => {
let pool = {
goodsList: formatCartGoods(p.goods_list),
promotionInfos: formatPoolPromotionInfos(p.promotion_list, gifts, priceGifts)
promotionInfos: formatPoolPromotionInfos(p.promotion_list, selectedGiftsList)
};
let goodsList = pool.goodsList;
... ... @@ -377,18 +392,18 @@ const formatSubPromotionPools = (pools, gifts, priceGifts) => {
* giftsList, priceGifts 已选择的赠品和加价购,判断可选的赠品和加价购是否被选中
* 优惠池
*/
const formatPromotionPools = (pools, giftsList, priceGifts) => {
const formatPromotionPools = (pools, selectedGiftsList) => {
return _.map(pools, p => {
let pool = {
poolTitle: p.pool_title,
poolType: p.pool_type,
goodsList: formatCartGoods(p.goods_list),
promotionInfos: formatPoolPromotionInfos(p.promotion_list, giftsList, priceGifts)
promotionInfos: formatPoolPromotionInfos(p.promotion_list, selectedGiftsList)
};
if (p.sub_pool) {
let goodsWithPromotion = formatSubPromotionPools(p.sub_pool, giftsList, priceGifts);
let goodsWithPromotion = formatSubPromotionPools(p.sub_pool, selectedGiftsList);
if (_.isArray(goodsWithPromotion) && goodsWithPromotion.length) {
pool.goodsList = goodsWithPromotion.concat(pool.goodsList);
... ... @@ -403,9 +418,11 @@ module.exports = {
transPrice,
getShoppingKeyByCookie,
formatCartGoods,
formatGifts,
// formatGifts,
formatPriceGiftOne,
formatPriceGifts,
formatShoppingCartData,
formatPromotion,
formatPromotionPools,
formatPromotionInfos,
formatOffShelves,
... ...
... ... @@ -423,19 +423,24 @@ const getCartData = (uid, shoppingKey, cartDelList) => {
stat: chelper.formatShoppingCartData(_.get(advCartData, 'shopping_cart_data'))
};
let giftsList = chelper.formatGifts(_.get(ordCartData, 'gift_list'));
let giftsList = chelper.formatPriceGifts(_.get(ordCartData, 'gift_list'));
let priceGifts = chelper.formatPriceGifts(_.get(ordCartData, 'price_gift'));
let goodsList = chelper.formatCartGoods(_.get(ordCartData, 'goods_list'), false, false, false, analysisData);
result.ordinaryCart = {
// 全场可选的赠品
gifts: giftsList, // chelper.formatGifts(_.get(ordCartData, 'gift_list')),
// 全场可选的加价购商品列表
priceGifts: priceGifts, // chelper.formatPriceGifts(_.get(ordCartData, 'price_gift')),
// 已选择的全场加价购和赠品
goodsList: goodsList,
pools: chelper.formatPromotionPools(_.get(ordCartData, 'goods_pool_list'), goodsList),
// 未参加活动的商品
goodsList: chelper.formatCartGoods(_.get(ordCartData, 'goods_list'), false, false, false, analysisData),
pools: chelper.formatPromotionPools(_.get(ordCartData, 'goods_pool_list'), giftsList, priceGifts),
offShelves: chelper.formatOffShelves(_.get(ordCartData, 'off_shelves_goods_list'), false, analysisData),
soldOuts: chelper.formatSoldOuts(_.get(ordCartData, 'sold_out_goods_list'), false, analysisData),
priceGifts: priceGifts, // chelper.formatPriceGifts(_.get(ordCartData, 'price_gift')),
promotionInfos: chelper.formatPromotionInfos(_.get(ordCartData, 'promotion_info'), giftsList, priceGifts),
promotionInfos: chelper.formatPromotionInfos(_.get(ordCartData, 'promotion_info'), goodsList),
stat: chelper.formatShoppingCartData(_.get(ordCartData, 'shopping_cart_data'))
};
... ... @@ -451,6 +456,13 @@ const getCartData = (uid, shoppingKey, cartDelList) => {
result.ordinaryCart = false;
}
// promotionInfos, gifts, priceGifts 放一起展示
let hasGifts = result.ordinaryCart.gifts && result.ordinaryCart.gifts.length;
let hasPrices = result.ordinaryCart.priceGifts && result.ordinaryCart.priceGifts.length;
let hasPromo = result.ordinaryCart.promotionInfos && result.ordinaryCart.promotionInfos.length;
result.ordinaryCart.hasGlobalBlock = hasGifts || hasPrices || hasPromo;
result.stat = {
orderAmount: _.get(advStat, 'orderAmount', 0) + _.get(ordStat, 'orderAmount', 0),
discountAmount: _.get(advStat, 'discountAmount', 0) + _.get(ordStat, 'discountAmount', 0),
... ... @@ -829,8 +841,37 @@ const swapGift = (uid, shoppingKey, promotionId, newSkn, newSku) => {
return cartApi.swapGift(uid, shoppingKey, promotionId, newSkn, newSku);
};
const queryPromotionGift = (promotionId) => {
return cartApi.queryPromotionGift(promotionId);
const queryUserPromotionGift = (promotionId, uid, shoppingKey) => {
return co(function * () {
let promotionGifts = yield cartApi.queryPromotionGift(promotionId);
let cartDataRet = yield cartApi.cartData(uid, shoppingKey);
let selectedGift = chelper.formatCartGoods(_.get(cartDataRet, 'data.ordinary_cart_data.goods_list'));
if(promotionGifts && promotionGifts.code === 200) {
promotionGifts.data = chelper.formatPriceGiftOne(promotionGifts.data);
// 处理是否选中状态
if(selectedGift && selectedGift.length) {
_.forEach(promotionGifts.data.goodsList, (it) => {
var isSelected = false;
_.forEach(selectedGift, sg => {
if(it.skn === sg.skn) {
isSelected = true;
return true;
}
});
it.isSelected = isSelected;
});
}
}
return promotionGifts;
})();
};
module.exports = {
... ... @@ -846,5 +887,5 @@ module.exports = {
getRecommendProduct,
modifyProduct,
swapGift,
queryPromotionGift
queryUserPromotionGift
};
... ...
... ... @@ -41,6 +41,6 @@ router.post('/index/fav', cart.moveToFav);
router.post('/index/checkFav', cart.checkFav);
router.get('/index/getProductData', cart.getProductData);
router.post('/index/swapGift', cart.swapGift);
router.get('/index/queryPromotionGift', cart.queryPromotionGift);
router.get('/index/queryPromotionGift', cart.queryUserPromotionGift);
module.exports = router;
... ...
... ... @@ -167,12 +167,6 @@
{{/if}}
{{/pools}}
<!--可选的加价购商品 -->
<!--priceGifts-->
<!--可选择的赠品-->
<!--gifts-->
<!-- -->
{{#if offShelves}}
<div class="cart-table">
<ul class="table">
... ... @@ -205,11 +199,67 @@
</div>
{{/if}}
{{#if promotionInfos}}
<!--可选的加价购商品 -->
<!--priceGifts-->
<!--可选择的赠品-->
<!--gifts-->
{{#if hasGlobalBlock}}
<div class="gift-sell mt20">
{{#gifts}}
<div class="gift-sell-info"
data-role="promotion-wrap"
data-promotionid="{{promotionId}}">
<code class="order-pay-mark order-pay-mark-white">
{{tag}}
</code>{{promotionTitle}}
{{#if isGift}}
<a class="order-pay-link" href="javascript:void(0);"
data-role="gift-sel-btn">领赠品</a>
{{/if}}
{{#if isPriceGift}}
<a href="javascript:void(0);"
class="order-pay-link"
data-role="pg-sel-btn">去换购</a>
<a class="btn-clear blue order-pay-link" target="_blank" href="{{promotionPageUrl}}">去凑单&nbsp;></a>
{{/if}}
{{!--{{> cart-sel-gift-tpl }}--}}
{{!--<textarea data-role="gifts-cansel" class="hide" data-promotionid="{{promotionId}}">{{{giftGoodsListStr}}}</textarea>--}}
</div>
{{/gifts}}
{{#priceGifts}}
<div class="gift-sell-info"
data-role="promotion-wrap"
data-promotionid="{{promotionId}}">
<code class="order-pay-mark">
{{tag}}
</code>{{promotionTitle}}
{{#if isGift}}
<a class="order-pay-link" href="javascript:void(0);"
data-role="gift-sel-btn">领赠品</a>
{{/if}}
{{#if isPriceGift}}
<a href="javascript:void(0);"
class="order-pay-link"
data-role="pg-sel-btn">去换购</a>
<a class="btn-clear blue order-pay-link" target="_blank" href="{{promotionPageUrl}}">去凑单&nbsp;></a>
{{/if}}
{{!--{{> cart-sel-gift-tpl }}--}}
{{!--<textarea data-role="gifts-cansel" class="hide" data-promotionid="{{promotionId}}">{{{giftGoodsListStr}}}</textarea>--}}
</div>
{{/priceGifts}}
{{#promotionInfos}}
<p class="gift-sell-info"><code>{{tag}}</code>{{promotionTitle}}<a class="btn-clear blue"
data-together-id="6">去凑单&nbsp;&gt;</a>
<p class="gift-sell-info"><code>{{tag}}</code>{{promotionTitle}}
<a class="btn-clear blue" data-together-id="6">去凑单&nbsp;&gt;</a>
</p>
{{/promotionInfos}}
</div>
... ...
... ... @@ -13,7 +13,7 @@
{{#if isChecked}}checked{{/if}}></i>
<a class="pay-pro-icon" href="{{link}}" target="_blank">
<img src="{{imgCover}}">
<span class="incentive red">预售</span>
{{#if isAdvance}}<span class="incentive red">预售</span>{{/if}}
</a>
<p class="pay-pro-info">
<a href="{{link}}" target="_blank">{{productTitle}}</a>
... ...
<div class="detail-body">
<div class="slide-img">
<p class="sell-class-title">选赠品:
<em class="slide-img-title"><span
class="active">1元加价购</span>
<code class="spacing">|</code>
<p class="sell-class-title"><!--选赠品:-->
<em class="slide-img-title">
<span class="active">{{promotionTitle}}</span>
<!--<code class="spacing">|</code>
<span>59元加价购</span>
<code class="spacing">|</code>
<span>99元加价购</span>
<span>99元加价购</span>-->
</em>
</p>
<div class="side-img-dd">
<ul class="img-list">
{{#each giftGoodsList}}
<li class="img-item">
{{#each goodsList}}
<li class="img-item"
data-id="{{id}}"
data-skn="{{skn}}"
data-ispricegift="{{isPriceGift}}"
data-isgift="{{isGift}}">
<span class="hide goods-id">{{goods_id}}</span>
<div class="good">
<a href="javascript:void(0)" target="_blank"> {{!--{{link}}--}}
... ... @@ -28,159 +32,5 @@
</div>
</div>
</div>
<div class="detail-goods">
<div class="detail-bigpic">
<div class="bigpic">
<img src="">
</div>
<div class="bigpic none">
<img src="">
</div>
<div class="bigpic none">
<img src="">
</div>
<div class="bigpic none">
<img src="">
</div>
<div class="bigpic none">
<img src="">
</div>
<div class="bigpic none">
<img src="">
</div>
<div class="piclist">
<span class="pre"></span>
<div class="con">
<ul>
<li class="active"><img src=""></li>
<li><img src=""></li>
<li><img src=""></li>
<li><img src=""></li>
<li><img src=""></li>
</ul>
</div>
<span class="next"></span>
</div>
</div>
<div class="detail-bigpic none">
<div class="bigpic">
<img src="">
</div>
<div class="bigpic none">
<img src="">
</div>
<div class="bigpic none">
<img src="">
</div>
<div class="bigpic none">
<img src="">
</div>
<div class="bigpic none">
<img src="">
</div>
<div class="bigpic none">
<img src="">
</div>
<div class="piclist">
<span class="pre"></span>
<div class="con">
<ul>
<li class="active"><img src=""></li>
<li><img src=""></li>
<li><img src=""></li>
<li><img src=""></li>
<li><img src=""></li>
</ul>
</div>
<span class="next"></span>
</div>
</div>
<div class="detail-info">
<div class="title">
<h2>哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈{{name}}</h2>
</div>
<div class="price">
<span class="newprice">现价:<b class="promotion-price">¥7777{{salePrice}}</b></span>
<span class="activityprice">活动价:<b class="promotion-price">¥5555{{marketPrice}}</b></span>
</div>
<div class="order">
<dl>
<dd class="colorBox">选颜色:</dd>
<dt>
<div class="colorBox">
<ul>
<li class="color active">
<p class="{{#if focus}}atcive{{/if}}"><span></span><img src=""></p>
<span>{{name}}</span>
</li>
<li class="color">
<p class="{{#if focus}}atcive{{/if}}"><span></span><img src=""></p>
<span>{{name}}</span>
</li>
</ul>
</div>
</dt>
</dl>
<dl>
<dd class="showSizeBox">选尺码:</dd>
<dt>
<div class="showSizeBox">
<span data-sku="{{sku}}" data-num="{{num}}" class="disabled">40码{{name}}</span>
<span data-sku="{{sku}}" data-num="{{num}}">40码{{name}}</span>
<span data-sku="{{sku}}" data-num="{{num}}">40码{{name}}</span>
<span data-sku="{{sku}}" data-num="{{num}}">40码{{name}}</span>
</div>
<p class="size-p">内长&nbsp;25.5com</p>
</dt>
</dl>
<dl>
<dd>选件数:</dd>
<dt>
<div class="amount_wrapper">
<input type="text" id="num" class="num" value="1" readonly="readonly">
<a class="amount cut"><i class="iconfont">&#xe6c0;</i></a>
<a class="amount add"><i class="iconfont">&#xe6c1;</i></a>
</div>
</dt>
</dl>
</div>
<div class="submit">
<button class="btn-red"><i class="addCart iconfont">&#xe600;</i>添加到购物车</button>
<button class="btn-favCount"><i class="favCount iconfont">&#xe68f;</i>收藏商品</button>
</div>
</div>
<div class="detail-size">
<h3>尺码信息(单位:厘米)</h3>
<table>
<thead>
<tr>
<th width="{{width}}">吊牌吃吗</th>
<th width="{{width}}">吊牌吃吗
</td>
<th width="{{width}}">吊牌吃吗
</td>
<th width="{{width}}">吊牌吃吗
</td>
<th width="{{width}}">吊牌吃吗
</td>
<th width="{{width}}">吊牌吃吗
</td>
</tr>
</thead>
<tbody>
<tr>
<td>6666{{.}}</td>
</tr>
<tr>
<td>4444{{.}}</td>
</tr>
</tbody>
</table>
<div class="size-info">
※ 以上尺寸为实物实际测量,因测量方式不同会有略微误差,相关数据仅作参考,以收到实物为准。
</div>
</div>
</div>
<div class="product-detail-info"></div>
</div>
... ...
<div class="detail-goods">
<div class="detail-bigpic">
<div class="bigpic">
<img src="">
</div>
<div class="bigpic none">
<img src="">
</div>
<div class="bigpic none">
<img src="">
</div>
<div class="bigpic none">
<img src="">
</div>
<div class="bigpic none">
<img src="">
</div>
<div class="bigpic none">
<img src="">
</div>
<div class="piclist">
<span class="pre"></span>
<div class="con">
<ul>
<li class="active"><img src=""></li>
<li><img src=""></li>
<li><img src=""></li>
<li><img src=""></li>
<li><img src=""></li>
</ul>
</div>
<span class="next"></span>
</div>
</div>
<div class="detail-bigpic none">
<div class="bigpic">
<img src="">
</div>
<div class="bigpic none">
<img src="">
</div>
<div class="bigpic none">
<img src="">
</div>
<div class="bigpic none">
<img src="">
</div>
<div class="bigpic none">
<img src="">
</div>
<div class="bigpic none">
<img src="">
</div>
<div class="piclist">
<span class="pre"></span>
<div class="con">
<ul>
<li class="active"><img src=""></li>
<li><img src=""></li>
<li><img src=""></li>
<li><img src=""></li>
<li><img src=""></li>
</ul>
</div>
<span class="next"></span>
</div>
</div>
<div class="detail-info">
<div class="title">
<h2>{{name}}</h2>
</div>
<div class="price">
<span class="newprice">现价:<b class="promotion-price">{{salePrice}}</b></span>
<span class="activityprice">活动价:<b class="promotion-price">{{marketPrice}}</b></span>
</div>
<div class="order">
<dl>
<dd class="colorBox">选颜色:</dd>
<dt>
<div class="colorBox">
<ul>
{{#each colors}}
<li class="color active">
<p class="{{#if focus}}atcive{{/if}}">
<span></span>
<img src="{{src}}">
</p>
<span>{{name}}</span>
</li>
{{/each}}
</ul>
</div>
</dt>
</dl>
<dl>
<dd class="showSizeBox">选尺码:</dd>
<dt>
{{#each colors}}
<div class="showSizeBox">
{{#each size}}
<span data-sku="{{sku}}" data-num="{{num}}" class="disabled">{{name}}</span>
{{/each}}
</div>
{{/each}}
<!--<p class="size-p">内长&nbsp;25.5com</p>-->
</dt>
</dl>
<dl>
<dd>选件数:</dd>
<dt>
<div class="amount_wrapper">
<input type="text" id="num" class="num" value="1" readonly="readonly">
<a class="amount cut"><i class="iconfont">&#xe6c0;</i></a>
<a class="amount add"><i class="iconfont">&#xe6c1;</i></a>
</div>
</dt>
</dl>
</div>
<div class="submit">
<button class="btn-red"><i class="addCart iconfont">&#xe600;</i>添加到购物车</button>
<button class="btn-favCount"><i class="favCount iconfont">&#xe68f;</i>收藏商品</button>
</div>
</div>
<div class="detail-size">
<h3>尺码信息(单位:厘米)</h3>
<table>
<thead>
<tr>
<th width="{{width}}">吊牌吃吗</th>
<th width="{{width}}">吊牌吃吗
</td>
<th width="{{width}}">吊牌吃吗
</td>
<th width="{{width}}">吊牌吃吗
</td>
<th width="{{width}}">吊牌吃吗
</td>
<th width="{{width}}">吊牌吃吗
</td>
</tr>
</thead>
<tbody>
<tr>
<td>6666{{.}}</td>
</tr>
<tr>
<td>4444{{.}}</td>
</tr>
</tbody>
</table>
<div class="size-info">
※ 以上尺寸为实物实际测量,因测量方式不同会有略微误差,相关数据仅作参考,以收到实物为准。
</div>
</div>
</div>
... ...
... ... @@ -14,7 +14,8 @@ var $cartnewTips = $('.cartnew-tips'),
CART_ITEM_DEL_URL = '/cart/index/remove',
CART_ITEM_FAV_URL = '/cart/index/fav',
selColorWinTpl = require('hbs/cart/select-color-panel.hbs'),
giftsWinTpl = require('hbs/cart/cart-gifts-win-tpl.hbs');
giftsWinTpl = require('hbs/cart/cart-gifts-win-tpl.hbs'),
productInfoTpl = require('hbs/cart/cart-product-info-tpl.hbs');
// 关闭温馨提示
$cartnewTips.find('.btn_close').click(function() {
... ... @@ -308,6 +309,20 @@ function getProductByPromotionId(promotionId) {
});
}
function bindGiftWinAction($el) {
$el.on('click', '.slide-img .img-list .img-item', function(){
var id = $(this).data('id');
var skn = $(this).data('skn');
getProductInfo(id, skn).then(res => {
$el.find('.product-detail-info').empty().append(productInfoTpl(res));
});
});
};
function renderAndShowGiftWin(plist) {
var d = new Dialog({
... ... @@ -316,6 +331,8 @@ function renderAndShowGiftWin(plist) {
});
d.show();
bindGiftWinAction(d.$el);
}
var Cart = {
... ... @@ -632,25 +649,30 @@ var Cart = {
var $this = $(this);
var $wrap = $this.closest('[data-role="promotion-wrap"]');
var promotionid = $wrap.data('promotionid');
var productList = $wrap.data('_giftList');
var promotionInfo = $wrap.data('_promotionInfo');
console.log($this);
console.log($wrap);
console.log(promotionid);
if(!productList) {
getProductByPromotionId(promotionid).done(function(plist) {
if(!promotionInfo) {
getProductByPromotionId(promotionid).done(function(pinfo) {
productList = plist;
if(!pinfo && pinfo.code !== 200) {
return new Alert('获取商品失败,请稍后再试!').show();
}
promotionInfo = pinfo.data;
$wrap.data('_giftList', productList);
renderAndShowGiftWin(productList);
$wrap.data('_promotionInfo', promotionInfo);
renderAndShowGiftWin(promotionInfo);
}).fail(function() {
new Alert('获取商品失败,请稍后再试!').show();
});
return;
}
renderAndShowGiftWin(productList);
renderAndShowGiftWin(promotionInfo);
},
submit: function() {
/* understock = '';
... ... @@ -711,7 +733,6 @@ $payWapper.on('click', 'li[data-role="pitem"] .button-sure', Cart.editColorOrSiz
$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);
/** 赠品加价购弹窗 **/
// 显示赠品
var giftBtn = ['[data-role=gift-view-btn]',
... ... @@ -720,7 +741,7 @@ var giftBtn = ['[data-role=gift-view-btn]',
'[data-role=pg-sel-btn]',
'[data-role=pg-resel-btn]'];
$payWapper.on('click', giftBtn.join(','), Cart.showGiftWin);
$payWapper./*find('li[data-role="pitem"]').*/on('click', giftBtn.join(','), Cart.showGiftWin);
/*
$('.shop-cart').on('click', giftBtn.join(','), function() {
... ...