prefer.js
998 Bytes
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
/**
* 为你优选
* @author: shijian
* @date: 2016/12/6
*/
'use strict';
const preferModel = require('../models/prefer');
const _channel = (channel) => {
let yhChannel = 1;
switch (channel) {
case 'men':
yhChannel = 1;
break;
case 'women':
yhChannel = 2;
break;
case 'lifestyle':
yhChannel = 4;
break;
default:
break;
}
return yhChannel;
};
/**
* 个人中心主页
*/
const component = {
index: (req, res) => {
res.render('prefer', {
module: 'me',
page: 'prefer'
});
},
list(req, res, next) {
let params = {
yh_channel: _channel(req.query.channel || req.cookies._Channel || 'men'),
udid: req.sessionID
};
req.ctx(preferModel).getlist(params).then((result) => {
res.json(result);
}).catch(next);
}
};
module.exports = component;