Authored by 刘传洋

m

... ... @@ -29,7 +29,7 @@ const getProductInfo = (req, res, next) => {
const getProductData = (req, res, next) => {
let pid = req.query.productId || '';
service.getProductInfoAsync(pid).then((result) => {
service.getProductInfoAsync(pid, req.user.uid).then((result) => {
return res.send(result);
}).catch(next);
};
... ...
... ... @@ -537,6 +537,16 @@ const checkUserIsFavProductList = (uid, pidList) => {
});
};
const checkProductIsFav = (uid, pid) => {
return api.get('', {
method: 'app.favorite.isFavorite',
id: pid,
uid: uid,
type: 'product'
});
};
/**
* 个人中心页面优选新品数据
*
... ... @@ -662,6 +672,7 @@ module.exports = {
savePrePayInfo,
addTicket,
checkUserIsFavProductList,
checkProductIsFav,
newPreference,
modifyProduct,
swapGift,
... ...
... ... @@ -347,7 +347,7 @@ const _detailDataPkg = (origin) => {
/**
* 获取某一个商品详情主页面
*/
const getProductInfoAsync = (pid) => {
const getProductInfoAsync = (pid, uid) => {
return co(function * () {
if (!pid) {
return {};
... ... @@ -373,7 +373,17 @@ const getProductInfoAsync = (pid) => {
let productInfo = requestData[1];
let intro = _getIntroInfo(productSkn, productDescription);
return Object.assign(productInfo, intro);
let isFav = false;
if(uid) {
let isFavRet = yield cartApi.checkProductIsFav(uid, pid);
if(isFavRet && isFavRet.code === 200) {
isFav = isFavRet.data;
}
}
return Object.assign({ isFav: isFav }, productInfo, intro);
})();
};
... ... @@ -750,6 +760,18 @@ const checkUserIsFav = (uid, skuList) => {
};
/**
* 检查用户是否收藏这一批商品
*
* @param int $uid 用户ID
* @param array $skuList 商品SKU列表
* @return array
*/
const checkProductIsFav = (uid, pid) => {
return cartApi.checkProductIsFav(uid, pid);
};
/**
* 获取为你优选商品 待处理
*
* @param $channel 频道
... ... @@ -966,7 +988,7 @@ const queryUserPromotionGift = (promotionId, uid, shoppingKey) => {
// 获取选中商品的数据详情
if (currentProduct && currentProduct.id) {
promotionGifts.data.productInfo = yield getProductInfoAsync(currentProduct.id);
promotionGifts.data.productInfo = yield getProductInfoAsync(currentProduct.id, uid);
// 价格为活动价
if (promotionGifts.data.productInfo) {
... ... @@ -989,6 +1011,7 @@ module.exports = {
removeFromCart,
addToFav,
checkUserIsFav,
checkProductIsFav,
getRecommendProduct,
getTogetherProduct,
modifyProduct,
... ...
... ... @@ -38,7 +38,8 @@
<div class="product-detail-info"
data-promotionid="{{promotionId}}"
data-maxselectnum="{{maxSelectNumber}}"
{{#if swap}}data-swap="{{swap}}"{{/if}}>
{{#if isSwap}}data-isswap="{{isSwap}}"{{/if}}
{{#if isView}}data-isview="{{isView}}"{{/if}}>
{{#productInfo}}
{{> cart-product-info-tpl}}
{{/productInfo}}
... ...
... ... @@ -76,7 +76,7 @@
{{/each}}
</div>
{{/each}}
<p class="size-p-tip"><i class="iconfont">&#xe6c2;</i>请选择尺码</p>
<p class="size-p-tip" style="display:none;"><i class="iconfont">&#xe6c2;</i>请选择尺码</p>
<!--<p class="size-p">内长&nbsp;25.5com</p>-->
</dt>
</dl>
... ... @@ -92,13 +92,24 @@
</dl>
</div>
<div class="submit">
<button class="btn-red addcart"><i class="addCart iconfont">&#xe600;</i>添加到购物车</button>
<button class="addcart btn-grey"><i class="addCart iconfont">&#xe600;</i>添加到购物车</button>
<button class="btn-sellOut btn-grey"><i class="sellOut iconfont">&#xe6ba;</i>已售罄</button>
<button class="btn-favCount"><i class="favCount iconfont">&#xe68f;</i>收藏商品</button>
<button class="btn-favCount"><i class="favCount iconfont coled">&#xe68f;</i>已收藏</button>
{{#unless isView}}
<button class="btn-red addcart"><i class="addCart iconfont">&#xe600;</i>添加到购物车</button>
{{/unless}}
{{#if isView}}
<button class="addcart btn-grey"><i class="addCart iconfont">&#xe600;</i>添加到购物车</button>
{{/if}}
<button class="btn-sellOut btn-grey" style="display:none;">
<i class="sellOut iconfont">&#xe6ba;</i>已售罄
</button>
{{#if isFav}}
<button class="btn-favCount"><i class="favCount iconfont coled">&#xe68f;</i>已收藏</button>
{{else}}
<button class="btn-favCount"><i class="favCount iconfont">&#xe68f;</i>收藏商品</button>
{{/if}}
</div>
<p class="submit-tip">未满足活动条件</p>
{{#if isView}}
<p class="submit-tip">未满足活动条件</p>
{{/if}}
</div>
<div class="detail-size">
<h3>尺码信息<span>(单位:厘米)</span></h3>
... ...
... ... @@ -34,6 +34,7 @@ GoodsWinAction = {
var promotionInfo = $wrap.data('_promotionInfo');
var role = $this.data('role');
var isSwap = role === 'pg-resel-btn' || role === 'gift-resel-btn';
var isView = role === 'gift-view-btn';
var $selectedItem;
var selectedSkn;
... ... @@ -63,6 +64,7 @@ GoodsWinAction = {
promotionInfo = pinfo.data;
promotionInfo.isSwap = isSwap;
promotionInfo.isView = isView;
if (selectedSkn) {
promotionInfo.selectedSkn = selectedSkn;
}
... ... @@ -101,6 +103,8 @@ GoodsWinAction = {
}
}
res.isView = $this.closest('.detail-body').find('.product-detail-info').data('isview');
$goodsSelWin.find('.product-detail-info').empty().append(productInfoTpl(res));
});
},
... ... @@ -187,13 +191,14 @@ GoodsWinAction = {
$this.siblings('span').removeClass('active');
$this.addClass('active');
$this.closest('[data-role=sizes]').find('.size-p-tip').hide();
if (shopNumAll > 0) {
$goodsSelWin.find('.addcart').removeClass('none');
$goodsSelWin.find('.btn_sellout').addClass('none');
$goodsSelWin.find('.btn-sellOut').addClass('none');
} else {
$goodsSelWin.find('.addcart').addClass('none');
$goodsSelWin.find('.btn_sellout').removeClass('none');
$goodsSelWin.find('.btn-sellOut').removeClass('none');
}
},
changeNum: function() {
... ... @@ -237,10 +242,11 @@ GoodsWinAction = {
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');
var isSwap = $this.closest('.product-detail-info').data('isswap');
if ($curSize.length <= 0) {
new Alert('请选择尺码').show();
$this.closest('.detail-info').find('.size-p-tip').show();
// new Alert('请选择尺码').show();
return false;
}
... ...