plusstar.js
2.28 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
/**
* 潮流优选
* @author: xiaoxiao<xiaoxiao.hao@yoho.cn>
* @date: 2016/08/04
*/
'use strict';
const mRoot = '../models';
const plusstarModel = require(`${mRoot}/plusstar`);
const headerModel = require('../../../doraemon/models/header'); // 头部model
let channels = {
boys: 1,
girl: 2,
kids: 3,
lifestyle: 4
};
/**
* 潮流优选首页
*/
exports.index = (req, res, next) => {
let isApp = req.query.app_version || req.query.appVersion || false;
let parameter = {};
let title = '潮流优选';
let gender = req.query.gender || req.cookies._Channel && channels[req.cookies._Channel] || 1;
if (isApp === false) {
parameter = {
pageHeader: headerModel.setNav({
navTitle: title
}),
pageFooter: true
};
}
plusstarModel.getAllChannels({gender: gender, app_type: 0}).then(result => {
res.render('plusstar/index', Object.assign({
page: 'plusstar-index',
result: result,
isApp: isApp,
title: title
}, parameter));
}).catch(next);
};
/**
* 潮流优选首页-资源位
*/
exports.resourcesTemplate = (req, res, next) => {
let isApp = req.query.app_version || req.query.appVersion || false;
let uid = '';
let param = {};
if (req.yoho.isApp) {
uid = req.query.uid;
} else {
uid = req.user.uid;
}
if (uid) {
param.uid = uid;
}
param.content_code = req.query.code || '';
param.yh_channel = req.query.yh_channel || 1;
plusstarModel.getResourcesData(param, {
isApp: isApp
}).then(result => {
res.render('plusstar/resources-template', {
layout: false,
result: result,
title: '潮流优选'
});
}).catch(next);
};
/**
* 潮流优选首页-资源位-商品列表
*/
exports.resourcesGoodsList = (req, res, next) => {
let productSkn = req.body.productSkn || '';
let isApp = req.body.app_version || req.body.appVersion || false;
plusstarModel.getProductBatch(productSkn.split(','), {
isApp: isApp
}).then(result => {
res.render('plusstar/resources-goodsList', {
layout: false,
goods: result,
title: '潮流优选'
});
}).catch(next);
};