Showing
7 changed files
with
70 additions
and
15 deletions
@@ -18,6 +18,12 @@ const saleLogger = (err, res) => { | @@ -18,6 +18,12 @@ const saleLogger = (err, res) => { | ||
18 | res.send('error'); | 18 | res.send('error'); |
19 | }; | 19 | }; |
20 | 20 | ||
21 | +const typeCont = { | ||
22 | + price: ['s_p_desc', 's_p_asc'], | ||
23 | + discount: ['p_d_desc', 'p_d_asc'], | ||
24 | + sales: ['s_n_desc', 's_n_asc'], | ||
25 | + newest: ['s_t_desc', 's_t_asc'] | ||
26 | +}; | ||
21 | 27 | ||
22 | /** | 28 | /** |
23 | * sale 首页 | 29 | * sale 首页 |
@@ -173,3 +179,24 @@ exports.vip = (req, res) => { | @@ -173,3 +179,24 @@ exports.vip = (req, res) => { | ||
173 | saleLogger(err, res); | 179 | saleLogger(err, res); |
174 | }); | 180 | }); |
175 | }; | 181 | }; |
182 | + | ||
183 | +exports.search = (req, res) => { | ||
184 | + let setting = { | ||
185 | + limit: '5', | ||
186 | + page: req.query.page, | ||
187 | + yh_channel: '1', | ||
188 | + productSize: '384x511' | ||
189 | + }; | ||
190 | + let type = req.query.type; | ||
191 | + let order = req.query.order; | ||
192 | + | ||
193 | + if (typeCont[type]) { | ||
194 | + setting.order = typeCont[type][order]; | ||
195 | + } | ||
196 | + | ||
197 | + saleModel.getSearchData(setting).then((result) => { | ||
198 | + result.goods = {}; | ||
199 | + result.layout = false; | ||
200 | + res.render('product', result); | ||
201 | + }); | ||
202 | +}; |
@@ -47,6 +47,37 @@ const processSpecial = (list) => { | @@ -47,6 +47,37 @@ const processSpecial = (list) => { | ||
47 | return formatData; | 47 | return formatData; |
48 | }; | 48 | }; |
49 | 49 | ||
50 | +/** | ||
51 | + * 商品搜索数据处理 | ||
52 | + */ | ||
53 | +const processSearch = (list) => { | ||
54 | + // const formartData = []; | ||
55 | + | ||
56 | + // let goods = {}; | ||
57 | + | ||
58 | + list = list || []; | ||
59 | + | ||
60 | + // _.forEach(camelCase(list.data.product_list), (data) => { | ||
61 | + | ||
62 | + // }); | ||
63 | +}; | ||
64 | + | ||
65 | +/** | ||
66 | + * 获取商品数据 | ||
67 | + */ | ||
68 | +exports.getSearchData = (params) => { | ||
69 | + return api.get('', sign.apiSign(Object.assign({ | ||
70 | + method: 'app.search.sales' | ||
71 | + }, params))).then((result) => { | ||
72 | + if (result && result.code === 200) { | ||
73 | + return processSearch(result); | ||
74 | + } else { | ||
75 | + logger.error('SALE 商品搜索返回 code 不是 200'); | ||
76 | + return []; | ||
77 | + } | ||
78 | + }); | ||
79 | +}; | ||
80 | + | ||
50 | exports.getSaleResources = () => { | 81 | exports.getSaleResources = () => { |
51 | return serviceAPI.get('operations/api/v5/resource/get', sign.apiSign({ | 82 | return serviceAPI.get('operations/api/v5/resource/get', sign.apiSign({ |
52 | content_code: '7c2b77093421efa8ae9302c91460db73' | 83 | content_code: '7c2b77093421efa8ae9302c91460db73' |
@@ -61,18 +92,6 @@ exports.getSaleResources = () => { | @@ -61,18 +92,6 @@ exports.getSaleResources = () => { | ||
61 | }; | 92 | }; |
62 | 93 | ||
63 | /** | 94 | /** |
64 | - * 获取首页数据 | ||
65 | - * @param {[object]} params | ||
66 | - * @return {[object]} | ||
67 | - */ | ||
68 | -exports.getSaleData = (params) => { | ||
69 | - | ||
70 | - return api.get('', sign.apiSign(Object.assign({ | ||
71 | - method: 'app.search.sales' | ||
72 | - }, params))); | ||
73 | -}; | ||
74 | - | ||
75 | -/** | ||
76 | * 获取折扣专场专题列表数据 | 95 | * 获取折扣专场专题列表数据 |
77 | * @param {[object]} params | 96 | * @param {[object]} params |
78 | * @return {[object]} | 97 | * @return {[object]} |
@@ -27,6 +27,8 @@ router.get('/specialDetail', sale.specialDetail); | @@ -27,6 +27,8 @@ router.get('/specialDetail', sale.specialDetail); | ||
27 | router.get('/breakCode', sale.breakCode); | 27 | router.get('/breakCode', sale.breakCode); |
28 | router.get('/vip', sale.vip); | 28 | router.get('/vip', sale.vip); |
29 | 29 | ||
30 | +router.get('/sale/search', sale.search); | ||
31 | + | ||
30 | // router.get('/outlet', sale.outlet); | 32 | // router.get('/outlet', sale.outlet); |
31 | 33 | ||
32 | module.exports = router; | 34 | module.exports = router; |
apps/product/views/action/product.hbs
0 → 100644
1 | <div class="banner"> | 1 | <div class="banner"> |
2 | <img src="{{image src 640 200}}"/> | 2 | <img src="{{image src 640 200}}"/> |
3 | + {{# activityTime}} | ||
3 | <p class="activity-time" data-time-ms = '{{msTime}}'><i class="iconfont time-ico"></i><span>剩1天2小时38分4秒</span></p> | 4 | <p class="activity-time" data-time-ms = '{{msTime}}'><i class="iconfont time-ico"></i><span>剩1天2小时38分4秒</span></p> |
5 | + {{/ activityTime}} | ||
4 | </div> | 6 | </div> |
5 | <ul id="list-nav" class="list-nav clearfix"> | 7 | <ul id="list-nav" class="list-nav clearfix"> |
6 | <li class="new active"> | 8 | <li class="new active"> |
1 | {{#if .}} {{!-- 剔除值为false的项 --}} | 1 | {{#if .}} {{!-- 剔除值为false的项 --}} |
2 | - <div class="good-info" data-id="{{id}}" data-bp-id="guang_goodList_{{name}}_false"> | 2 | + <div class="good-info" data-id="{{goodsId}}" data-bp-id="guang_goodList_{{name}}_false"> |
3 | <div class="tag-container clearfix"> | 3 | <div class="tag-container clearfix"> |
4 | {{# tags}} | 4 | {{# tags}} |
5 | {{# isNew}} | 5 | {{# isNew}} |
@@ -51,6 +51,7 @@ var $listNav = $('#list-nav'), | @@ -51,6 +51,7 @@ var $listNav = $('#list-nav'), | ||
51 | searching; | 51 | searching; |
52 | 52 | ||
53 | require('./suspend-cart'); // 悬浮购物车 | 53 | require('./suspend-cart'); // 悬浮购物车 |
54 | +require('../common'); | ||
54 | 55 | ||
55 | ellipsis.init(); | 56 | ellipsis.init(); |
56 | 57 | ||
@@ -151,7 +152,6 @@ function search(opt) { | @@ -151,7 +152,6 @@ function search(opt) { | ||
151 | } | 152 | } |
152 | 153 | ||
153 | nav = navInfo[navType]; | 154 | nav = navInfo[navType]; |
154 | - | ||
155 | page = nav.page + 1; | 155 | page = nav.page + 1; |
156 | if (nav.reload) { | 156 | if (nav.reload) { |
157 | page = 1; | 157 | page = 1; |
@@ -172,12 +172,14 @@ function search(opt) { | @@ -172,12 +172,14 @@ function search(opt) { | ||
172 | 172 | ||
173 | $.ajax({ | 173 | $.ajax({ |
174 | type: 'GET', | 174 | type: 'GET', |
175 | - url: '/product/newsale/selectNewSale', | 175 | + url: '/product/sale/search', |
176 | data: setting, | 176 | data: setting, |
177 | success: function(data) { | 177 | success: function(data) { |
178 | var $container, | 178 | var $container, |
179 | num; | 179 | num; |
180 | 180 | ||
181 | + console.log(data); | ||
182 | + | ||
181 | switch (navType) { | 183 | switch (navType) { |
182 | case 'newest': | 184 | case 'newest': |
183 | $container = $ngc; | 185 | $container = $ngc; |
-
Please register or login to post a comment