Authored by 刘传洋

m

@@ -29,7 +29,7 @@ const getProductInfo = (req, res, next) => { @@ -29,7 +29,7 @@ const getProductInfo = (req, res, next) => {
29 const getProductData = (req, res, next) => { 29 const getProductData = (req, res, next) => {
30 let pid = req.query.productId || ''; 30 let pid = req.query.productId || '';
31 31
32 - service.getProductInfoAsync(pid).then((result) => { 32 + service.getProductInfoAsync(pid, req.user.uid).then((result) => {
33 return res.send(result); 33 return res.send(result);
34 }).catch(next); 34 }).catch(next);
35 }; 35 };
@@ -537,6 +537,16 @@ const checkUserIsFavProductList = (uid, pidList) => { @@ -537,6 +537,16 @@ const checkUserIsFavProductList = (uid, pidList) => {
537 }); 537 });
538 }; 538 };
539 539
  540 +const checkProductIsFav = (uid, pid) => {
  541 +
  542 + return api.get('', {
  543 + method: 'app.favorite.isFavorite',
  544 + id: pid,
  545 + uid: uid,
  546 + type: 'product'
  547 + });
  548 +};
  549 +
540 /** 550 /**
541 * 个人中心页面优选新品数据 551 * 个人中心页面优选新品数据
542 * 552 *
@@ -662,6 +672,7 @@ module.exports = { @@ -662,6 +672,7 @@ module.exports = {
662 savePrePayInfo, 672 savePrePayInfo,
663 addTicket, 673 addTicket,
664 checkUserIsFavProductList, 674 checkUserIsFavProductList,
  675 + checkProductIsFav,
665 newPreference, 676 newPreference,
666 modifyProduct, 677 modifyProduct,
667 swapGift, 678 swapGift,
@@ -347,7 +347,7 @@ const _detailDataPkg = (origin) => { @@ -347,7 +347,7 @@ const _detailDataPkg = (origin) => {
347 /** 347 /**
348 * 获取某一个商品详情主页面 348 * 获取某一个商品详情主页面
349 */ 349 */
350 -const getProductInfoAsync = (pid) => { 350 +const getProductInfoAsync = (pid, uid) => {
351 return co(function * () { 351 return co(function * () {
352 if (!pid) { 352 if (!pid) {
353 return {}; 353 return {};
@@ -373,7 +373,17 @@ const getProductInfoAsync = (pid) => { @@ -373,7 +373,17 @@ const getProductInfoAsync = (pid) => {
373 let productInfo = requestData[1]; 373 let productInfo = requestData[1];
374 let intro = _getIntroInfo(productSkn, productDescription); 374 let intro = _getIntroInfo(productSkn, productDescription);
375 375
376 - return Object.assign(productInfo, intro); 376 + let isFav = false;
  377 +
  378 + if(uid) {
  379 + let isFavRet = yield cartApi.checkProductIsFav(uid, pid);
  380 +
  381 + if(isFavRet && isFavRet.code === 200) {
  382 + isFav = isFavRet.data;
  383 + }
  384 + }
  385 +
  386 + return Object.assign({ isFav: isFav }, productInfo, intro);
377 })(); 387 })();
378 }; 388 };
379 389
@@ -750,6 +760,18 @@ const checkUserIsFav = (uid, skuList) => { @@ -750,6 +760,18 @@ const checkUserIsFav = (uid, skuList) => {
750 }; 760 };
751 761
752 /** 762 /**
  763 + * 检查用户是否收藏这一批商品
  764 + *
  765 + * @param int $uid 用户ID
  766 + * @param array $skuList 商品SKU列表
  767 + * @return array
  768 + */
  769 +const checkProductIsFav = (uid, pid) => {
  770 +
  771 + return cartApi.checkProductIsFav(uid, pid);
  772 +};
  773 +
  774 +/**
753 * 获取为你优选商品 待处理 775 * 获取为你优选商品 待处理
754 * 776 *
755 * @param $channel 频道 777 * @param $channel 频道
@@ -966,7 +988,7 @@ const queryUserPromotionGift = (promotionId, uid, shoppingKey) => { @@ -966,7 +988,7 @@ const queryUserPromotionGift = (promotionId, uid, shoppingKey) => {
966 988
967 // 获取选中商品的数据详情 989 // 获取选中商品的数据详情
968 if (currentProduct && currentProduct.id) { 990 if (currentProduct && currentProduct.id) {
969 - promotionGifts.data.productInfo = yield getProductInfoAsync(currentProduct.id); 991 + promotionGifts.data.productInfo = yield getProductInfoAsync(currentProduct.id, uid);
970 992
971 // 价格为活动价 993 // 价格为活动价
972 if (promotionGifts.data.productInfo) { 994 if (promotionGifts.data.productInfo) {
@@ -989,6 +1011,7 @@ module.exports = { @@ -989,6 +1011,7 @@ module.exports = {
989 removeFromCart, 1011 removeFromCart,
990 addToFav, 1012 addToFav,
991 checkUserIsFav, 1013 checkUserIsFav,
  1014 + checkProductIsFav,
992 getRecommendProduct, 1015 getRecommendProduct,
993 getTogetherProduct, 1016 getTogetherProduct,
994 modifyProduct, 1017 modifyProduct,
@@ -38,7 +38,8 @@ @@ -38,7 +38,8 @@
38 <div class="product-detail-info" 38 <div class="product-detail-info"
39 data-promotionid="{{promotionId}}" 39 data-promotionid="{{promotionId}}"
40 data-maxselectnum="{{maxSelectNumber}}" 40 data-maxselectnum="{{maxSelectNumber}}"
41 - {{#if swap}}data-swap="{{swap}}"{{/if}}> 41 + {{#if isSwap}}data-isswap="{{isSwap}}"{{/if}}
  42 + {{#if isView}}data-isview="{{isView}}"{{/if}}>
42 {{#productInfo}} 43 {{#productInfo}}
43 {{> cart-product-info-tpl}} 44 {{> cart-product-info-tpl}}
44 {{/productInfo}} 45 {{/productInfo}}
@@ -76,7 +76,7 @@ @@ -76,7 +76,7 @@
76 {{/each}} 76 {{/each}}
77 </div> 77 </div>
78 {{/each}} 78 {{/each}}
79 - <p class="size-p-tip"><i class="iconfont">&#xe6c2;</i>请选择尺码</p> 79 + <p class="size-p-tip" style="display:none;"><i class="iconfont">&#xe6c2;</i>请选择尺码</p>
80 <!--<p class="size-p">内长&nbsp;25.5com</p>--> 80 <!--<p class="size-p">内长&nbsp;25.5com</p>-->
81 </dt> 81 </dt>
82 </dl> 82 </dl>
@@ -92,13 +92,24 @@ @@ -92,13 +92,24 @@
92 </dl> 92 </dl>
93 </div> 93 </div>
94 <div class="submit"> 94 <div class="submit">
95 - <button class="btn-red addcart"><i class="addCart iconfont">&#xe600;</i>添加到购物车</button>  
96 - <button class="addcart btn-grey"><i class="addCart iconfont">&#xe600;</i>添加到购物车</button>  
97 - <button class="btn-sellOut btn-grey"><i class="sellOut iconfont">&#xe6ba;</i>已售罄</button>  
98 - <button class="btn-favCount"><i class="favCount iconfont">&#xe68f;</i>收藏商品</button>  
99 - <button class="btn-favCount"><i class="favCount iconfont coled">&#xe68f;</i>已收藏</button> 95 + {{#unless isView}}
  96 + <button class="btn-red addcart"><i class="addCart iconfont">&#xe600;</i>添加到购物车</button>
  97 + {{/unless}}
  98 + {{#if isView}}
  99 + <button class="addcart btn-grey"><i class="addCart iconfont">&#xe600;</i>添加到购物车</button>
  100 + {{/if}}
  101 + <button class="btn-sellOut btn-grey" style="display:none;">
  102 + <i class="sellOut iconfont">&#xe6ba;</i>已售罄
  103 + </button>
  104 + {{#if isFav}}
  105 + <button class="btn-favCount"><i class="favCount iconfont coled">&#xe68f;</i>已收藏</button>
  106 + {{else}}
  107 + <button class="btn-favCount"><i class="favCount iconfont">&#xe68f;</i>收藏商品</button>
  108 + {{/if}}
100 </div> 109 </div>
101 - <p class="submit-tip">未满足活动条件</p> 110 + {{#if isView}}
  111 + <p class="submit-tip">未满足活动条件</p>
  112 + {{/if}}
102 </div> 113 </div>
103 <div class="detail-size"> 114 <div class="detail-size">
104 <h3>尺码信息<span>(单位:厘米)</span></h3> 115 <h3>尺码信息<span>(单位:厘米)</span></h3>
@@ -34,6 +34,7 @@ GoodsWinAction = { @@ -34,6 +34,7 @@ GoodsWinAction = {
34 var promotionInfo = $wrap.data('_promotionInfo'); 34 var promotionInfo = $wrap.data('_promotionInfo');
35 var role = $this.data('role'); 35 var role = $this.data('role');
36 var isSwap = role === 'pg-resel-btn' || role === 'gift-resel-btn'; 36 var isSwap = role === 'pg-resel-btn' || role === 'gift-resel-btn';
  37 + var isView = role === 'gift-view-btn';
37 var $selectedItem; 38 var $selectedItem;
38 var selectedSkn; 39 var selectedSkn;
39 40
@@ -63,6 +64,7 @@ GoodsWinAction = { @@ -63,6 +64,7 @@ GoodsWinAction = {
63 64
64 promotionInfo = pinfo.data; 65 promotionInfo = pinfo.data;
65 promotionInfo.isSwap = isSwap; 66 promotionInfo.isSwap = isSwap;
  67 + promotionInfo.isView = isView;
66 if (selectedSkn) { 68 if (selectedSkn) {
67 promotionInfo.selectedSkn = selectedSkn; 69 promotionInfo.selectedSkn = selectedSkn;
68 } 70 }
@@ -101,6 +103,8 @@ GoodsWinAction = { @@ -101,6 +103,8 @@ GoodsWinAction = {
101 } 103 }
102 } 104 }
103 105
  106 + res.isView = $this.closest('.detail-body').find('.product-detail-info').data('isview');
  107 +
104 $goodsSelWin.find('.product-detail-info').empty().append(productInfoTpl(res)); 108 $goodsSelWin.find('.product-detail-info').empty().append(productInfoTpl(res));
105 }); 109 });
106 }, 110 },
@@ -187,13 +191,14 @@ GoodsWinAction = { @@ -187,13 +191,14 @@ GoodsWinAction = {
187 191
188 $this.siblings('span').removeClass('active'); 192 $this.siblings('span').removeClass('active');
189 $this.addClass('active'); 193 $this.addClass('active');
  194 + $this.closest('[data-role=sizes]').find('.size-p-tip').hide();
190 195
191 if (shopNumAll > 0) { 196 if (shopNumAll > 0) {
192 $goodsSelWin.find('.addcart').removeClass('none'); 197 $goodsSelWin.find('.addcart').removeClass('none');
193 - $goodsSelWin.find('.btn_sellout').addClass('none'); 198 + $goodsSelWin.find('.btn-sellOut').addClass('none');
194 } else { 199 } else {
195 $goodsSelWin.find('.addcart').addClass('none'); 200 $goodsSelWin.find('.addcart').addClass('none');
196 - $goodsSelWin.find('.btn_sellout').removeClass('none'); 201 + $goodsSelWin.find('.btn-sellOut').removeClass('none');
197 } 202 }
198 }, 203 },
199 changeNum: function() { 204 changeNum: function() {
@@ -237,10 +242,11 @@ GoodsWinAction = { @@ -237,10 +242,11 @@ GoodsWinAction = {
237 var sku = $curSize.data('sku'); 242 var sku = $curSize.data('sku');
238 var skn = $this.closest('.detail-goods').data('skn'); 243 var skn = $this.closest('.detail-goods').data('skn');
239 var promotionId = $this.closest('.product-detail-info').data('promotionid') || 0; 244 var promotionId = $this.closest('.product-detail-info').data('promotionid') || 0;
240 - var isSwap = $this.closest('.product-detail-info').data('swap'); 245 + var isSwap = $this.closest('.product-detail-info').data('isswap');
241 246
242 if ($curSize.length <= 0) { 247 if ($curSize.length <= 0) {
243 - new Alert('请选择尺码').show(); 248 + $this.closest('.detail-info').find('.size-p-tip').show();
  249 + // new Alert('请选择尺码').show();
244 return false; 250 return false;
245 } 251 }
246 252