outlets.js
4.19 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
/**
* 商品促销controller
* @author: yyq<yanqing.yang@yoho.cn>
* @date: 2016/5/19
*/
'use strict';
const mRoot = '../models';
// const simuOutlets = require(`${mRoot}/simu-outlets`);
const headerModel = require('../../../doraemon/models/header');
// 开发用模拟数据
// const outletsSimulation = require('../models/simulation');
// sale 页 model
const outlets = require(`${mRoot}/outlets`);
/**
* outlets 首页
* @param {[type]} req [description]
* @param {[type]} res [description]
* @return {[type]} [description]
*/
exports.index = (req, res) => {
let responseData = {};
// 首页模拟数据
// responseData.result = simuOutlets.index();
headerModel.requestHeaderData().then(headerData => {
responseData = headerModel.setHeaderData(headerData.data, 'sale');
responseData.module = 'product';
responseData.page = 'outlets';
responseData.footerTop = true;
responseData.devEnv = true;
outlets.getOutletsIndexData(req.query).then(result => {
responseData.result = result;
responseData.resultShow = JSON.stringify(result, null, 4);
res.render('outlets/index', responseData);
});
});
};
/**
* outlets 频道页
* @param {[type]} req [description]
* @param {[type]} res [description]
* @return {[type]} [description]
*/
exports.channel = (req, res) => {
let channel = {
boys: 'true',
girls: 'true',
kids: 'true',
lifestyle: ''
};
let response = {};
// 错误页面
if (!channel[req.params.channel]) {
response.pageErr = true;
}
// 头部数据
headerModel.requestHeaderData().then(headerData => {
Object.assign(response, headerModel.setHeaderData(headerData.data, 'outlets'));
// 频道数据
outlets.getOutletsChannelData({ channel: req.params.channel }).then(outletsData => {
response.module = 'product';
response.page = 'outlets';
response.devEnv = true;
// 输出数据
Object.assign(response, outletsData);
res.render('outlets/channel', response);
});
// 假数据
// response.module = 'product';
// response.page = 'outlets';
// response.footerTop = true;
// response.devEnv = true;
// res.render('outlets/channel', Object.assign(response, outletsSimulation.outletBanner()));
});
// outlets.getOutletsChannelData({channel:req.params.channel}).then(outletsData => {
// response.module = 'product';
// response.page = 'sale';
// response.footerTop = true;
// response.devEnv = true;
// res.render('outlets/channel', Object.assing(response, outlets.outletBanner()));
// });
// 输出数据
// res.render('outlets/channel', Object.assign(response,
// outlets.getOutletsChannelData({'channel':req.params.channel})));
};
/**
* outlets 活动
* @param {[type]} req [description]
* @param {[type]} res [description]
* @return {[type]} [description]
*/
exports.special = (req, res) => {
let params = req.query;
let resData = {
module: 'product',
page: 'outlets',
devEnv: true
};
resData.mainBanner = {
url: '#',
src: 'http://img10.static.yhbimg.com/brandBanner/2014/11/24/07/01ff74fb2a33764c2fd18b3c8a60f5beef.jpg'
};
resData.specialHead = {
logo: 'http://img10.static.yhbimg.com/brandLogo/2012/08/02/15/0119ad6a2407f5505268688a470d6f6c13.jpg',
special: '精品上装专场',
discount: '8',
title: '全部商品',
count: '123533',
limit: '80000000'
};
headerModel.requestHeaderData().then(headerData => {
resData = Object.assign(resData, headerModel.setHeaderData(headerData.data, 'outlets'));
if (!params.id) {
resData.pageErr = true;
}
// res.render('outlets/special', resData);
outlets.getOutletsSpecialData(params).then(result => {
resData.specialHead = result.specialHead;
res.render('outlets/special', resData);
});
}).catch(() => {
resData.pageErr = true;
res.render('error', resData);
});
};