Showing
1 changed file
with
29 additions
and
11 deletions
@@ -10,25 +10,43 @@ const utils = '../../../utils'; | @@ -10,25 +10,43 @@ const utils = '../../../utils'; | ||
10 | const headerModel = require('../../../doraemon/models/header'); | 10 | const headerModel = require('../../../doraemon/models/header'); |
11 | const searchProcess = require(`${utils}/search-process`); | 11 | const searchProcess = require(`${utils}/search-process`); |
12 | const newModel = require(`${mRoot}/new`); | 12 | const newModel = require(`${mRoot}/new`); |
13 | +const searchModel = require(`${mRoot}/search`); | ||
13 | const _ = require('lodash'); | 14 | const _ = require('lodash'); |
14 | const helpers = global.yoho.helpers; | 15 | const helpers = global.yoho.helpers; |
15 | 16 | ||
16 | // 新品到着(blk) | 17 | // 新品到着(blk) |
17 | -const blkNewGoods = (req, res) => { | 18 | +const blkNewGoods = (req, res, next) => { |
18 | let params = Object.assign({ | 19 | let params = Object.assign({ |
19 | isblknew: true | 20 | isblknew: true |
20 | }, req.query); | 21 | }, req.query); |
21 | 22 | ||
22 | - res.render('search/goods-list', { | ||
23 | - module: 'product', | ||
24 | - page: 'search-list', | ||
25 | - pageHeader: headerModel.setNav({ | ||
26 | - navTitle: req.query.title || req.query.sort_name || '新品抢先看' | ||
27 | - }), | ||
28 | - goodList: params, | ||
29 | - showDownloadApp: true, | ||
30 | - pageFooter: true | ||
31 | - }); | 23 | + // 获取第一页数据做服务端渲染 |
24 | + let uid = req.user.uid || 0; | ||
25 | + let initialData = _.assign({ | ||
26 | + gender: req.query.gender || '1,3', | ||
27 | + type: 'default', | ||
28 | + order: '0', | ||
29 | + page: 1, | ||
30 | + limit: 12 | ||
31 | + }, params); | ||
32 | + | ||
33 | + if (uid) { | ||
34 | + initialData.uid = uid; | ||
35 | + } | ||
36 | + | ||
37 | + searchModel.getSearchData(initialData).then(firstScreenGoodsList => { | ||
38 | + res.render('search/goods-list', { | ||
39 | + module: 'product', | ||
40 | + page: 'search-list', | ||
41 | + pageHeader: headerModel.setNav({ | ||
42 | + navTitle: req.query.title || req.query.sort_name || '新品抢先看' | ||
43 | + }), | ||
44 | + goodList: params, | ||
45 | + firstPageGoodsList: firstScreenGoodsList.list, | ||
46 | + showDownloadApp: true, | ||
47 | + pageFooter: true | ||
48 | + }); | ||
49 | + }).catch(next); | ||
32 | }; | 50 | }; |
33 | 51 | ||
34 | // 新品到着 | 52 | // 新品到着 |
-
Please register or login to post a comment