Merge branch 'aaa' into feature/wsl5.3
Showing
9 changed files
with
172 additions
and
1 deletions
apps/product/controllers/recommend.js
0 → 100644
1 | +/** | ||
2 | + * 推荐商品(店铺推荐|为您优选|最近浏览)controller | ||
3 | + * @author: wsl<shuiling.wang@yoho.cn> | ||
4 | + * @date: 2016/11/21 | ||
5 | + */ | ||
6 | +'use strict'; | ||
7 | + | ||
8 | +const _ = require('lodash'); | ||
9 | +const recommend = require('../models/recommend'); | ||
10 | + | ||
11 | +const getRecommendProduct = (req, res, next) => { | ||
12 | + recommend.getRecommendProduct().then((result) => { | ||
13 | + res.json(result); | ||
14 | + }); | ||
15 | +}; | ||
16 | + | ||
17 | +module.exports = { | ||
18 | + getRecommendProduct | ||
19 | +}; |
apps/product/models/recommend.js
0 → 100644
1 | +/** | ||
2 | + * 推荐商品(店铺推荐|为您优选|最近浏览)model | ||
3 | + * @author: wsl<shuiling.wang@yoho.cn> | ||
4 | + * @date: 2016/11/21 | ||
5 | + */ | ||
6 | + | ||
7 | +'use strict'; | ||
8 | + | ||
9 | +const _ = require('lodash'); | ||
10 | +const api = global.yoho.API; | ||
11 | +const logger = global.yoho.logger; | ||
12 | + | ||
13 | +const getRecommendProduct = (params) => { | ||
14 | + params = { | ||
15 | + yh_channel: 4, | ||
16 | + udid: '0f528764d624db129b32c21fbca0cb8d6', | ||
17 | + limit: 5, | ||
18 | + rec_pos: 100003 | ||
19 | + }; | ||
20 | + | ||
21 | + return api.get('app.home.newPreference', params).then((data) => { | ||
22 | + if (data.code === 200 && data.data.length > 0) { | ||
23 | + console.log(data); | ||
24 | + return data.data; | ||
25 | + } else { | ||
26 | + logger.error('get recommend product data code is not 200'); | ||
27 | + return []; | ||
28 | + } | ||
29 | + }); | ||
30 | +}; | ||
31 | + | ||
32 | +module.exports = { | ||
33 | + getRecommendProduct | ||
34 | +}; |
@@ -14,6 +14,7 @@ const item = require(cRoot + '/item'); | @@ -14,6 +14,7 @@ const item = require(cRoot + '/item'); | ||
14 | const fav = require(cRoot + '/favorite'); | 14 | const fav = require(cRoot + '/favorite'); |
15 | const shop = require(cRoot + '/shop'); | 15 | const shop = require(cRoot + '/shop'); |
16 | const query = require(cRoot + '/query'); | 16 | const query = require(cRoot + '/query'); |
17 | +const recommend = require(cRoot + '/recommend'); | ||
17 | 18 | ||
18 | // Your controller here | 19 | // Your controller here |
19 | router.get('/list', list.index); // 列表页面 | 20 | router.get('/list', list.index); // 列表页面 |
@@ -31,4 +32,6 @@ router.post('/brand/togglecollect', auth, fav.brand); | @@ -31,4 +32,6 @@ router.post('/brand/togglecollect', auth, fav.brand); | ||
31 | 32 | ||
32 | router.get('/query', query.index); | 33 | router.get('/query', query.index); |
33 | 34 | ||
35 | +router.get('/getRecommendProduct', recommend.getRecommendProduct); | ||
36 | + | ||
34 | module.exports = router; | 37 | module.exports = router; |
@@ -8,7 +8,8 @@ var $ = require('yoho-jquery'), | @@ -8,7 +8,8 @@ var $ = require('yoho-jquery'), | ||
8 | handlebars = require('yoho-handlebars'), | 8 | handlebars = require('yoho-handlebars'), |
9 | lazyload = require('yoho-jquery-lazyload'), | 9 | lazyload = require('yoho-jquery-lazyload'), |
10 | Dialog = require('../plugins/dialog').Dialog, | 10 | Dialog = require('../plugins/dialog').Dialog, |
11 | - regx = require('../passport/common/mail-phone-regx').phoneRegx; | 11 | + regx = require('../passport/common/mail-phone-regx').phoneRegx, |
12 | + recProduct = require('./item/recommend-product'); | ||
12 | 13 | ||
13 | var $main = $('.product-main'), | 14 | var $main = $('.product-main'), |
14 | $mainThumb = $('#main-thumb'), | 15 | $mainThumb = $('#main-thumb'), |
@@ -47,6 +48,11 @@ require('../plugins/share'); | @@ -47,6 +48,11 @@ require('../plugins/share'); | ||
47 | 48 | ||
48 | lazyload($('img.lazy')); | 49 | lazyload($('img.lazy')); |
49 | 50 | ||
51 | +recProduct.init({ | ||
52 | + dom: '.recommend-product', | ||
53 | + isGoodsDetail: true | ||
54 | +}); | ||
55 | + | ||
50 | function changeThumb($dom) { | 56 | function changeThumb($dom) { |
51 | var data; | 57 | var data; |
52 | 58 |
public/js/product/item/recommend-product.js
0 → 100644
1 | +/** | ||
2 | + * 为您优选 | 店铺推荐 | 最近浏览 | ||
3 | + * @author: wsl<shuiling.wang@yoho.cn> | ||
4 | + * @date: 2016/11/21 | ||
5 | + */ | ||
6 | + | ||
7 | +var recProduct = require('../../../tpl/product/recommend-product.hbs'); | ||
8 | +var recTemplet = require('../../../tpl/product/recommend-templet.hbs'); | ||
9 | + | ||
10 | +var recommmendProduct = { | ||
11 | + init: function(params) { | ||
12 | + var _this = this; | ||
13 | + var obj = { | ||
14 | + isGoodsDetail: false | ||
15 | + }; | ||
16 | + | ||
17 | + if (params.isGoodsDetail) { | ||
18 | + obj.isGoodsDetail = true; | ||
19 | + } | ||
20 | + | ||
21 | + $(params.dom).append(recTemplet(obj)); | ||
22 | + | ||
23 | + _this.getRecommendProduct({ | ||
24 | + page: 1, | ||
25 | + dom: params.dom | ||
26 | + }); | ||
27 | + }, | ||
28 | + getRecommendProduct: function(params) { | ||
29 | + $.get('/product/getRecommendProduct', { | ||
30 | + page: params.page | ||
31 | + }, function(data) { | ||
32 | + if (data) { | ||
33 | + $(params.dom).find('.goods-area').html(recProduct(data)); | ||
34 | + } | ||
35 | + }); | ||
36 | + } | ||
37 | +}; | ||
38 | + | ||
39 | +module.exports = recommmendProduct; |
@@ -478,6 +478,55 @@ | @@ -478,6 +478,55 @@ | ||
478 | } | 478 | } |
479 | } | 479 | } |
480 | 480 | ||
481 | + .recommend-product { | ||
482 | + width: 100%; | ||
483 | + margin-bottom: 55px; | ||
484 | + | ||
485 | + .recommend-header { | ||
486 | + height: 40px; | ||
487 | + border-bottom: 1px solid #ddd; | ||
488 | + } | ||
489 | + | ||
490 | + .head-tab { | ||
491 | + width: 140px; | ||
492 | + height:40px; | ||
493 | + line-height: 42px; | ||
494 | + font-size: 14px; | ||
495 | + text-align: center; | ||
496 | + float: left; | ||
497 | + cursor: pointer; | ||
498 | + | ||
499 | + &.active { | ||
500 | + font-weight: bold; | ||
501 | + border: 1px solid #ddd; | ||
502 | + border-bottom-color: #fff; | ||
503 | + box-sizing: border-box; | ||
504 | + } | ||
505 | + } | ||
506 | + | ||
507 | + .change-btn { | ||
508 | + float: right; | ||
509 | + font-size: 14px; | ||
510 | + font-weight: bold; | ||
511 | + line-height: 42px; | ||
512 | + | ||
513 | + .iconfont { | ||
514 | + font-size: 18px; | ||
515 | + position: relative; | ||
516 | + top: 2px; | ||
517 | + margin-left: 5px; | ||
518 | + } | ||
519 | + } | ||
520 | + | ||
521 | + .product-area { | ||
522 | + img { | ||
523 | + width: 214px; | ||
524 | + height: 288px; | ||
525 | + background: #f5f7f6; | ||
526 | + } | ||
527 | + } | ||
528 | + } | ||
529 | + | ||
481 | .info-block { | 530 | .info-block { |
482 | border: 1px solid #f3f3f3; | 531 | border: 1px solid #f3f3f3; |
483 | padding: 40px 130px; | 532 | padding: 40px 130px; |
public/tpl/product/recommend-product.hbs
0 → 100644
1 | +{{#each products}} | ||
2 | + <div class="goods" data-id="{{productId}}" data-url="{{url}}"> | ||
3 | + <div class="goods-img"> | ||
4 | + <a href="{{https url}}" target="_blank"> | ||
5 | + <img class="lazy" data-original="{{image defaultImages 263 351}}" width="263" height="351" alt=""> | ||
6 | + </a> | ||
7 | + </div> | ||
8 | + <div class="goods-brand">{{brandName}}</div> | ||
9 | + <div class="goods-name">{{productName}}</div> | ||
10 | + <div class="goods-price"> | ||
11 | + <span>¥{{round salesPrice}}</span> | ||
12 | + </div> | ||
13 | + </div> | ||
14 | +{{/each}} |
public/tpl/product/recommend-templet.hbs
0 → 100644
-
Please register or login to post a comment