outlets.js
3.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/**
* 商品促销controller
* @author: yyq<yanqing.yang@yoho.cn>
* @date: 2016/5/19
*/
'use strict';
const mRoot = '../models';
const outlets = require(`${mRoot}/outlets`);
// 开发用模拟数据
// const simuOutlets = require(`${mRoot}/simu-outlets`);
// const outletsSimulation = require('../models/simulation');
/**
* outlets 首页
* @param {[type]} req [description]
* @param {[type]} res [description]
* @return {[type]} [description]
*/
exports.index = (req, res) => {
let resData = {
module: 'product',
page: 'outlets'
};
let channel = req.query.channel || req.cookies._Channel || 'boys';
// 首页模拟数据
// resData.result = simuOutlets.index();
outlets.getOutletsIndexData(req.query, channel).then(result => {
resData.result = result;
resData.headerData = result.headerData;
resData.resultShow = JSON.stringify(result, null, 4);
res.render('outlets/index', resData);
}).catch(() => {
resData.pageErr = true;
res.render('error', resData);
});
};
/**
* outlets 频道页
* @param {[type]} req [description]
* @param {[type]} res [description]
* @return {[type]} [description]
*/
exports.channel = (req, res) => {
let resData = {
module: 'product',
page: 'outlets'
};
// 首页模拟数据
// resData = outletsSimulation.outletBanner();
outlets.getOutletsChannelData(req.query, req.params.channel).then(result => {
res.render('outlets/channel', Object.assign(resData, result));
}).catch(() => {
resData.pageErr = true;
res.render('error', resData);
});
};
/**
* outlets 活动
* @param {[type]} req [description]
* @param {[type]} res [description]
* @return {[type]} [description]
*/
exports.special = (req, res) => {
let params = req.query;
let channel = req.query.channel || req.cookies._Channel || 'boys';
let resData = {
module: 'product',
page: 'outlets'
};
if (!params.id) {
resData.pageErr = true;
}
// 模拟数据
// resData = outletsSimulation.special();
outlets.getOutletsSpecialData(params, channel).then(result => {
res.render('outlets/special', Object.assign(resData, result));
}).catch(() => {
resData.pageErr = true;
res.render('error', resData);
});
};
/**
* 商品列表页
* @param {[type]} req [description]
* @param {[type]} res [description]
* @return {[type]} [description]
*/
exports.list = (req, res) => {
let params = Object.assign({
saleType: '4',
order: 's_t_asc,s_s_asc'
}, req.query);
let channel = req.query.channel || req.cookies._Channel || 'boys';
params.uid = req.user.uid || 0;
let responseData = {
module: 'product',
page: 'outlets'
};
outlets.getOutletsCategoryData(params, channel).then((result) => {
responseData.resultShow = JSON.stringify(result, null, 4);
res.render('sale/other', Object.assign(responseData, result));
}).catch(() => {
responseData.pageErr = true;
res.render('error', responseData);
});
};