sale.js
2.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
/**
* 商品促销controller
* @author: yyq<yanqing.yang@yoho.cn>
* @date: 2016/5/18
*/
'use strict';
const headerModel = require('../../../doraemon/models/header');
const mRoot = '../models';
// sale 页 model
const sale = require(`${mRoot}/sale`);
const saleDiscount = require(`${mRoot}/sale-discount`);
/**
* sale 首页
* @param {[type]} req [description]
* @param {[type]} res [description]
* @return {[type]} [description]
*/
exports.index = (req, res) => {
headerModel.requestHeaderData()
.then(response => {
response = headerModel.setHeaderData(response.data, 'sale');
response.module = 'product';
response.page = 'sale';
response.footerTop = true;
response.devEnv = true;
// 假数据输出
// res.render('sale/index', Object.assign(response, sale.outputDevData()));
// 真实数据输出
return sale.getSaleDate().then(result => {
response.result = result;
response.resultShow = JSON.stringify(result, null, 4);
res.render('sale/index', response);
});
})
.catch(() => {
res.render('error', { devEnv: true, pageErr: true });
});
};
/**
* 折扣专场
* @param {[type]} req [description]
* @param {[type]} res [description]
* @return {[type]} [description]
*/
exports.discount = (req, res) => {
headerModel.requestHeaderData()
.then(response => {
response = headerModel.setHeaderData(response.data, 'sale-discount');
response.module = 'product';
response.page = 'sale';
response.footerTop = true;
response.devEnv = true;
return saleDiscount.getSaleDiscountData()
.then(result => {
response.result = result;
response.resultShow = JSON.stringify(result, null, 4);
res.render('sale/discount', response);
});
})
.catch(() => {
res.render('error', { devEnv: true, pageErr: true });
});
};