sale.js
4.34 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
/**
* 商品促销controller
* @author: yyq<yanqing.yang@yoho.cn>
* @date: 2016/5/18
*/
'use strict';
const mRoot = '../models';
const sale = require(`${mRoot}/sale`); // sale 页 model
/**
* sale 首页
* @param {[type]} req [description]
* @param {[type]} res [description]
* @return {[type]} [description]
*/
exports.index = (req, res, next) => {
let channel = req.query.channel || req.cookies._Channel || 'boys';
// 真实数据输出
sale.getSaleIndexData(channel).then(result => {
res.render('sale/index', Object.assign({
module: 'product',
page: 'sale'
}, {
result: result,
headerData: result.headerData
}));
}).catch(next);
};
/**
* 折扣专场
* @param {[type]} req [description]
* @param {[type]} res [description]
* @return {[type]} [description]
*/
exports.discount = (req, res, next) => {
let params = Object.assign({
saleType: '3'
}, req.query);
let channel = req.query.channel || req.cookies._Channel || 'boys';
let responseData = {
module: 'product',
page: 'sale'
};
sale.getSaleDiscountData(params, channel).then((result) => {
responseData.result = result;
if (result) {
responseData.headerData = result.headerData;
}
res.render('sale/discount', responseData);
}).catch(next);
};
/**
* VIP会员专享
* @param {[type]} req [description]
* @param {[type]} res [description]
* @return {[type]} [description]
*/
exports.vip = (req, res, next) => {
let params = Object.assign({
saleType: '2'
}, req.query);
let channel = req.query.channel || req.cookies._Channel || 'boys';
params.uid = req.user.uid || 0;
sale.getSaleOthersData(params, channel).then((result) => {
res.render('sale/other', Object.assign({
module: 'product',
page: 'sale'
}, {
saleList: result,
headerData: result.headerData
}));
}).catch(next);
};
/**
* 新降价专区
* @param {[type]} req [description]
* @param {[type]} res [description]
* @return {[type]} [description]
*/
exports.newSale = (req, res, next) => {
let params = Object.assign({
order: 's_t_desc'
}, req.query);
let channel = req.query.channel || req.cookies._Channel || 'boys';
sale.getSaleOthersData(params, channel).then((result) => {
res.render('sale/other', Object.assign({
module: 'product',
page: 'sale'
}, {
saleList: result,
headerData: result.headerData
}));
}).catch(next);
};
/**
* 断码专区
* @param {[type]} req [description]
* @param {[type]} res [description]
* @return {[type]} [description]
*/
exports.breakingYards = (req, res, next) => {
let params = Object.assign({
saleType: '5'
}, req.query);
let channel = req.query.channel || req.cookies._Channel || 'boys';
let responseData = {
module: 'product',
page: 'sale'
};
sale.getSalebreakingYardsData(params, channel).then((result) => {
responseData.saleList = result;
if (result) {
responseData.headerData = result.headerData;
}
res.render('sale/other', responseData);
}).catch(next);
};
/**
* 活动
* @param {[type]} req [description]
* @param {[type]} res [description]
* @return {[type]} [description]
*/
exports.special = (req, res, next) => {
let params = req.query;
let specialId = params.specialsale_id || params.specialsaleId, // 专区ID
promotion = params.promotion; // 促销ID
if (!specialId && !promotion) {
return next();
}
sale.getSaleSpecialData(specialId, params, req.yoho.channel).then(result => {
res.render('sale/special', result);
}).catch(next);
};
/**
* Ajax 获取商品列表
* @param {[type]} req [description]
* @param {[type]} res [description]
* @return {[type]} [description]
*/
exports.getGoodsList = (req, res, next) => {
let params = req.query;
params.uid = req.user.uid || 0;
sale.getSaleGoodsData(params).then(result => {
let responseData = {};
responseData.footerTop = false;
responseData.layout = false;
responseData.result = result;
res.render('goods', responseData);
}).catch(next);
};