new.js
1.92 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
/**
* 新品到着 controller
* @author: wsl<shuiling.wang@yoho.cn>
* @date: 2016/7/28
*/
'use strict';
const mRoot = '../models';
const utils = '../../../utils';
const headerModel = require('../../../doraemon/models/header');
const searchProcess = require(`${utils}/search-process`);
const newModel = require(`${mRoot}/new`);
const _ = require('lodash');
const helpers = global.yoho.helpers;
// 新品到着
const newGoods = (req, res, next) => {
let channel = req.cookies._Channel;
newModel.getNewFocus(channel).then((result) => {
res.render('new/new', {
module: 'product',
page: 'new',
title: '新品到着',
pageHeader: headerModel.setNav({
navTitle: '新品到着'
}),
headerBanner: result,
brand: '0',
sort: '0',
gender: req.query.gender ? req.query.gender : searchProcess.getGenderByChannel(channel),
channel: channel,
price: '0',
size: '0',
dayLimit: 1,
discount: '',
cartUrl: helpers.urlFormat('/cart/index/index', null),
pageFooter: true,
showDownloadApp: true
});
}).catch(next);
};
const selectNewSale = (req, res, next) => {
let params = _.assign({}, req.query);
newModel.getSearchData(params).then((result) => {
res.render('search/page', {
layout: false,
new: result
});
}).catch(next);
};
/**
* 筛选
* @param {[object]} req
* @param {[object]} res
* @return {[type]}
*/
let filter = (req, res, next) => {
let params = Object.assign({}, req.query);
newModel.getFilterData(params).then((result) => {
res.render('search/filter', {
layout: false,
params: params,
filter: result
});
}).catch(next);
};
module.exports = {
newGoods,
selectNewSale,
filter
};