Showing
3 changed files
with
107 additions
and
1 deletions
@@ -2,12 +2,56 @@ | @@ -2,12 +2,56 @@ | ||
2 | * @Author: Targaryen | 2 | * @Author: Targaryen |
3 | * @Date: 2016-05-21 10:59:20 | 3 | * @Date: 2016-05-21 10:59:20 |
4 | * @Last Modified by: Targaryen | 4 | * @Last Modified by: Targaryen |
5 | - * @Last Modified time: 2016-05-21 13:22:46 | 5 | + * @Last Modified time: 2016-06-02 15:17:03 |
6 | */ | 6 | */ |
7 | 7 | ||
8 | 'use strict'; | 8 | 'use strict'; |
9 | +const headerModel = require('../../../doraemon/models/header'); | ||
10 | +const mRoot = '../models'; | ||
11 | + | ||
12 | +// list 页 model | ||
13 | +const list = require(`${mRoot}/list`); | ||
9 | 14 | ||
10 | exports.getProductPic = (req, res) => { | 15 | exports.getProductPic = (req, res) => { |
11 | 16 | ||
12 | res.jsonp(); | 17 | res.jsonp(); |
13 | }; | 18 | }; |
19 | + | ||
20 | +/** | ||
21 | + * 商品列表页 | ||
22 | + * @param {[type]} req [description] | ||
23 | + * @param {[type]} res [description] | ||
24 | + * @return {[type]} [description] | ||
25 | + */ | ||
26 | +exports.index = (req, res) => { | ||
27 | + let params = Object.assign({ | ||
28 | + saleType: 2, | ||
29 | + order: 's_t_asc,s_s_asc' | ||
30 | + }, req.query); | ||
31 | + | ||
32 | + let channel = req.query.channel || req.cookies._Channel || 'boys'; | ||
33 | + | ||
34 | + params.uid = req.user.uid || 0; | ||
35 | + | ||
36 | + let responseData = {}; | ||
37 | + | ||
38 | + headerModel.requestHeaderData().then(headerData => { | ||
39 | + responseData = headerModel.setHeaderData(headerData.data, 'vip'); | ||
40 | + responseData.module = 'product'; | ||
41 | + responseData.page = 'sale'; | ||
42 | + | ||
43 | + // responseData.footerTop = true; | ||
44 | + responseData.devEnv = true; | ||
45 | + | ||
46 | + list.getSaleOthersData(params, channel).then((result) => { | ||
47 | + responseData.saleList = result; | ||
48 | + responseData.resultShow = JSON.stringify(result, null, 4); | ||
49 | + | ||
50 | + res.render('sale/other', responseData); | ||
51 | + }); | ||
52 | + | ||
53 | + }).catch(() => { | ||
54 | + res.render('error', { devEnv: true, pageErr: true }); | ||
55 | + }); | ||
56 | + | ||
57 | +}; |
apps/product/models/list.js
0 → 100644
1 | +/* | ||
2 | + * @Author: Targaryen | ||
3 | + * @Date: 2016-06-02 15:11:15 | ||
4 | + * @Last Modified by: Targaryen | ||
5 | + * @Last Modified time: 2016-06-02 15:22:08 | ||
6 | + */ | ||
7 | + | ||
8 | +'use strict'; | ||
9 | +const library = '../../../library'; | ||
10 | +const utils = '../../../utils'; | ||
11 | +const API = require(`${library}/api`).API; | ||
12 | +const api = new API(); | ||
13 | +const saleApi = require('./sale-api'); | ||
14 | +const saleHandler = require('./sale-handler'); | ||
15 | +const productProcess = require(`${utils}/product-process`); | ||
16 | +const _ = require('lodash'); | ||
17 | + | ||
18 | +/** | ||
19 | + * 获取 VIP 会员专享和新降价专区数据 Controller 调用 | ||
20 | + * @return {[type]} [description] | ||
21 | + */ | ||
22 | +exports.getSaleOthersData = (params) => { | ||
23 | + | ||
24 | + let promiseObject = [ | ||
25 | + saleApi.getSaleGoodsList(params), | ||
26 | + saleApi.getLeftContentList() | ||
27 | + ]; | ||
28 | + | ||
29 | + return api.all(promiseObject).then(result => { | ||
30 | + let finalResult = {}; | ||
31 | + | ||
32 | + // 获取商品数据和顶部筛选条件 | ||
33 | + if (result[0].code === 200) { | ||
34 | + finalResult.goods = productProcess.processProductList(result[0].data.product_list); | ||
35 | + if (!_.isEmpty(result[0].data.filter)) { | ||
36 | + finalResult.filters = saleHandler.handleSaleFilterData(result[0].data.filter, params); | ||
37 | + } | ||
38 | + | ||
39 | + // 处理排序数据 | ||
40 | + finalResult.opts = saleHandler.handleSaleOptsData(params, result[0].data.total); | ||
41 | + finalResult.totalCount = result[0].data.total; | ||
42 | + finalResult.pager = saleHandler.handleSalePagerData(result[0].data.total, params); | ||
43 | + } | ||
44 | + | ||
45 | + // 获取左侧类目数据 | ||
46 | + if (result[1].code === 200) { | ||
47 | + if (params.gender === '2,3') { | ||
48 | + finalResult.leftContent = saleHandler.handleSaleSortData(result[1].data.girl, params); | ||
49 | + } else { | ||
50 | + finalResult.leftContent = saleHandler.handleSaleSortData(result[1].data.boy, params); | ||
51 | + } | ||
52 | + } | ||
53 | + | ||
54 | + return finalResult; | ||
55 | + }); | ||
56 | +}; |
@@ -18,6 +18,9 @@ const sale = require(`${cRoot}/sale`); | @@ -18,6 +18,9 @@ const sale = require(`${cRoot}/sale`); | ||
18 | // 奥特莱斯controller | 18 | // 奥特莱斯controller |
19 | const outlets = require(`${cRoot}/outlets`); | 19 | const outlets = require(`${cRoot}/outlets`); |
20 | 20 | ||
21 | +// 商品促销controller | ||
22 | +const list = require(`${cRoot}/list`); | ||
23 | + | ||
21 | // 商品促销routers | 24 | // 商品促销routers |
22 | router.get('/sale', sale.index); // sale 首页 | 25 | router.get('/sale', sale.index); // sale 首页 |
23 | router.get('/sale/discount/detail', sale.discount); // 折扣专场详情页 | 26 | router.get('/sale/discount/detail', sale.discount); // 折扣专场详情页 |
@@ -31,4 +34,7 @@ router.get('/outlets/index', outlets.index); | @@ -31,4 +34,7 @@ router.get('/outlets/index', outlets.index); | ||
31 | router.get('/outlets/special/detail', outlets.special); | 34 | router.get('/outlets/special/detail', outlets.special); |
32 | router.get('/outlets/:channel', outlets.channel); | 35 | router.get('/outlets/:channel', outlets.channel); |
33 | 36 | ||
37 | +// 商品列表页 | ||
38 | +router.get('/list', list.index); // 商品列表页 | ||
39 | + | ||
34 | module.exports = router; | 40 | module.exports = router; |
-
Please register or login to post a comment