channel.js
1.18 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
/**
* 主页
* @author: Bi Kai<kai.bi@yoho.cn>
* @date: 2016/05/09
*/
'use strict';
const channelModel = require('../models/channel');
/**
* 频道选择页
*/
module.exports = {
index(req, res) {
let channel = req.path.split('/')[1] || req.yoho.channel;
res.render('index', {
module: 'channel',
page: 'home',
channel: channel
});
},
channel(req, res, next) {
channelModel.getChannelData().then(result => {
return res.json(result);
}).catch(next);
},
resources(req, res, next) {
channelModel.getResourcesData(req.query).then(result => {
return res.json(result);
}).catch(next);
},
goods(req, res, next) {
channelModel.getGoodsData(req.query).then(result => {
return res.json(result);
}).catch(next);
},
sidebar(req, res, next) {
if (!req.xhr) {
return res.render('sidebar', {
module: 'channel',
page: 'sidebar'
});
}
channelModel.getSidebarData(req.query).then(result => {
return res.json(result);
}).catch(next);
}
};