Merge branch 'release/5.2' of http://git.yoho.cn/fe/yohobuy-node into release/5.2
Showing
16 changed files
with
435 additions
and
48 deletions
@@ -12,6 +12,20 @@ const crypto = global.yoho.crypto; | @@ -12,6 +12,20 @@ const crypto = global.yoho.crypto; | ||
12 | 12 | ||
13 | const easypayApi = require('./easypay-api'); | 13 | const easypayApi = require('./easypay-api'); |
14 | 14 | ||
15 | +const handelViewPrice = list => { | ||
16 | + if (list) { | ||
17 | + _.forEach(list, val => { | ||
18 | + if (val.promotion === '商品金额') { | ||
19 | + val.promotion = '商品总价'; | ||
20 | + val.promotion_amount = `+ ${val.promotion_amount}`; | ||
21 | + } else { | ||
22 | + val.promotion_amount = _.replace(val.promotion_amount, '+', '+ '); | ||
23 | + val.promotion_amount = _.replace(val.promotion_amount, '-', '- '); | ||
24 | + } | ||
25 | + }); | ||
26 | + } | ||
27 | +}; | ||
28 | + | ||
15 | const _handelPaymentInfo = (d) => { | 29 | const _handelPaymentInfo = (d) => { |
16 | let resData = {}; | 30 | let resData = {}; |
17 | 31 | ||
@@ -66,6 +80,10 @@ const _handelPaymentInfo = (d) => { | @@ -66,6 +80,10 @@ const _handelPaymentInfo = (d) => { | ||
66 | contractMe: false | 80 | contractMe: false |
67 | }; | 81 | }; |
68 | 82 | ||
83 | + if (d.shopping_cart_data && d.shopping_cart_data.promotion_formula_list) { | ||
84 | + handelViewPrice(d.shopping_cart_data.promotion_formula_list); | ||
85 | + } | ||
86 | + | ||
69 | Object.assign(resData, { | 87 | Object.assign(resData, { |
70 | paymentWay: d.payment_way, | 88 | paymentWay: d.payment_way, |
71 | deliveryTime: d.delivery_time, | 89 | deliveryTime: d.delivery_time, |
@@ -119,7 +137,13 @@ const getOrderComputeData = (uid, cartType, params) => { | @@ -119,7 +137,13 @@ const getOrderComputeData = (uid, cartType, params) => { | ||
119 | 137 | ||
120 | return easypayApi.getEasypayComputeAsync(uid, cartType, params.paymentType, params.deliveryWay, params).then(result => { // eslint-disable-line | 138 | return easypayApi.getEasypayComputeAsync(uid, cartType, params.paymentType, params.deliveryWay, params).then(result => { // eslint-disable-line |
121 | if (result.code === 200) { | 139 | if (result.code === 200) { |
122 | - result.data.last_order_amount = _.round(result.data.last_order_amount, 2); | 140 | + if (_.has(result, 'data.last_order_amount')) { |
141 | + result.data.last_order_amount = _.round(result.data.last_order_amount, 2); | ||
142 | + } | ||
143 | + | ||
144 | + if (_.has(result, 'data.promotion_formula_list')) { | ||
145 | + handelViewPrice(result.data.promotion_formula_list); | ||
146 | + } | ||
123 | } | 147 | } |
124 | return result; | 148 | return result; |
125 | }); | 149 | }); |
@@ -233,6 +233,22 @@ const createConsult = (req, res, next) => { | @@ -233,6 +233,22 @@ const createConsult = (req, res, next) => { | ||
233 | } | 233 | } |
234 | }; | 234 | }; |
235 | 235 | ||
236 | +const recommend = (req, res, next) => { | ||
237 | + let skn = req.query.skn || ''; | ||
238 | + let pageSize = req.query.size || 5; | ||
239 | + let pageNum = req.query.num || 1; | ||
240 | + | ||
241 | + if (!skn) { | ||
242 | + return res.json({ | ||
243 | + code: 400, | ||
244 | + message: '服务器错误' | ||
245 | + }); | ||
246 | + } | ||
247 | + | ||
248 | + service.recommendAsync(skn, pageNum, pageSize) | ||
249 | + .then(result => res.json(result)) | ||
250 | + .catch(next); | ||
251 | +}; | ||
236 | 252 | ||
237 | module.exports = { | 253 | module.exports = { |
238 | showMain, | 254 | showMain, |
@@ -241,7 +257,8 @@ module.exports = { | @@ -241,7 +257,8 @@ module.exports = { | ||
241 | indexConsult, | 257 | indexConsult, |
242 | createConsult, | 258 | createConsult, |
243 | productHeader: detailHeader, | 259 | productHeader: detailHeader, |
244 | - detailReturn | 260 | + detailReturn, |
261 | + recommend | ||
245 | }; | 262 | }; |
246 | 263 | ||
247 | 264 |
@@ -104,6 +104,20 @@ const getLimitedProductStatusAsync = (code, uid, skn) => { | @@ -104,6 +104,20 @@ const getLimitedProductStatusAsync = (code, uid, skn) => { | ||
104 | return api.get('', params, config.apiCache); | 104 | return api.get('', params, config.apiCache); |
105 | }; | 105 | }; |
106 | 106 | ||
107 | +/** | ||
108 | + * | ||
109 | + * @param skn product_skn | ||
110 | + * @param sid shop_id | ||
111 | + */ | ||
112 | +const getShopRecommendAsync = (skn, page, limit) => { | ||
113 | + return api.get('', { | ||
114 | + method: 'web.product.shopRecommend', | ||
115 | + product_skn: skn, | ||
116 | + page: page, | ||
117 | + limit: limit | ||
118 | + }); | ||
119 | +}; | ||
120 | + | ||
107 | module.exports = { | 121 | module.exports = { |
108 | getProductBannerAsync, | 122 | getProductBannerAsync, |
109 | sizeInfoAsync, | 123 | sizeInfoAsync, |
@@ -113,5 +127,6 @@ module.exports = { | @@ -113,5 +127,6 @@ module.exports = { | ||
113 | getProductAsync, | 127 | getProductAsync, |
114 | getPromotionAsync, | 128 | getPromotionAsync, |
115 | isSupportReturnedSale, | 129 | isSupportReturnedSale, |
116 | - getLimitedProductStatusAsync | 130 | + getLimitedProductStatusAsync, |
131 | + getShopRecommendAsync | ||
117 | }; | 132 | }; |
@@ -1234,7 +1234,6 @@ const _detailDataPkg = (origin, uid, vipLevel, cookies) => { | @@ -1234,7 +1234,6 @@ const _detailDataPkg = (origin, uid, vipLevel, cookies) => { | ||
1234 | let notForSale = propOrigin('attribute') === 2; // 非卖品 | 1234 | let notForSale = propOrigin('attribute') === 2; // 非卖品 |
1235 | let virtualGoods = propOrigin('attribute') === 3; // 虚拟商品 | 1235 | let virtualGoods = propOrigin('attribute') === 3; // 虚拟商品 |
1236 | 1236 | ||
1237 | - | ||
1238 | if (virtualGoods) { | 1237 | if (virtualGoods) { |
1239 | result.virtualGoods = virtualGoods; | 1238 | result.virtualGoods = virtualGoods; |
1240 | 1239 | ||
@@ -1450,6 +1449,57 @@ const showMainAsync = (data) => { | @@ -1450,6 +1449,57 @@ const showMainAsync = (data) => { | ||
1450 | })(); | 1449 | })(); |
1451 | }; | 1450 | }; |
1452 | 1451 | ||
1452 | + | ||
1453 | +const recommendAsync = (skn, page, limit) => { | ||
1454 | + return co(function * () { | ||
1455 | + let recommendData = yield productAPI.getShopRecommendAsync(skn, page, limit); | ||
1456 | + | ||
1457 | + if (_.get(recommendData, 'code', 400) !== 200) { | ||
1458 | + return { | ||
1459 | + code: 400, | ||
1460 | + message: '服务器错误!' | ||
1461 | + }; | ||
1462 | + } | ||
1463 | + | ||
1464 | + const formatPrice = p => `¥${p}`; | ||
1465 | + const productUrl = (pid, gid, cn) => helpers.urlFormat(`/product/pro_${pid}_${gid}/${cn}.html`, null, 'item'); | ||
1466 | + const productImageUrl = Fn.pipe(Fn.prop('default_images'), _.partial(helpers.image, _, 150, 200, 2, 70)); | ||
1467 | + | ||
1468 | + let products = _.get(recommendData, 'data.product_list', []).map((rp) => { | ||
1469 | + let marketPrice = rp.sales_price; | ||
1470 | + let salePrice = rp.market_price; | ||
1471 | + | ||
1472 | + let defaultGoods = _.find(rp.goods_list, {is_default: 'Y'}); | ||
1473 | + | ||
1474 | + // 无默认商品取商品列表第一个 | ||
1475 | + if (!defaultGoods) { | ||
1476 | + defaultGoods = rp.goods_list[0]; | ||
1477 | + } | ||
1478 | + | ||
1479 | + return { | ||
1480 | + market_price: marketPrice === salePrice ? '' : formatPrice(helpers.round(marketPrice, 2)), | ||
1481 | + price: formatPrice(helpers.round(salePrice, 2)), | ||
1482 | + product_name: rp.product_name, | ||
1483 | + url: productUrl(rp.product_id, defaultGoods.goods_id, rp.cn_alphabet), | ||
1484 | + pic_url: productImageUrl(rp) | ||
1485 | + }; | ||
1486 | + }); | ||
1487 | + | ||
1488 | + return { | ||
1489 | + code: 200, | ||
1490 | + data: { | ||
1491 | + pager: { | ||
1492 | + total: _.get(recommendData, 'page_total', 0), | ||
1493 | + size: _.get(recommendData, 'page_size', 5), | ||
1494 | + num: _.get(recommendData, 'page', 1) | ||
1495 | + }, | ||
1496 | + products: products, | ||
1497 | + total: _.get(recommendData, 'total', 0) | ||
1498 | + } | ||
1499 | + }; | ||
1500 | + })(); | ||
1501 | +}; | ||
1502 | + | ||
1453 | module.exports = { | 1503 | module.exports = { |
1454 | getShareOrderListAsync: commentService.getShareOrderListAsync, // 获取评论列表 | 1504 | getShareOrderListAsync: commentService.getShareOrderListAsync, // 获取评论列表 |
1455 | indexConsultAsync: consultService.indexAsync, // 获取咨询列表 | 1505 | indexConsultAsync: consultService.indexAsync, // 获取咨询列表 |
@@ -1458,5 +1508,6 @@ module.exports = { | @@ -1458,5 +1508,6 @@ module.exports = { | ||
1458 | indexHotAreaAsync: hotAreaService.indexAsync, // 获取某一个商品的热区数据 | 1508 | indexHotAreaAsync: hotAreaService.indexAsync, // 获取某一个商品的热区数据 |
1459 | saveRecentGoodInCookies, // 保存最近的商品 | 1509 | saveRecentGoodInCookies, // 保存最近的商品 |
1460 | getDetailHeader, | 1510 | getDetailHeader, |
1461 | - saleReturn | 1511 | + saleReturn, |
1512 | + recommendAsync | ||
1462 | }; | 1513 | }; |
@@ -64,6 +64,7 @@ router.post('/index/favoriteBrand', favorite.changeFavoriteBrand);// 收è—å“ç‰ | @@ -64,6 +64,7 @@ router.post('/index/favoriteBrand', favorite.changeFavoriteBrand);// 收è—å“ç‰ | ||
64 | router.post('/item/togglecollect', favorite.collectProduct); // 收藏商品 | 64 | router.post('/item/togglecollect', favorite.collectProduct); // 收藏商品 |
65 | router.get('/detail/header', detail.productHeader); // 价格数据重新获取接口 | 65 | router.get('/detail/header', detail.productHeader); // 价格数据重新获取接口 |
66 | router.get('/detail/return', detail.detailReturn);// 特殊商品退换货 | 66 | router.get('/detail/return', detail.detailReturn);// 特殊商品退换货 |
67 | +router.get('/detail/recommend', detail.recommend);// 推荐商品 | ||
67 | router.get('/index/isfav', favorite.isFavoriteBrand);// 品牌收藏状态 | 68 | router.get('/index/isfav', favorite.isFavoriteBrand);// 品牌收藏状态 |
68 | router.get('/detail/coupon', auth, coupon.acquire); // 获得优惠券 | 69 | router.get('/detail/coupon', auth, coupon.acquire); // 获得优惠券 |
69 | 70 |
@@ -233,6 +233,16 @@ | @@ -233,6 +233,16 @@ | ||
233 | </div> | 233 | </div> |
234 | 234 | ||
235 | {{# consultComment}} | 235 | {{# consultComment}} |
236 | + <div class="lazy-load-object"> | ||
237 | + <textarea class="datalazyload" style="visibility: hidden;"> | ||
238 | + <script> | ||
239 | + fetchComment(); | ||
240 | + fetchReturn(); | ||
241 | + loadRecommend(); | ||
242 | + </script> | ||
243 | + </textarea> | ||
244 | + </div> | ||
245 | + | ||
236 | <div class="consult-comment info-block"> | 246 | <div class="consult-comment info-block"> |
237 | 247 | ||
238 | <p class="block-title"> | 248 | <p class="block-title"> |
@@ -303,16 +313,6 @@ | @@ -303,16 +313,6 @@ | ||
303 | </p> | 313 | </p> |
304 | </div> | 314 | </div> |
305 | </div> | 315 | </div> |
306 | - | ||
307 | - <div class="lazy-load-object"> | ||
308 | - <textarea class="datalazyload" style="visibility: hidden;"> | ||
309 | - <script> | ||
310 | - fetchComment(); | ||
311 | - fetchReturn(); | ||
312 | - </script> | ||
313 | - </textarea> | ||
314 | - </div> | ||
315 | - | ||
316 | </div> | 316 | </div> |
317 | {{/ consultComment}} | 317 | {{/ consultComment}} |
318 | 318 | ||
@@ -354,23 +354,36 @@ | @@ -354,23 +354,36 @@ | ||
354 | 354 | ||
355 | <div class="service"></div> | 355 | <div class="service"></div> |
356 | {{#unless @root.pc.product.removeRecentView}} | 356 | {{#unless @root.pc.product.removeRecentView}} |
357 | - {{#if latestWalk}} | ||
358 | - <div class="info-block latest-walk"> | ||
359 | - <input id="latest-walk-count" type="hidden" value="{{latestWalk}}"> | ||
360 | - <p class="block-title"> | ||
361 | - <span class="title cur">最近浏览 RECENT REVIEW</span> | ||
362 | - </p> | ||
363 | - <div id="latest-walk-goods" class="goods clearfix"></div> | ||
364 | - {{> product/latest-walk-tpl}} | 357 | + <div class="individual-comment info-block"> |
358 | + <p class="block-title"> | ||
359 | + <span class="title cur">店铺推荐 SHOP RECOMMENDED</span> | ||
360 | + <span class="sep">|</span> | ||
361 | + <span class="title">最近浏览 RECENT REVIEW</span> | ||
362 | + </p> | ||
363 | + {{#if latestWalk}} | ||
364 | + <div class="latest-walk"> | ||
365 | + <input id="latest-walk-count" type="hidden" value="{{latestWalk}}"> | ||
366 | + <div id="latest-walk-goods" class="goods clearfix"></div> | ||
367 | + {{> product/latest-walk-tpl}} | ||
365 | </div> | 368 | </div> |
366 | - {{/if}} | 369 | + {{/if}} |
370 | + | ||
371 | + <div id="recommend-shop" class="hide"> | ||
372 | + <div class="recommend-content clearfix"> | ||
373 | + <div class="recommend-slider"> | ||
374 | + <ul class=" img-list" id="recommend-content"></ul> | ||
375 | + <div class="img-brand-switch"> | ||
376 | + <a class="prev iconfont" href="javascript:;"></a> | ||
377 | + <a class="next iconfont" href="javascript:;"></a> | ||
378 | + </div> | ||
379 | + </div> | ||
380 | + </div> | ||
381 | + </div> | ||
382 | + </div> | ||
367 | {{/unless}} | 383 | {{/unless}} |
368 | </div> | 384 | </div> |
369 | </div> | 385 | </div> |
370 | {{/ detail}} | 386 | {{/ detail}} |
371 | - <script id="consults-tpl" type="text/html"> | ||
372 | - | ||
373 | - </script> | ||
374 | </div> | 387 | </div> |
375 | 388 | ||
376 | {{# statGoodsInfo}} | 389 | {{# statGoodsInfo}} |
@@ -17,11 +17,16 @@ module.exports = { | @@ -17,11 +17,16 @@ module.exports = { | ||
17 | cookieDomain: '.yohobuy.com', | 17 | cookieDomain: '.yohobuy.com', |
18 | domains: { | 18 | domains: { |
19 | favApi: 'http://192.168.102.31:8092/brower', | 19 | favApi: 'http://192.168.102.31:8092/brower', |
20 | - api: 'http://api-test1.yohops.com:9999/', | ||
21 | - service: 'http://service-test1.yohops.com:9999/', | 20 | + |
21 | + // api: 'http://api-test1.yohops.com:9999/', | ||
22 | + // service: 'http://service-test1.yohops.com:9999/', | ||
22 | 23 | ||
23 | // api: 'http://api.yoho.cn/', | 24 | // api: 'http://api.yoho.cn/', |
24 | // service: 'http://service.yoho.cn/', | 25 | // service: 'http://service.yoho.cn/', |
26 | + | ||
27 | + api: 'http://dev-api.yohops.com:9999/', | ||
28 | + service: 'http://dev-service.yohops.com:9999/', | ||
29 | + | ||
25 | search: 'http://192.168.102.216:8080/yohosearch/' | 30 | search: 'http://192.168.102.216:8080/yohosearch/' |
26 | }, | 31 | }, |
27 | subDomains: { | 32 | subDomains: { |
@@ -67,7 +72,7 @@ module.exports = { | @@ -67,7 +72,7 @@ module.exports = { | ||
67 | port: '4444' // influxdb port | 72 | port: '4444' // influxdb port |
68 | }, | 73 | }, |
69 | console: { | 74 | console: { |
70 | - level: 'error', | 75 | + level: 'info', |
71 | colorize: 'all', | 76 | colorize: 'all', |
72 | prettyPrint: true | 77 | prettyPrint: true |
73 | } | 78 | } |
@@ -116,10 +121,10 @@ if (isProduction) { | @@ -116,10 +121,10 @@ if (isProduction) { | ||
116 | master: ['memcache1.yohoops.org:12111', 'memcache2.yohoops.org:12111', 'memcache3.yohoops.org:12111'], | 121 | master: ['memcache1.yohoops.org:12111', 'memcache2.yohoops.org:12111', 'memcache3.yohoops.org:12111'], |
117 | slave: ['memcache1.yohoops.org:12112', 'memcache2.yohoops.org:12112', 'memcache3.yohoops.org:12112'], | 122 | slave: ['memcache1.yohoops.org:12112', 'memcache2.yohoops.org:12112', 'memcache3.yohoops.org:12112'], |
118 | session: ['memcache1.yohoops.org:12111', 'memcache2.yohoops.org:12111', 'memcache3.yohoops.org:12111'], | 123 | session: ['memcache1.yohoops.org:12111', 'memcache2.yohoops.org:12111', 'memcache3.yohoops.org:12111'], |
119 | - poolSize: 100, | 124 | + poolSize: 25, |
120 | reconnect: 5000, | 125 | reconnect: 5000, |
121 | timeout: 300, | 126 | timeout: 300, |
122 | - retries: 0, | 127 | + retries: 1, |
123 | retry: 3000 | 128 | retry: 3000 |
124 | }, | 129 | }, |
125 | useOneapm: true, | 130 | useOneapm: true, |
@@ -12,8 +12,4 @@ | @@ -12,8 +12,4 @@ | ||
12 | </div> | 12 | </div> |
13 | \{{/ latestWalk}} | 13 | \{{/ latestWalk}} |
14 | </script> | 14 | </script> |
15 | -<div class="lazy-load-object"> | ||
16 | - <textarea class="latest-walk-datalazyload" style="visibility: hidden;"> | ||
17 | - <script> fetchLatestWalk(); </script> | ||
18 | - </textarea> | ||
19 | -</div> | 15 | + |
@@ -7,5 +7,11 @@ | @@ -7,5 +7,11 @@ | ||
7 | </div> | 7 | </div> |
8 | 8 | ||
9 | {{> product/latest-walk-tpl}} | 9 | {{> product/latest-walk-tpl}} |
10 | + | ||
11 | + <div class="lazy-load-object"> | ||
12 | + <textarea class="latest-walk-datalazyload" style="visibility: hidden;"> | ||
13 | + <script> fetchLatestWalk(); </script> | ||
14 | + </textarea> | ||
15 | + </div> | ||
10 | {{/if}} | 16 | {{/if}} |
11 | {{/unless}} | 17 | {{/unless}} |
public/hbs/product/recommend.hbs
0 → 100644
1 | +{{# products}} | ||
2 | + <li class="img-item"> | ||
3 | + <div class="good"> | ||
4 | + <a href="{{url}}" target="_blank"> | ||
5 | + <img class="lazy" src="{{pic_url}}"/> | ||
6 | + </a> | ||
7 | + <a class="name" href="{{url}}" target="_blank">{{product_name}}</a> | ||
8 | + <p class="price"> | ||
9 | + <span class="market-price">{{market_price}}</span> | ||
10 | + <span class="sale-price">{{price}}</span> | ||
11 | + </p> | ||
12 | + </div> | ||
13 | + </li> | ||
14 | +{{/ products}} |
@@ -49,6 +49,9 @@ function isEmpty(el) { | @@ -49,6 +49,9 @@ function isEmpty(el) { | ||
49 | return !$.trim(el.html()); | 49 | return !$.trim(el.html()); |
50 | } | 50 | } |
51 | 51 | ||
52 | +require('../plugins/slider'); | ||
53 | +require('../common/center-slider'); | ||
54 | + | ||
52 | bindEvent.add(function() { | 55 | bindEvent.add(function() { |
53 | var $imgShow = $('#img-show'), | 56 | var $imgShow = $('#img-show'), |
54 | $thumbs = $('#thumbs > .thumb-wrap'); | 57 | $thumbs = $('#thumbs > .thumb-wrap'); |
@@ -789,9 +792,6 @@ function fetchComment() { | @@ -789,9 +792,6 @@ function fetchComment() { | ||
789 | return; | 792 | return; |
790 | } | 793 | } |
791 | 794 | ||
792 | - // 更新总数显示 | ||
793 | - // $commentNum.text(res[0].total); | ||
794 | - | ||
795 | if (filter && filter.length && !cNumReady) { | 795 | if (filter && filter.length && !cNumReady) { |
796 | cNumReady = true; | 796 | cNumReady = true; |
797 | $(filter).each(function(idx, fit) { | 797 | $(filter).each(function(idx, fit) { |
@@ -815,13 +815,6 @@ function fetchComment() { | @@ -815,13 +815,6 @@ function fetchComment() { | ||
815 | }); | 815 | }); |
816 | } | 816 | } |
817 | 817 | ||
818 | - // 购买有图评价 | ||
819 | - /* function loadPicComments() { | ||
820 | - loadComments(commentType.PIC).then(function(data){ | ||
821 | - | ||
822 | - }); | ||
823 | - }*/ | ||
824 | - | ||
825 | // 顾客咨询 | 818 | // 顾客咨询 |
826 | function loadConsults() { | 819 | function loadConsults() { |
827 | if (loadingConsults) { | 820 | if (loadingConsults) { |
@@ -1019,6 +1012,78 @@ $('.comments').on('click', '.img-preview [data-role="preview-right"]', function( | @@ -1019,6 +1012,78 @@ $('.comments').on('click', '.img-preview [data-role="preview-right"]', function( | ||
1019 | $img.css('transform', 'rotate(' + rotate + 'deg)'); | 1012 | $img.css('transform', 'rotate(' + rotate + 'deg)'); |
1020 | }); | 1013 | }); |
1021 | 1014 | ||
1015 | +// 店铺推荐 | ||
1016 | +function loadRecommend() { | ||
1017 | + $.ajax({ | ||
1018 | + type: 'GET', | ||
1019 | + url: '/product/detail/recommend', | ||
1020 | + data: { | ||
1021 | + skn: skn, | ||
1022 | + size: 20, | ||
1023 | + num: 1 | ||
1024 | + } | ||
1025 | + }).then(function(data) { | ||
1026 | + var pro = data.data.products; | ||
1027 | + var recommendTpl = require('hbs/product/recommend.hbs'); | ||
1028 | + var html = recommendTpl(data.data); | ||
1029 | + | ||
1030 | + if (data.code === 200) { | ||
1031 | + if (pro.length === 0) { | ||
1032 | + $('.individual-comment').find('.block-title .title:first-child').addClass('hide'); | ||
1033 | + $('.individual-comment').find('.block-title').find('.title') | ||
1034 | + .addClass('cur').prev('.sep').addClass('hide'); | ||
1035 | + $('#recommend-shop').detach(); | ||
1036 | + } | ||
1037 | + | ||
1038 | + $('#recommend-shop').removeClass('hide'); | ||
1039 | + $('#recommend-content').append(html); | ||
1040 | + $('.recommend-slider').slider2({ | ||
1041 | + shownum: 5, | ||
1042 | + isCircle: false | ||
1043 | + }); | ||
1044 | + } else { | ||
1045 | + $('.individual-comment').find('.block-title .title:first-child').addClass('hide'); | ||
1046 | + $('.individual-comment').find('.block-title').find('.title').addClass('cur').prev('.sep').addClass('hide'); | ||
1047 | + $('#recommend-shop').detach(); | ||
1048 | + } | ||
1049 | + }); | ||
1050 | +} | ||
1051 | + | ||
1052 | +window.loadRecommend = loadRecommend; | ||
1053 | + | ||
1054 | +// 推荐和浏览切换 | ||
1055 | +$('.individual-comment').on('click', '.title', function() { | ||
1056 | + var $this = $(this), | ||
1057 | + index = $this.index(); | ||
1058 | + | ||
1059 | + var $latestWalk = $('.latest-walk'), | ||
1060 | + $recommendComment = $('#recommend-shop'); | ||
1061 | + | ||
1062 | + if ($this.hasClass('cur')) { | ||
1063 | + return; | ||
1064 | + } | ||
1065 | + | ||
1066 | + $this.addClass('cur'); | ||
1067 | + $this.siblings('.cur').removeClass('cur'); | ||
1068 | + | ||
1069 | + if (index === 0) { | ||
1070 | + // 店铺推荐 | ||
1071 | + $recommendComment.slideDown(SLIDETIME); | ||
1072 | + $latestWalk.slideUp(SLIDETIME); | ||
1073 | + } else { | ||
1074 | + // 最近游览 | ||
1075 | + fetchLatestWalk(); // eslint-disable-line | ||
1076 | + $recommendComment.slideUp(SLIDETIME); | ||
1077 | + $latestWalk.slideDown(SLIDETIME); | ||
1078 | + } | ||
1079 | +}); | ||
1080 | + | ||
1081 | +$('.recommend-content').find('.iconfont').mouseenter(function() { | ||
1082 | + $(this).addClass('focus'); | ||
1083 | +}).mouseleave(function() { | ||
1084 | + $(this).removeClass('focus'); | ||
1085 | +}); | ||
1086 | + | ||
1022 | // 特殊商品退换货 | 1087 | // 特殊商品退换货 |
1023 | function fetchReturn() { | 1088 | function fetchReturn() { |
1024 | return $.ajax({ | 1089 | return $.ajax({ |
@@ -18,6 +18,10 @@ function fetchLatestWalk() { | @@ -18,6 +18,10 @@ function fetchLatestWalk() { | ||
18 | return; | 18 | return; |
19 | } | 19 | } |
20 | 20 | ||
21 | + if ($('#latest-walk-goods').html()) { | ||
22 | + return; | ||
23 | + } | ||
24 | + | ||
21 | tpl = Handlebars.compile($('#latest-walk-tpl').html()); | 25 | tpl = Handlebars.compile($('#latest-walk-tpl').html()); |
22 | 26 | ||
23 | $.ajax({ | 27 | $.ajax({ |
@@ -51,6 +55,7 @@ function fetchLatestWalk() { | @@ -51,6 +55,7 @@ function fetchLatestWalk() { | ||
51 | } | 55 | } |
52 | 56 | ||
53 | if (latestWalk.length > 0) { | 57 | if (latestWalk.length > 0) { |
58 | + | ||
54 | $('#latest-walk-goods').html(tpl({ | 59 | $('#latest-walk-goods').html(tpl({ |
55 | latestWalk: latestWalk | 60 | latestWalk: latestWalk |
56 | })); | 61 | })); |
public/js/product/detail/recommend.js
0 → 100644
1 | +// /** | ||
2 | +// * 最近浏览取接口渲染模板 | ||
3 | +// * @author: xuhui<xuhui.ge@yoho.cn> | ||
4 | +// 8 @date: 2016/11/09 | ||
5 | +// */ | ||
6 | +// | ||
7 | +// var $ = require('yoho-jquery'); | ||
8 | +// var Handlebars = require('yoho-handlebars'); | ||
9 | +// var lazyLoad = require('yoho-jquery-lazyload'); | ||
10 | +// var dataLazyLoad = require('../../plugins/lazy-load')(document); | ||
11 | +// | ||
12 | +// | ||
13 | +// function shopRecommend() { | ||
14 | +// var tpl; | ||
15 | +// | ||
16 | +// tpl = Handlebars.compile($('#recommend-shop').html()); | ||
17 | +// | ||
18 | +// $.ajax({ | ||
19 | +// url: 'product/detail/recommend', | ||
20 | +// | ||
21 | +// success: function(data) { | ||
22 | +// var recommendShop = [], | ||
23 | +// res, i, cur; | ||
24 | +// | ||
25 | +// if (data.code === 200) { | ||
26 | +// res = data.data; | ||
27 | +// | ||
28 | +// for (i = 0; i < res.length; i++) { | ||
29 | +// cur = res[i]; | ||
30 | +// | ||
31 | +// recommendShop.push({ | ||
32 | +// href: cur.url, | ||
33 | +// img: cur.pic_url, | ||
34 | +// name: cur.product_name, | ||
35 | +// salePrice: cur.price | ||
36 | +// }); | ||
37 | +// } | ||
38 | +// | ||
39 | +// if (recommendShop.length > 0) { | ||
40 | +// $('#recommend-shop').html(tpl({ | ||
41 | +// recommendShop: recommendShop | ||
42 | +// })); | ||
43 | +// | ||
44 | +// lazyLoad($('#recommend-shop .lazy')); | ||
45 | +// } | ||
46 | +// } | ||
47 | +// } | ||
48 | +// }); | ||
49 | +// } | ||
50 | +// | ||
51 | +// window.shopRecommend = shopRecommend; | ||
52 | +// | ||
53 | +// // 数据懒加载 | ||
54 | +// dataLazyLoad.init({cls: '.latest-walk-datalazyload', threshold: 700}); |
@@ -42,7 +42,7 @@ var couponPickConfig = { | @@ -42,7 +42,7 @@ var couponPickConfig = { | ||
42 | className: 'top-coupon-dialog', | 42 | className: 'top-coupon-dialog', |
43 | btns: [{ | 43 | btns: [{ |
44 | id: 1, | 44 | id: 1, |
45 | - name: '去使用', | 45 | + name: '关闭', |
46 | btnClass: ['btn-close'] | 46 | btnClass: ['btn-close'] |
47 | }] | 47 | }] |
48 | }, | 48 | }, |
@@ -151,6 +151,7 @@ function syncCouponStatus() { | @@ -151,6 +151,7 @@ function syncCouponStatus() { | ||
151 | coup.status === 3 ? setPicked(couponObj[i]) : false; | 151 | coup.status === 3 ? setPicked(couponObj[i]) : false; |
152 | } else { | 152 | } else { |
153 | couponObj[i].status = 2; // 券不存在设置领取状态为已领光 | 153 | couponObj[i].status = 2; // 券不存在设置领取状态为已领光 |
154 | + couponObj[i].dom.text('已领光'); | ||
154 | } | 155 | } |
155 | } | 156 | } |
156 | } | 157 | } |
@@ -1227,6 +1227,7 @@ | @@ -1227,6 +1227,7 @@ | ||
1227 | 1227 | ||
1228 | .not-support-saleReturned-service { | 1228 | .not-support-saleReturned-service { |
1229 | $service: product/limit.png; | 1229 | $service: product/limit.png; |
1230 | + | ||
1230 | width: width($service); | 1231 | width: width($service); |
1231 | height: height($service); | 1232 | height: height($service); |
1232 | margin: 45px auto; | 1233 | margin: 45px auto; |
@@ -1235,6 +1236,7 @@ | @@ -1235,6 +1236,7 @@ | ||
1235 | 1236 | ||
1236 | .latest-walk { | 1237 | .latest-walk { |
1237 | overflow: inherit; | 1238 | overflow: inherit; |
1239 | + border-top: none; | ||
1238 | 1240 | ||
1239 | .goods { | 1241 | .goods { |
1240 | width: 1010px; | 1242 | width: 1010px; |
@@ -1366,6 +1368,121 @@ | @@ -1366,6 +1368,121 @@ | ||
1366 | } | 1368 | } |
1367 | } | 1369 | } |
1368 | } | 1370 | } |
1371 | + | ||
1372 | + .individual-comment { | ||
1373 | + | ||
1374 | + .block-title { | ||
1375 | + | ||
1376 | + .sep { | ||
1377 | + &+.title { | ||
1378 | + margin-right: 34px; | ||
1379 | + } | ||
1380 | + } | ||
1381 | + } | ||
1382 | + } | ||
1383 | + | ||
1384 | + .recommend-content { | ||
1385 | + position: relative; | ||
1386 | + height: 280px; | ||
1387 | + overflow: hidden; | ||
1388 | + | ||
1389 | + .recommend-slider { | ||
1390 | + margin: 0 80px; | ||
1391 | + box-sizing: border-box; | ||
1392 | + width: 990px; | ||
1393 | + height: 280px; | ||
1394 | + overflow: hidden; | ||
1395 | + } | ||
1396 | + | ||
1397 | + ul { | ||
1398 | + height: 100%; | ||
1399 | + } | ||
1400 | + | ||
1401 | + li { | ||
1402 | + float: left; | ||
1403 | + width: 200px; | ||
1404 | + height: 280px; | ||
1405 | + overflow: hidden; | ||
1406 | + } | ||
1407 | + | ||
1408 | + .img-brand-switch { | ||
1409 | + display: block; | ||
1410 | + | ||
1411 | + a { | ||
1412 | + position: absolute; | ||
1413 | + top: 50%; | ||
1414 | + margin-top: -40px; | ||
1415 | + font-size: 24px; | ||
1416 | + color: #fff; | ||
1417 | + width: 40px; | ||
1418 | + height: 32px; | ||
1419 | + padding-top: 8px; | ||
1420 | + text-align: center; | ||
1421 | + background-color: #b0b0b0; | ||
1422 | + | ||
1423 | + &.focus { | ||
1424 | + background-color: #444; | ||
1425 | + } | ||
1426 | + | ||
1427 | + &.prev { | ||
1428 | + left: 0; | ||
1429 | + } | ||
1430 | + | ||
1431 | + &.next { | ||
1432 | + right: 0; | ||
1433 | + } | ||
1434 | + } | ||
1435 | + } | ||
1436 | + | ||
1437 | + .good { | ||
1438 | + float: left; | ||
1439 | + width: 180px; | ||
1440 | + margin-right: 22px; | ||
1441 | + | ||
1442 | + a { | ||
1443 | + cursor: pointer; | ||
1444 | + | ||
1445 | + & > div { | ||
1446 | + background-color: #f4f7f6; | ||
1447 | + } | ||
1448 | + } | ||
1449 | + | ||
1450 | + img { | ||
1451 | + display: block; | ||
1452 | + width: 180px; | ||
1453 | + height: 240px; | ||
1454 | + } | ||
1455 | + | ||
1456 | + .name { | ||
1457 | + display: block; | ||
1458 | + max-width: 150px; | ||
1459 | + height: 18px; | ||
1460 | + line-height: 16px; | ||
1461 | + margin: 5px 0; | ||
1462 | + color: #222; | ||
1463 | + overflow: hidden; | ||
1464 | + text-overflow: ellipsis; | ||
1465 | + white-space: nowrap; | ||
1466 | + } | ||
1467 | + | ||
1468 | + .price { | ||
1469 | + color: #222; | ||
1470 | + font-weight: 700; | ||
1471 | + margin-top: 5px; | ||
1472 | + } | ||
1473 | + | ||
1474 | + .market-price { | ||
1475 | + color: #999; | ||
1476 | + margin-right: 5px; | ||
1477 | + text-decoration: line-through; | ||
1478 | + } | ||
1479 | + | ||
1480 | + .sale-price { | ||
1481 | + color: #000; | ||
1482 | + font-weight: 700; | ||
1483 | + } | ||
1484 | + } | ||
1485 | + } | ||
1369 | } | 1486 | } |
1370 | 1487 | ||
1371 | .coupon-big { | 1488 | .coupon-big { |
-
Please register or login to post a comment