Showing
25 changed files
with
512 additions
and
119 deletions
@@ -61,6 +61,8 @@ const newGoods = (req, res, next) => { | @@ -61,6 +61,8 @@ const newGoods = (req, res, next) => { | ||
61 | }; | 61 | }; |
62 | 62 | ||
63 | const _newGoods = (req, res, next) => { | 63 | const _newGoods = (req, res, next) => { |
64 | + const channel = req.cookies._Channel; | ||
65 | + | ||
64 | res.render('new/index', { | 66 | res.render('new/index', { |
65 | module: 'product', | 67 | module: 'product', |
66 | page: 'new-arrival', | 68 | page: 'new-arrival', |
@@ -69,21 +71,46 @@ const _newGoods = (req, res, next) => { | @@ -69,21 +71,46 @@ const _newGoods = (req, res, next) => { | ||
69 | pageHeader: headerModel.setNav({ | 71 | pageHeader: headerModel.setNav({ |
70 | navTitle: '新品到着' | 72 | navTitle: '新品到着' |
71 | }), | 73 | }), |
74 | + | ||
75 | + brand: '0', | ||
76 | + sort: '0', | ||
77 | + gender: req.query.gender || searchProcess.getGenderByChannel(channel), | ||
78 | + channel, | ||
79 | + price: '0', | ||
80 | + size: '0', | ||
81 | + dayLimit: 1, | ||
82 | + discount: '', | ||
83 | + cartUrl: helpers.urlFormat('/cart/index/index', null), | ||
84 | + pageFooter: true, | ||
85 | + showDownloadApp: true | ||
72 | }); | 86 | }); |
73 | }; | 87 | }; |
74 | 88 | ||
89 | +/** | ||
90 | + * 新品到着 落地页: 为您推荐 | ||
91 | + */ | ||
75 | const brands = (req, res, next) => { | 92 | const brands = (req, res, next) => { |
76 | - res.render('new/brands', { | ||
77 | - module: 'product', | ||
78 | - page: 'new-brands', | ||
79 | - width750: true, | ||
80 | - localCss: true, | ||
81 | - pageHeader: headerModel.setNav({ | ||
82 | - navTitle: '为您推荐' | ||
83 | - }), | ||
84 | - }); | 93 | + const channel = req.cookies._Channel; |
94 | + const uid = req.user.uid; | ||
95 | + | ||
96 | + newModel.recbrand(uid, channel).then(data => { | ||
97 | + res.render('new/brands', { | ||
98 | + module: 'product', | ||
99 | + page: 'new-brands', | ||
100 | + width750: true, | ||
101 | + localCss: true, | ||
102 | + pageHeader: headerModel.setNav({ | ||
103 | + navTitle: '为您推荐' | ||
104 | + }), | ||
105 | + | ||
106 | + hotBrands: data.hot_brand_list, | ||
107 | + browseBrands: data.browse_brand_list, | ||
108 | + newBrands: data.new_brand_list | ||
109 | + }); | ||
110 | + }).catch(next); | ||
85 | }; | 111 | }; |
86 | 112 | ||
113 | + | ||
87 | const selectNewSale = (req, res, next) => { | 114 | const selectNewSale = (req, res, next) => { |
88 | let params = _.assign({}, req.query); | 115 | let params = _.assign({}, req.query); |
89 | 116 | ||
@@ -101,6 +128,47 @@ const selectNewSale = (req, res, next) => { | @@ -101,6 +128,47 @@ const selectNewSale = (req, res, next) => { | ||
101 | }; | 128 | }; |
102 | 129 | ||
103 | /** | 130 | /** |
131 | + * 新品到着----为您推荐 | ||
132 | + * Router: /product/new/recommend-shop.json | ||
133 | + */ | ||
134 | +const recommendShop = (req, res, next) => { | ||
135 | + const channel = req.cookies._Channel; | ||
136 | + const uid = req.user.uid; | ||
137 | + | ||
138 | + newModel.recommendShops(uid, channel).then(data => { | ||
139 | + res.json(data); | ||
140 | + }); | ||
141 | +}; | ||
142 | + | ||
143 | + | ||
144 | +/** | ||
145 | + * 获取上架新品 | ||
146 | + */ | ||
147 | +const fetchNew = (req, res, next) => { | ||
148 | + const uid = req.user.uid; | ||
149 | + const channel = req.cookies._Channel; | ||
150 | + | ||
151 | + delete req.query.uid; | ||
152 | + delete req.query.channel; | ||
153 | + | ||
154 | + newModel.reclist(uid, channel, req.query).then(data => { | ||
155 | + return res.json(data); | ||
156 | + }).catch(next); | ||
157 | +}; | ||
158 | + | ||
159 | +const goodsFilter = (req, res, next) => { | ||
160 | + const uid = req.user.uid; | ||
161 | + const channel = req.cookies._Channel; | ||
162 | + | ||
163 | + newModel.reclistFilter(uid, channel).then(result => { | ||
164 | + res.render('search/filter', { | ||
165 | + layout: false, | ||
166 | + filter: result | ||
167 | + }); | ||
168 | + }).catch(next); | ||
169 | +}; | ||
170 | + | ||
171 | +/** | ||
104 | * 筛选 | 172 | * 筛选 |
105 | * @param {[object]} req | 173 | * @param {[object]} req |
106 | * @param {[object]} res | 174 | * @param {[object]} res |
@@ -121,9 +189,13 @@ let filter = (req, res, next) => { | @@ -121,9 +189,13 @@ let filter = (req, res, next) => { | ||
121 | 189 | ||
122 | module.exports = { | 190 | module.exports = { |
123 | blkNewGoods, | 191 | blkNewGoods, |
124 | - newGoods, | 192 | + newGoods, // TODO remove |
125 | _newGoods, | 193 | _newGoods, |
126 | brands, | 194 | brands, |
127 | - selectNewSale, | ||
128 | - filter | 195 | + selectNewSale, // TODO remove |
196 | + filter, // TODO remove | ||
197 | + | ||
198 | + recommendShop, | ||
199 | + fetchNew, | ||
200 | + goodsFilter | ||
129 | }; | 201 | }; |
@@ -16,6 +16,7 @@ const serviceAPI = global.yoho.ServiceAPI; | @@ -16,6 +16,7 @@ const serviceAPI = global.yoho.ServiceAPI; | ||
16 | const api = global.yoho.API; | 16 | const api = global.yoho.API; |
17 | 17 | ||
18 | /** | 18 | /** |
19 | + * TODO: remove | ||
19 | * 商品搜索接口请求 | 20 | * 商品搜索接口请求 |
20 | * @param {[object]} params | 21 | * @param {[object]} params |
21 | * @return {[array]} | 22 | * @return {[array]} |
@@ -66,6 +67,7 @@ const getNewFocus = (channel) => { | @@ -66,6 +67,7 @@ const getNewFocus = (channel) => { | ||
66 | }; | 67 | }; |
67 | 68 | ||
68 | /** | 69 | /** |
70 | + * TODO remove | ||
69 | * 获取商品数据 | 71 | * 获取商品数据 |
70 | */ | 72 | */ |
71 | const getSearchData = (params) => { | 73 | const getSearchData = (params) => { |
@@ -88,6 +90,7 @@ const getSearchData = (params) => { | @@ -88,6 +90,7 @@ const getSearchData = (params) => { | ||
88 | }; | 90 | }; |
89 | 91 | ||
90 | /** | 92 | /** |
93 | + * TODO remove | ||
91 | * 获取筛选数据 | 94 | * 获取筛选数据 |
92 | * @param {[object]} params | 95 | * @param {[object]} params |
93 | * @return {[array]} | 96 | * @return {[array]} |
@@ -103,8 +106,129 @@ const getFilterData = (params) => { | @@ -103,8 +106,129 @@ const getFilterData = (params) => { | ||
103 | }); | 106 | }); |
104 | }; | 107 | }; |
105 | 108 | ||
109 | +/** | ||
110 | + * method=app.newproduct.recshop 推荐店铺 | ||
111 | + * http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/BigData/新品到着.md | ||
112 | + */ | ||
113 | +const recommendShops = (uid, channel, limit, page) => { | ||
114 | + limit = limit || 20; | ||
115 | + page = page || 1; | ||
116 | + | ||
117 | + let params = { | ||
118 | + method: 'app.newproduct.recshop', | ||
119 | + channel, | ||
120 | + limit, | ||
121 | + page, | ||
122 | + uid | ||
123 | + }; | ||
124 | + | ||
125 | + return api.get('', params, {cache: true}) | ||
126 | + .then(result=> { | ||
127 | + let shopData = _.get(result, 'data', {}); | ||
128 | + | ||
129 | + return shopData; | ||
130 | + }) | ||
131 | + .catch(() => {}); | ||
132 | +}; | ||
133 | + | ||
134 | + | ||
135 | +/** | ||
136 | + * method=app.newproduct.recbrand 推荐品牌 | ||
137 | + * http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/BigData/新品到着.md | ||
138 | + */ | ||
139 | +const recbrand = (uid, channel, limit, page) => { | ||
140 | + limit = limit || 20; | ||
141 | + page = page || 1; | ||
142 | + | ||
143 | + let params = { | ||
144 | + method: 'app.newproduct.recbrand', | ||
145 | + channel, | ||
146 | + limit, | ||
147 | + page, | ||
148 | + uid | ||
149 | + }; | ||
150 | + | ||
151 | + return api.get('', params, {cache: true}) | ||
152 | + .then(result => { | ||
153 | + let data = _.get(result, 'data', {}); | ||
154 | + | ||
155 | + return data; | ||
156 | + }) | ||
157 | + .catch(() => {}); | ||
158 | +}; | ||
159 | + | ||
160 | +const newGoodsAPI = (params) => { | ||
161 | + let method = 'app.newproduct.reclist'; | ||
162 | + | ||
163 | + // 排除基本筛选项默认值为0的对象 | ||
164 | + for (let str in params) { | ||
165 | + if ((str !== 'order' && params[str] === '0') || params[str] === null) { | ||
166 | + delete params[str]; | ||
167 | + } | ||
168 | + } | ||
169 | + | ||
170 | + params.yh_channel = searchProcess.getChannelType(params.channel); | ||
171 | + | ||
172 | + delete params.channel; | ||
173 | + | ||
174 | + params = _.assign({ | ||
175 | + limit: '60' | ||
176 | + }, params); | ||
177 | + | ||
178 | + params.order = params.order === '0' ? 's_t_desc' : 's_t_asc'; | ||
179 | + | ||
180 | + return api.get('', _.assign({ | ||
181 | + method: method | ||
182 | + }, params), { | ||
183 | + cache: true | ||
184 | + }); | ||
185 | +}; | ||
186 | + | ||
187 | +/** | ||
188 | + * method:app.newproduct.reclist 新品上架 | ||
189 | + * http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/BigData/新品到着.md | ||
190 | + */ | ||
191 | +const reclist = (uid, channel, searchOptions) => { | ||
192 | + let params = Object.assign({}, {uid, channel}, searchOptions); | ||
193 | + | ||
194 | + return newGoodsAPI(params).then(result => { | ||
195 | + if (result && result.code === 200) { | ||
196 | + let newList = {}; | ||
197 | + | ||
198 | + newList.list = productProcess.processProductList(result.data.product_list || [], {showTags: true}); | ||
199 | + | ||
200 | + if (parseInt(params.page, 10) === 1) { | ||
201 | + newList.total = result.data.total; | ||
202 | + } | ||
203 | + | ||
204 | + return newList; | ||
205 | + } else { | ||
206 | + logger.error('get product search api return code is not 200'); | ||
207 | + return []; | ||
208 | + } | ||
209 | + }); | ||
210 | +}; | ||
211 | + | ||
212 | +const reclistFilter = (uid, channel) => { | ||
213 | + let params = Object.assign({}, {uid, channel}); | ||
214 | + | ||
215 | + return newGoodsAPI(params).then(result => { | ||
216 | + if (result && result.code === 200) { | ||
217 | + return productProcess.processFilter(result.data.filter || []); | ||
218 | + } else { | ||
219 | + logger.error('get filter data api return code is not 200'); | ||
220 | + return []; | ||
221 | + } | ||
222 | + }); | ||
223 | +}; | ||
224 | + | ||
106 | module.exports = { | 225 | module.exports = { |
107 | getNewFocus, | 226 | getNewFocus, |
108 | - getSearchData, | ||
109 | - getFilterData | 227 | + getSearchData, // TODO remove |
228 | + getFilterData, // TODO remove | ||
229 | + | ||
230 | + recommendShops, | ||
231 | + recbrand, | ||
232 | + reclist, | ||
233 | + reclistFilter | ||
110 | }; | 234 | }; |
@@ -158,8 +158,12 @@ router.get('/list/new', news.newGoods); // 兼容 PC 的链接 | @@ -158,8 +158,12 @@ router.get('/list/new', news.newGoods); // 兼容 PC 的链接 | ||
158 | router.get('/new/selectNewSale', news.selectNewSale); | 158 | router.get('/new/selectNewSale', news.selectNewSale); |
159 | router.get('/new/filter', news.filter); | 159 | router.get('/new/filter', news.filter); |
160 | 160 | ||
161 | -router.get('/newnew', news._newGoods); | ||
162 | -router.get('/new/brands', news.brands); | 161 | +router.get('/newnew', news._newGoods); // TODO: repleace /new |
162 | +router.get('/new/recommend-shop.json', news.recommendShop); | ||
163 | +router.get('/new/goods.json', news.fetchNew); | ||
164 | +router.get('/new/goods-filter', news.goodsFilter); | ||
165 | +router.get('/new/shops', news.brands); | ||
166 | + | ||
163 | 167 | ||
164 | // 新品到着(blk) | 168 | // 新品到着(blk) |
165 | router.get('/blknew', news.blkNewGoods); | 169 | router.get('/blknew', news.blkNewGoods); |
1 | -<div class="new-brands"> | 1 | +<div class="recommend-brands"> |
2 | {{!--浏览过的品牌--}} | 2 | {{!--浏览过的品牌--}} |
3 | - {{> new/recommend-brands | ||
4 | - title="浏览过的品牌" | ||
5 | - }} | 3 | + {{#if browseBrands}} |
4 | + {{> new/recommend-brands | ||
5 | + title="浏览过的品牌" | ||
6 | + shops=browseBrands | ||
7 | + }} | ||
8 | + {{/if}} | ||
6 | 9 | ||
7 | {{!--热门品牌--}} | 10 | {{!--热门品牌--}} |
8 | - {{> new/recommend-brands title="热门品牌"}} | 11 | + {{> new/recommend-brands |
12 | + title="热门品牌" | ||
13 | + shops=hotBrands | ||
14 | + }} | ||
9 | 15 | ||
10 | {{!--新入驻品牌--}} | 16 | {{!--新入驻品牌--}} |
11 | - {{> new/recommend-brands title="新入驻品牌"}} | 17 | + {{> new/recommend-brands |
18 | + title="新入驻品牌" | ||
19 | + style="new-brands" | ||
20 | + shops=newBrands | ||
21 | + }} | ||
12 | </div> | 22 | </div> |
@@ -17,15 +17,24 @@ | @@ -17,15 +17,24 @@ | ||
17 | </div> | 17 | </div> |
18 | 18 | ||
19 | {{!--为您推荐--}} | 19 | {{!--为您推荐--}} |
20 | - {{> 'new/recommend-brands' | ||
21 | - style="new-recommend " | ||
22 | - title="为您推荐" | ||
23 | - more='/product/new/brands' | ||
24 | - }} | 20 | + <div id="new-recommend" class="new-recommend panel"> |
21 | + <header class="panel-header"> | ||
22 | + <h3>为您推荐</h3> | ||
23 | + <a href="/product/new/shops" class="panel-header-r more"> | ||
24 | + <i class="iconfont more"></i> | ||
25 | + </a> | ||
26 | + </header> | ||
27 | + <div class="panel-body"></div> | ||
28 | + </div> | ||
25 | 29 | ||
26 | {{!--精选抢先看--}} | 30 | {{!--精选抢先看--}} |
27 | {{> 'new/handpick'}} | 31 | {{> 'new/handpick'}} |
28 | 32 | ||
29 | {{!--最新上架--}} | 33 | {{!--最新上架--}} |
30 | {{> 'new/goods'}} | 34 | {{> 'new/goods'}} |
35 | + | ||
36 | + {{> common/query-param}} | ||
37 | + | ||
38 | + {{> common/suspend-home}} | ||
39 | + {{> common/suspend-cart}} | ||
31 | </div> | 40 | </div> |
1 | -{{!-- 商品列表中的 品牌上新--}} | ||
2 | -<div class="good-info brand-info"> | ||
3 | - <img src="//img11.static.yhbimg.com/brandLogo/2016/08/16/16/01cfd27979a572e6d26018eebfcb6d3583.jpg?imageMogr2/thumbnail/120x120/extent/120x120/background/d2hpdGU=/position/center/quality/80" alt=""> | ||
4 | - <h5 class="bname">这是一个品牌</h5> | ||
5 | - <p class="summary">上新<span class="red">11</span>件 <span class="red">1111</span>人收藏</p> | ||
6 | - <a href="#" class="entry">进入店铺</a> | ||
7 | -</div> |
1 | {{!-- 新品到着: 最新上架--}} | 1 | {{!-- 新品到着: 最新上架--}} |
2 | -<div> | 2 | +<div id="new-goods"> |
3 | <div> | 3 | <div> |
4 | {{> common/filter-nav}} | 4 | {{> common/filter-nav}} |
5 | </div> | 5 | </div> |
6 | 6 | ||
7 | <div class="goods-container"> | 7 | <div class="goods-container"> |
8 | - {{# goods}} | ||
9 | - {{> common/goods}} | ||
10 | - {{/ goods}} | ||
11 | - | ||
12 | - {{> new/tags}} | ||
13 | - {{> new/brand}} | ||
14 | - {{> new/brand-recommend}} | ||
15 | - {{> new/article}} | ||
16 | - | ||
17 | - {{> common/filter}} | 8 | + <div class="container" data-rel="new-0"></div> |
9 | + <div class="container" data-rel="price-0"></div> | ||
10 | + <div class="container" data-rel="price-1"></div> | ||
11 | + <div class="container" data-rel="discount-0"></div> | ||
12 | + <div class="container" data-rel="discount-1"></div> | ||
13 | + <div class="container" data-rel="filter"></div> | ||
14 | + <div id="js-filter"></div> | ||
18 | </div> | 15 | </div> |
19 | 16 | ||
20 | {{> common/query-param}} | 17 | {{> common/query-param}} |
1 | {{!-- 新品到着: 为您推荐--}} | 1 | {{!-- 新品到着: 为您推荐--}} |
2 | -<div id="new-recommend" class="{{style}} panel"> | 2 | +<div id="{{id}}" class="{{style}} panel"> |
3 | <header class="panel-header"> | 3 | <header class="panel-header"> |
4 | <h3>{{title}}</h3> | 4 | <h3>{{title}}</h3> |
5 | {{#more}} | 5 | {{#more}} |
@@ -9,54 +9,6 @@ | @@ -9,54 +9,6 @@ | ||
9 | {{/more}} | 9 | {{/more}} |
10 | </header> | 10 | </header> |
11 | <div class="panel-body"> | 11 | <div class="panel-body"> |
12 | - <div class="brand-news-count"> | ||
13 | - <div class="brand-logo"> | ||
14 | - <img src="//img11.static.yhbimg.com/brandLogo/2016/08/16/16/01cfd27979a572e6d26018eebfcb6d3583.jpg?imageMogr2/thumbnail/120x120/extent/120x120/background/d2hpdGU=/position/center/quality/80" alt=""> | ||
15 | - <h5>品牌品牌</h5> | ||
16 | - </div> | ||
17 | - <div class="count">上新10款<i class="iconfont"></i></div> | ||
18 | - </div> | ||
19 | - <div class="brand-news-count"> | ||
20 | - <div class="brand-logo"> | ||
21 | - <img src="//img11.static.yhbimg.com/brandLogo/2016/08/16/16/01cfd27979a572e6d26018eebfcb6d3583.jpg?imageMogr2/thumbnail/120x120/extent/120x120/background/d2hpdGU=/position/center/quality/80" alt=""> | ||
22 | - <h5>品牌品牌</h5> | ||
23 | - </div> | ||
24 | - <div class="count">上新10款<i class="iconfont"></i></div> | ||
25 | - </div> | ||
26 | - <div class="brand-news-count"> | ||
27 | - <div class="brand-logo"> | ||
28 | - <img src="//img11.static.yhbimg.com/brandLogo/2016/08/16/16/01cfd27979a572e6d26018eebfcb6d3583.jpg?imageMogr2/thumbnail/120x120/extent/120x120/background/d2hpdGU=/position/center/quality/80" alt=""> | ||
29 | - <h5>品牌品牌</h5> | ||
30 | - </div> | ||
31 | - <div class="count">上新10款<i class="iconfont"></i></div> | ||
32 | - </div> | ||
33 | - <div class="brand-news-count"> | ||
34 | - <div class="brand-logo"> | ||
35 | - <img src="//img11.static.yhbimg.com/brandLogo/2016/08/16/16/01cfd27979a572e6d26018eebfcb6d3583.jpg?imageMogr2/thumbnail/120x120/extent/120x120/background/d2hpdGU=/position/center/quality/80" alt=""> | ||
36 | - <h5>品牌品牌</h5> | ||
37 | - </div> | ||
38 | - <div class="count">上新10款<i class="iconfont"></i></div> | ||
39 | - </div> | ||
40 | - <div class="brand-news-count"> | ||
41 | - <div class="brand-logo"> | ||
42 | - <img src="//img11.static.yhbimg.com/brandLogo/2016/08/16/16/01cfd27979a572e6d26018eebfcb6d3583.jpg?imageMogr2/thumbnail/120x120/extent/120x120/background/d2hpdGU=/position/center/quality/80" alt=""> | ||
43 | - <h5>品牌品牌</h5> | ||
44 | - </div> | ||
45 | - <div class="count">上新10款<i class="iconfont"></i></div> | ||
46 | - </div> | ||
47 | - <div class="brand-news-count"> | ||
48 | - <div class="brand-logo"> | ||
49 | - <img src="//img11.static.yhbimg.com/brandLogo/2016/08/16/16/01cfd27979a572e6d26018eebfcb6d3583.jpg?imageMogr2/thumbnail/120x120/extent/120x120/background/d2hpdGU=/position/center/quality/80" alt=""> | ||
50 | - <h5>品牌品牌</h5> | ||
51 | - </div> | ||
52 | - <div class="count">上新10款<i class="iconfont"></i></div> | ||
53 | - </div> | ||
54 | - <div class="brand-news-count"> | ||
55 | - <div class="brand-logo"> | ||
56 | - <img src="//img11.static.yhbimg.com/brandLogo/2016/08/16/16/01cfd27979a572e6d26018eebfcb6d3583.jpg?imageMogr2/thumbnail/120x120/extent/120x120/background/d2hpdGU=/position/center/quality/80" alt=""> | ||
57 | - <h5>品牌品牌</h5> | ||
58 | - </div> | ||
59 | - <div class="count">上新10款<i class="iconfont"></i></div> | ||
60 | - </div> | 12 | + {{> product/brands}} |
61 | </div> | 13 | </div> |
62 | </div> | 14 | </div> |
1 | -<div class="good-info good-tags season-tags "> | ||
2 | - <div> | ||
3 | - <ul class="good-tags-list"> | ||
4 | - <li><a href="#" class="good-tag">夹克</a></li> | ||
5 | - <li><a href="#" class="good-tag">夹克</a></li> | ||
6 | - <li><a href="#" class="good-tag">夹克</a></li> | ||
7 | - <li><a href="#" class="good-tag">夹克</a></li> | ||
8 | - <li><a href="#" class="good-tag">夹克</a></li> | ||
9 | - <li><a href="#" class="good-tag">夹克</a></li> | ||
10 | - <li><a href="#" class="good-tag">夹克</a></li> | ||
11 | - <li><a href="#" class="good-tag">夹克</a></li> | ||
12 | - </ul> | ||
13 | - </div> | ||
14 | -</div> |
@@ -17,6 +17,7 @@ module.exports = { | @@ -17,6 +17,7 @@ module.exports = { | ||
17 | assetUrl: '//127.0.0.1:5001', | 17 | assetUrl: '//127.0.0.1:5001', |
18 | testCode: 'yoho4946abcdef#$%&!@', | 18 | testCode: 'yoho4946abcdef#$%&!@', |
19 | domains: { | 19 | domains: { |
20 | + api: 'http://api-test2.yohops.com:9999/', | ||
20 | // api: 'http://api-test3.yohops.com:9999/', | 21 | // api: 'http://api-test3.yohops.com:9999/', |
21 | // service: 'http://service-test3.yohops.com:9999/', | 22 | // service: 'http://service-test3.yohops.com:9999/', |
22 | // liveApi: 'http://testapi.live.yohops.com:9999/', | 23 | // liveApi: 'http://testapi.live.yohops.com:9999/', |
@@ -25,7 +26,7 @@ module.exports = { | @@ -25,7 +26,7 @@ module.exports = { | ||
25 | // imCs: 'http://im.yohobuy.com/api', | 26 | // imCs: 'http://im.yohobuy.com/api', |
26 | // imServer: 'http://im.yohobuy.com/server' | 27 | // imServer: 'http://im.yohobuy.com/server' |
27 | // api: 'http://192.168.102.205:8080/gateway/', | 28 | // api: 'http://192.168.102.205:8080/gateway/', |
28 | - api: 'http://api.yoho.cn/', | 29 | + // api: 'http://api.yoho.cn/', |
29 | service: 'http://service.yoho.cn/', | 30 | service: 'http://service.yoho.cn/', |
30 | liveApi: 'http://api.live.yoho.cn/', | 31 | liveApi: 'http://api.live.yoho.cn/', |
31 | singleApi: 'http://single.yoho.cn/', | 32 | singleApi: 'http://single.yoho.cn/', |
@@ -76,7 +77,7 @@ module.exports = { | @@ -76,7 +77,7 @@ module.exports = { | ||
76 | port: '4444' // influxdb port | 77 | port: '4444' // influxdb port |
77 | }, | 78 | }, |
78 | console: { | 79 | console: { |
79 | - level: 'info', | 80 | + level: 'debug', |
80 | colorize: 'all', | 81 | colorize: 'all', |
81 | prettyPrint: true | 82 | prettyPrint: true |
82 | } | 83 | } |
doraemon/views/partial/product/brands.hbs
0 → 100644
1 | +{{!--新品到着 品牌推荐--}} | ||
2 | +{{#each shops}} | ||
3 | +<div class="brand-news-count"> | ||
4 | + <div class="brand-logo"> | ||
5 | + <img src="{{image shop_logo 186 115}}" alt="{{shop_domain}}"> | ||
6 | + <h5>{{shop_name}}</h5> | ||
7 | + </div> | ||
8 | + <div class="count">上新{{new_product_num}}款<i class="iconfont"></i></div> | ||
9 | + <a class="link" href="http://m.yohobuy.com/product/index/brand?domain={{shop_domain}}"></a> | ||
10 | +</div> | ||
11 | +{{/each}} |
public/hbs/product/new/brands.hbs
0 → 100644
1 | +{{> product/brands}} |
public/hbs/product/new/goods.hbs
0 → 100644
1 | +{{# goods}} | ||
2 | + {{#if _isFashionArticle}} | ||
3 | + | ||
4 | + {{#with this.data}} | ||
5 | + {{> guang-article}} | ||
6 | + {{/with}} | ||
7 | + | ||
8 | + {{else if _isSeasonSort}} | ||
9 | + | ||
10 | + {{#with this.data}} | ||
11 | + {{> search-tag kind="season-tags" tags=this}} | ||
12 | + {{/with}} | ||
13 | + | ||
14 | + {{else if _isHotShop}} | ||
15 | + | ||
16 | + {{#with this.data}} | ||
17 | + {{> hot-shop}} | ||
18 | + {{/with}} | ||
19 | + | ||
20 | + {{else if _isHotSearchTerm}} | ||
21 | + | ||
22 | + {{#with this.data}} | ||
23 | + {{> search-tag kind="search-tags" tags=this}} | ||
24 | + {{/with}} | ||
25 | + | ||
26 | + {{else}} | ||
27 | + | ||
28 | + {{> common/goods}} | ||
29 | + | ||
30 | + {{/if}} | ||
31 | +{{/ goods}} |
1 | <div class="good-info"> | 1 | <div class="good-info"> |
2 | <div class="guang-article"> | 2 | <div class="guang-article"> |
3 | <div class="cate tip">潮品</div> | 3 | <div class="cate tip">潮品</div> |
4 | - <img src="//img13.static.yhbimg.com/article/2016/12/28/09/024949cb26c998cb9fccd2e0819e1a9e43.jpg?imageView2/2/w/640/h/640/q/60" alt=""> | 4 | + <img src="{{image src 322 214 1}}" alt=""> |
5 | <div class="footer"> | 5 | <div class="footer"> |
6 | - <p class="digest">Supreme这个牌子有什么超魔力为什么玩潮女生都爱穿它?</p> | 6 | + <p class="digest">{{title}}</p> |
7 | <div class="meta clearfix"> | 7 | <div class="meta clearfix"> |
8 | <div class="pull-left"> | 8 | <div class="pull-left"> |
9 | - <i class="iconfont"></i> <span>12月27日 13:05</span> | 9 | + <i class="iconfont"></i> <span>{{publish_time}}</span> |
10 | </div> | 10 | </div> |
11 | <div class="pull-right"> | 11 | <div class="pull-right"> |
12 | - <i class="iconfont"></i> <span>26789</span> | 12 | + <i class="iconfont"></i> <span>{{praise_num}}</span> |
13 | </div> | 13 | </div> |
14 | </div> | 14 | </div> |
15 | </div> | 15 | </div> |
public/hbs/product/new/hot-shop.hbs
0 → 100644
1 | +{{!-- 商品列表中的 品牌上新--}} | ||
2 | +<div class="good-info brand-info"> | ||
3 | + <img src="{{image shop_logo 240 100}}" alt="{{shop_name}}"> | ||
4 | + <h5 class="bname">{{shop_name}}</h5> | ||
5 | + <p class="summary">上新<span class="red">{{new_product_num}}</span>件 <span class="red">{{favorite_num}}</span>人收藏</p> | ||
6 | + <a href="//m.yohobuy.com/product/index/brand?domain={{shop_domain}}" class="entry">进入店铺</a> | ||
7 | +</div> |
public/hbs/product/new/search-tag.hbs
0 → 100644
1 | +{{!-- | ||
2 | +描述: 商品列表里的 特殊goods-info | ||
3 | + | ||
4 | +@param kind | ||
5 | +season-tags 应季热门 | ||
6 | +search-tags 热门搜索 | ||
7 | +brand-tags 热门品牌 【已废除】 | ||
8 | + | ||
9 | +@param tags ul 的数据 | ||
10 | +--}} | ||
11 | +<div class="good-info good-tags {{kind}} "> | ||
12 | + <div> | ||
13 | + <ul class="good-tags-list"> | ||
14 | + {{#each tags}} | ||
15 | + {{> (lookup .. 'kind')}} | ||
16 | + {{/each}} | ||
17 | + </ul> | ||
18 | + </div> | ||
19 | +</div> | ||
20 | + | ||
21 | + | ||
22 | + | ||
23 | +{{#*inline 'season-tags'}} | ||
24 | +{{!-- | ||
25 | + TODO: 如果要搜索品类,修改这里,目前是query查询 | ||
26 | +--}} | ||
27 | +<li> | ||
28 | + <a href="//search.m.yohobuy.com/?query={{encodeURIComponent categoryName}}&from=search" class="good-tag">{{categoryName}}</a> | ||
29 | +</li> | ||
30 | +{{/inline}} | ||
31 | + | ||
32 | + | ||
33 | + | ||
34 | +{{#*inline 'search-tags'}} | ||
35 | +<li> | ||
36 | + <a href="//search.m.yohobuy.com/?query={{encodeURIComponent .}}&from=search" class="good-tag">{{.}}</a> | ||
37 | +</li> | ||
38 | +{{/inline}} |
public/js/common/helpers/round.js
0 → 100644
1 | +'use strict'; | ||
1 | require('product/new-arrival.page.css'); | 2 | require('product/new-arrival.page.css'); |
3 | +require('common'); | ||
4 | +require('common/suspend-cart'); | ||
2 | 5 | ||
3 | let Swiper = require('yoho-swiper'); | 6 | let Swiper = require('yoho-swiper'); |
7 | +let lazyLoad = require('yoho-jquery-lazyload'); | ||
4 | 8 | ||
5 | - | ||
6 | -var mySwiper = new Swiper('.handpick-swiper', { | 9 | +let filter = require('plugin/filter'); |
10 | +let mySwiper = new Swiper('.handpick-swiper', { | ||
7 | // Optional parameters | 11 | // Optional parameters |
8 | loop: true, | 12 | loop: true, |
9 | 13 | ||
@@ -14,3 +18,97 @@ var mySwiper = new Swiper('.handpick-swiper', { | @@ -14,3 +18,97 @@ var mySwiper = new Swiper('.handpick-swiper', { | ||
14 | spaceBetween: 30, | 18 | spaceBetween: 30, |
15 | pagination: '.swiper-pagination', | 19 | pagination: '.swiper-pagination', |
16 | }); | 20 | }); |
21 | + | ||
22 | +// ============================================== | ||
23 | +// function: 为您推荐 | ||
24 | +let recommendShops = function() { | ||
25 | + let $container = $('#new-recommend'); | ||
26 | + let fetchURI = '/product/new/recommend-shop.json'; | ||
27 | + let template = require('product/new/brands.hbs'); | ||
28 | + | ||
29 | + // 渲染模版并插入 | ||
30 | + function render(shops) { | ||
31 | + let html = template({shops}); | ||
32 | + | ||
33 | + $container.find('.panel-body').append(html); | ||
34 | + } | ||
35 | + | ||
36 | + $.get(fetchURI).done(shopData => { | ||
37 | + render(shopData.shop_list || []); | ||
38 | + }); | ||
39 | +}; | ||
40 | + | ||
41 | +recommendShops(); | ||
42 | + | ||
43 | + | ||
44 | +// ============================================== | ||
45 | +let searchView = function() { | ||
46 | + let $c = $('#new-goods'); | ||
47 | + let $nav = $c.find('filter-nav'); | ||
48 | + let $goodsBox = $c.find('.goods-container'); | ||
49 | + | ||
50 | + let $prevNav = null; | ||
51 | + let goodsT = require('product/new/goods.hbs'); | ||
52 | + | ||
53 | + // 给nav 设置 数据属性 | ||
54 | + $nav.children('.new').data('order', ['new', '0']); // 从新到旧 | ||
55 | + $nav.children('.price').data('order', ['price', '1']); // 从低到高 | ||
56 | + $nav.children('.discount').data('order', ['discount', '0']); // 折扣从大到小 | ||
57 | + | ||
58 | + | ||
59 | + | ||
60 | + | ||
61 | + function initFilter() { | ||
62 | + $.get('/product/new/goods-filter').done(filterHtml => { | ||
63 | + $('#js-filter').replaceWith(filterHtml); | ||
64 | + | ||
65 | + filter.initFilter({ | ||
66 | + fCbFn: $.noop, | ||
67 | + hCbFn: $.noop | ||
68 | + }); | ||
69 | + }); | ||
70 | + } | ||
71 | + | ||
72 | + | ||
73 | + function switchNav($nextNav) { | ||
74 | + | ||
75 | + } | ||
76 | + | ||
77 | + function renderGoods($container, data) { | ||
78 | + let html = goodsT({ | ||
79 | + goods: data | ||
80 | + }); | ||
81 | + | ||
82 | + $container.append(html); | ||
83 | + lazyLoad($container.find('.lazy')); | ||
84 | + } | ||
85 | + | ||
86 | + // search state | ||
87 | + function fetchNew(searchParams) { | ||
88 | + return $.get('/product/new/goods.json', searchParams) | ||
89 | + .then(data => { | ||
90 | + console.log(data); | ||
91 | + renderGoods($('.goods-container'), data.list); | ||
92 | + }); | ||
93 | + } | ||
94 | + | ||
95 | + | ||
96 | + $nav.on('click', 'li', function(event) { | ||
97 | + let $curNav = $(event.target); | ||
98 | + | ||
99 | + switchNav($curNav); | ||
100 | + }); | ||
101 | + | ||
102 | + initFilter(); | ||
103 | + | ||
104 | + return { | ||
105 | + fetchNew, | ||
106 | + switchNav | ||
107 | + }; | ||
108 | +}; | ||
109 | + | ||
110 | + | ||
111 | +window.search = searchView(); | ||
112 | +window.$ = $; | ||
113 | + | ||
114 | + |
@@ -31,6 +31,10 @@ body { | @@ -31,6 +31,10 @@ body { | ||
31 | } | 31 | } |
32 | } | 32 | } |
33 | 33 | ||
34 | +.new-recommend .panel-body { | ||
35 | + min-height: 193px; | ||
36 | +} | ||
37 | + | ||
34 | .filter-nav { | 38 | .filter-nav { |
35 | border-top: 1PX solid #dededf; | 39 | border-top: 1PX solid #dededf; |
36 | border-bottom: 1PX solid #dededf; | 40 | border-bottom: 1PX solid #dededf; |
@@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
5 | background-color: #f0f0f0; | 5 | background-color: #f0f0f0; |
6 | } | 6 | } |
7 | 7 | ||
8 | -.new-brands { | 8 | +.recommend-brands { |
9 | .panel-header { | 9 | .panel-header { |
10 | border-bottom: none; | 10 | border-bottom: none; |
11 | } | 11 | } |
@@ -25,4 +25,8 @@ | @@ -25,4 +25,8 @@ | ||
25 | height: auto; | 25 | height: auto; |
26 | } | 26 | } |
27 | } | 27 | } |
28 | +} | ||
29 | + | ||
30 | +.new-brands .brand-news-count .count{ | ||
31 | + display: none; | ||
28 | } | 32 | } |
@@ -6,6 +6,7 @@ | @@ -6,6 +6,7 @@ | ||
6 | } | 6 | } |
7 | 7 | ||
8 | .brand-news-count { | 8 | .brand-news-count { |
9 | + position: relative; | ||
9 | display: inline-block; | 10 | display: inline-block; |
10 | color: #fff; | 11 | color: #fff; |
11 | text-align: center; | 12 | text-align: center; |
@@ -21,6 +22,9 @@ | @@ -21,6 +22,9 @@ | ||
21 | margin-bottom: 25px; | 22 | margin-bottom: 25px; |
22 | 23 | ||
23 | h5 { | 24 | h5 { |
25 | + text-overflow: ellipsis; | ||
26 | + white-space: nowrap; | ||
27 | + overflow: hidden; | ||
24 | color: #b8b8b8; | 28 | color: #b8b8b8; |
25 | } | 29 | } |
26 | } | 30 | } |
@@ -39,4 +43,12 @@ | @@ -39,4 +43,12 @@ | ||
39 | font-size: inherit; | 43 | font-size: inherit; |
40 | } | 44 | } |
41 | } | 45 | } |
46 | + | ||
47 | + .link { | ||
48 | + position: absolute; | ||
49 | + top: 0; | ||
50 | + right: 0; | ||
51 | + bottom: 0; | ||
52 | + left: 0; | ||
53 | + } | ||
42 | } | 54 | } |
@@ -79,7 +79,29 @@ exports.processProductList = (list, options) => { | @@ -79,7 +79,29 @@ exports.processProductList = (list, options) => { | ||
79 | } | 79 | } |
80 | 80 | ||
81 | // 商品信息有问题,则不显示 | 81 | // 商品信息有问题,则不显示 |
82 | - if (!product.product_id || !product.goods_list || product.goods_list.length === 0) { | 82 | + if (!( |
83 | + (product.product_id && _.get(product, 'goods_list.length', 0)) || product.recommend_type | ||
84 | + )) { | ||
85 | + return; | ||
86 | + } | ||
87 | + | ||
88 | + | ||
89 | + if (product.recommend_type) { | ||
90 | + // recommend_type 对应 附加属性 | ||
91 | + let flagMap = { | ||
92 | + fashionArticle: '_isFashionArticle', | ||
93 | + seasonSort: '_isSeasonSort', | ||
94 | + hotShop: '_isHotShop', | ||
95 | + hotSearchTerm: '_isHotSearchTerm', | ||
96 | + }; | ||
97 | + | ||
98 | + let extraAttr = flagMap[product.recommend_type]; | ||
99 | + | ||
100 | + if (extraAttr) { | ||
101 | + product[extraAttr] = true; | ||
102 | + pruductList.push(product); | ||
103 | + } | ||
104 | + | ||
83 | return; | 105 | return; |
84 | } | 106 | } |
85 | 107 |
-
Please register or login to post a comment