newsale.js
1.93 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
/**
* 热销排行页面
* @author: zxr<xiaoru.zhang@yoho.cn>
* @date: 2016/09/22
*/
'use strict';
const newsaleModel = require('../models/newsale');
const headerModel = require('../../../doraemon/models/header');
let channels = {
boys: '1,3',
girl: '2,3',
kids: '1,2,3',
lifestyle: '1,2,3'
};
const index = (req, res, next) => {
let channel = req.yoho.channel || 'boys';
let codeKey = '';
switch (channel) {
case 'boys': // 男生
codeKey = '3cf2c1be5217fbab6009ce83959e1e12';
break;
case 'girls': // 女生
codeKey = '1cf7f9f10e2a2670e73d05c568793ad9';
break;
case 'kids': // 潮童
codeKey = '57457adececa6c748b29c90cad0ae940';
break;
case 'lifestyle': // 创意生活
codeKey = '04953a61cbf1db426a681e55d496d2fe';
break;
}
newsaleModel.getHotRank(codeKey).then((result) => {
res.render('newsale/hotrank', {
module: 'product',
page: 'hot-rank',
title: '热销排行榜',
pageHeader: headerModel.setNav({
navTitle: '热销排行榜'
}),
pageFooter: true,
headerBanner: result
});
}).catch(next);
};
const selectHotrank = (req, res, next) => {
let sort = req.query.sort;
let tab_id = req.query.tab_id;
let limit = 50;
let page = req.query.page || 1;
let notab = req.query.notab || 0;
let yhChannel = req.query.yh_channel || 1;
let gender = req.query.gender || req.cookies._Channel && channels[req.cookies._Channel] || '1,3';
newsaleModel.selectHotrank(yhChannel, gender, sort, tab_id, limit, page, notab).then((result) => {
res.render('newsale/hotlist', {
layout: false,
tabs: result.tabs,
goods: result.goods
});
}).catch(next);
};
module.exports = {
index,
selectHotrank
};