brands.js
1.99 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
/**
* 品牌一览 controller
* @author: ghw<hongwei.gao@yoho.cn>
* @date: 2016/9/29
*/
'use strict';
const mRoot = '../models';
const brandsService = require(`${mRoot}/brands-service`); // students 页 model
/**
* brands 首页
* @param {[type]} req [description]
* @param {[type]} res [description]
* @return {[type]} [description]
*/
exports.index = (req, res, next) => {
let channel = req.query.channel || req.cookies._Channel || 'boys';
req.ctx(brandsService).getBrandViewList(channel, req).then(result => {
// 返回null,不cashe
if (result.noCashe) {
res.set('Cache-Control', 'no-cache');
}
res.render('brands/brands', result);
}).catch(next);
};
/**
* brandList-Ajax调用
*/
exports.brandList = (req, res, next) => {
let channel = req.query.channel || req.cookies._Channel || 'boys';
req.ctx(brandsService).getBrandList(channel, req.body.start).then(result => {
res.render('brands/brand-list', Object.assign({layout: false}, result));
}).catch(next);
};
/**
* 品牌接口数据
*
* @param string brandId 获取品牌ID
* @return json
*/
exports.brandInfo = (req, res, next) => {
let brandId = req.query.brandId || 0;
req.ctx(brandsService).brandInfo(brandId, req.user.uid).then(result => {
// 返回null,不cashe
if (result.noCashe) {
res.set('Cache-Control', 'no-cache');
}
res.json(result);
}).catch(next);
};
/**
* 品牌plusstar列表
*/
exports.plusstarList = (req, res, next) => {
let channel = req.query.channel || req.yoho.channel;
req.ctx(brandsService).plusstarList(channel, req).then(result => {
// 返回null,不cashe
if (result.noCashe) {
res.set('Cache-Control', 'no-cache');
}
res.render('brands/plusstar', result);
}).catch(next);
};
/**
* 原url 301重定向到伪静态url
*/
exports.redirectNewPlusstar = (req, res) => {
res.redirect(301, `/${req.yoho.channel}`);
};