Showing
7 changed files
with
33 additions
and
12 deletions
@@ -17,12 +17,14 @@ const indexModel = require('../models/brand'); | @@ -17,12 +17,14 @@ const indexModel = require('../models/brand'); | ||
17 | * @param int channel 1表示男生频道, 2表示女生频道, 3表示潮童频道, 4表示创意生活频道 | 17 | * @param int channel 1表示男生频道, 2表示女生频道, 3表示潮童频道, 4表示创意生活频道 |
18 | */ | 18 | */ |
19 | let index = (req, res, next) => { | 19 | let index = (req, res, next) => { |
20 | + let genders = req.cookies._Channel || 'boys'; | ||
21 | + | ||
20 | let responseData = { | 22 | let responseData = { |
21 | module: 'channel', | 23 | module: 'channel', |
22 | page: 'brand', | 24 | page: 'brand', |
23 | 25 | ||
24 | // title: '品牌一览 | Yoho!Buy有货 | 潮流购物逛不停', | 26 | // title: '品牌一览 | Yoho!Buy有货 | 潮流购物逛不停', |
25 | - showFooterTab: footerModel.getUrlData('category') | 27 | + showFooterTab: footerModel.getUrlData('category', genders) |
26 | }; | 28 | }; |
27 | 29 | ||
28 | let param = { | 30 | let param = { |
@@ -7,6 +7,8 @@ const footerModel = require('../../../doraemon/models/footer_tab'); // 底部tab | @@ -7,6 +7,8 @@ const footerModel = require('../../../doraemon/models/footer_tab'); // 底部tab | ||
7 | const helpers = global.yoho.helpers; | 7 | const helpers = global.yoho.helpers; |
8 | 8 | ||
9 | let index = (req, res, next) => { | 9 | let index = (req, res, next) => { |
10 | + let gender = req.cookies._Channel || 'boys'; | ||
11 | + | ||
10 | cateModel.getCateData(req.yoho.channel).then((result) => { | 12 | cateModel.getCateData(req.yoho.channel).then((result) => { |
11 | res.render('cate', { | 13 | res.render('cate', { |
12 | module: 'channel', | 14 | module: 'channel', |
@@ -18,7 +20,7 @@ let index = (req, res, next) => { | @@ -18,7 +20,7 @@ let index = (req, res, next) => { | ||
18 | list: result.list, | 20 | list: result.list, |
19 | searchUrl: helpers.urlFormat('/search', null, 'search') | 21 | searchUrl: helpers.urlFormat('/search', null, 'search') |
20 | }, | 22 | }, |
21 | - showFooterTab: footerModel.getUrlData('category') | 23 | + showFooterTab: footerModel.getUrlData('category', gender) |
22 | }); | 24 | }); |
23 | }).catch(next); | 25 | }).catch(next); |
24 | }; | 26 | }; |
@@ -11,16 +11,19 @@ const footerModel = require('../../../doraemon/models/footer_tab'); // 底部tab | @@ -11,16 +11,19 @@ const footerModel = require('../../../doraemon/models/footer_tab'); // 底部tab | ||
11 | 11 | ||
12 | const helpers = global.yoho.helpers; | 12 | const helpers = global.yoho.helpers; |
13 | 13 | ||
14 | -let _renderData = { | 14 | +let _renderData = (gender) => { |
15 | + return { | ||
15 | module: 'channel', | 16 | module: 'channel', |
16 | page: 'home', | 17 | page: 'home', |
17 | homeHeader: { | 18 | homeHeader: { |
18 | searchUrl: helpers.urlFormat('/search', null, 'search') | 19 | searchUrl: helpers.urlFormat('/search', null, 'search') |
19 | }, | 20 | }, |
20 | maybeLike: true, | 21 | maybeLike: true, |
21 | - showFooterTab: footerModel.getUrlData('home'), | 22 | + showFooterTab: footerModel.getUrlData('home', gender), |
22 | pageFooter: true | 23 | pageFooter: true |
23 | -}; | 24 | + }; |
25 | + | ||
26 | +} | ||
24 | 27 | ||
25 | /** | 28 | /** |
26 | * 频道页生成函数 | 29 | * 频道页生成函数 |
@@ -30,12 +33,14 @@ let _renderData = { | @@ -30,12 +33,14 @@ let _renderData = { | ||
30 | * @return {[type]} | 33 | * @return {[type]} |
31 | */ | 34 | */ |
32 | let _channelPage = (req, res, data) => { | 35 | let _channelPage = (req, res, data) => { |
36 | + let gender = req.cookies._Channel || 'boys'; | ||
33 | return channelModel.getChannelData({ | 37 | return channelModel.getChannelData({ |
34 | gender: data.gender, | 38 | gender: data.gender, |
35 | uid: _.toString(req.user.uid), | 39 | uid: _.toString(req.user.uid), |
36 | limit: 6// 首屏先获取前6个楼层,其余用ajax获取 | 40 | limit: 6// 首屏先获取前6个楼层,其余用ajax获取 |
37 | }).then(result => { | 41 | }).then(result => { |
38 | - _renderData.homeHeader.defaultTerms = result.defaultTerms; | 42 | + let links = _renderData(gender); |
43 | + links.homeHeader.defaultTerms = result.defaultTerms; | ||
39 | 44 | ||
40 | if (!result.content.length || !result.sideNav.length) { | 45 | if (!result.content.length || !result.sideNav.length) { |
41 | res.set('Cache-Control', 'no-cache'); | 46 | res.set('Cache-Control', 'no-cache'); |
@@ -52,7 +57,7 @@ let _channelPage = (req, res, data) => { | @@ -52,7 +57,7 @@ let _channelPage = (req, res, data) => { | ||
52 | // } | 57 | // } |
53 | // }].concat(result.content); | 58 | // }].concat(result.content); |
54 | // console.log(result.content[9]); | 59 | // console.log(result.content[9]); |
55 | - res.render('channel', Object.assign({}, _renderData, data, result, { | 60 | + res.render('channel', Object.assign({}, links, data, result, { |
56 | localCss: true | 61 | localCss: true |
57 | })); | 62 | })); |
58 | }); | 63 | }); |
@@ -153,11 +153,14 @@ const pageData = (req, res, next) => { | @@ -153,11 +153,14 @@ const pageData = (req, res, next) => { | ||
153 | * @param next | 153 | * @param next |
154 | */ | 154 | */ |
155 | const index = (req, res, next) => { | 155 | const index = (req, res, next) => { |
156 | + | ||
157 | + let gender = req.cookies._Channel || 'boys'; | ||
158 | + | ||
156 | let responseData = { | 159 | let responseData = { |
157 | module: 'guang', | 160 | module: 'guang', |
158 | page: 'index', | 161 | page: 'index', |
159 | title: '逛 | Yoho!Buy有货 | 潮流购物逛不停', | 162 | title: '逛 | Yoho!Buy有货 | 潮流购物逛不停', |
160 | - showFooterTab: footerModel.getUrlData('guang') | 163 | + showFooterTab: footerModel.getUrlData('guang', gender) |
161 | }; | 164 | }; |
162 | 165 | ||
163 | let param = { | 166 | let param = { |
@@ -23,6 +23,8 @@ exports.index = (req, res, next) => { | @@ -23,6 +23,8 @@ exports.index = (req, res, next) => { | ||
23 | udid: require('md5')(req.ip) | 23 | udid: require('md5')(req.ip) |
24 | }; | 24 | }; |
25 | 25 | ||
26 | + let gender = req.cookies._Channel || 'boys'; | ||
27 | + | ||
26 | indexModel.index(params).then(result => { | 28 | indexModel.index(params).then(result => { |
27 | if (result) { | 29 | if (result) { |
28 | res.render('home', Object.assign(result, { | 30 | res.render('home', Object.assign(result, { |
@@ -34,7 +36,7 @@ exports.index = (req, res, next) => { | @@ -34,7 +36,7 @@ exports.index = (req, res, next) => { | ||
34 | pageChannel: { | 36 | pageChannel: { |
35 | boys: true | 37 | boys: true |
36 | }, | 38 | }, |
37 | - showFooterTab: footerModel.getUrlData('mine') | 39 | + showFooterTab: footerModel.getUrlData('mine', gender) |
38 | })); | 40 | })); |
39 | } | 41 | } |
40 | }).catch(next); | 42 | }).catch(next); |
@@ -8,11 +8,18 @@ | @@ -8,11 +8,18 @@ | ||
8 | 8 | ||
9 | const helpers = global.yoho.helpers; | 9 | const helpers = global.yoho.helpers; |
10 | 10 | ||
11 | -exports.getUrlData = function(type) { | 11 | +let channels = { |
12 | + boys: '1,3', | ||
13 | + girls: '2,3', | ||
14 | + kids: '1,2,3', | ||
15 | + lifestyle: '1,2,3' | ||
16 | +}; | ||
17 | + | ||
18 | +exports.getUrlData = function(type, gender) { | ||
12 | const urlData = { | 19 | const urlData = { |
13 | indexUrl: helpers.urlFormat('/?go=1'), // 首页 | 20 | indexUrl: helpers.urlFormat('/?go=1'), // 首页 |
14 | categoryUrl: helpers.urlFormat('/cate'), // 分类 | 21 | categoryUrl: helpers.urlFormat('/cate'), // 分类 |
15 | - guangUrl: helpers.urlFormat('', null, 'guang'), // 逛首页 | 22 | + guangUrl: helpers.urlFormat('', {'gender': channels[gender]}, 'guang'), // 逛首页 |
16 | shoppingCartUrl: helpers.urlFormat('/cart/index/index'), // 购物车 | 23 | shoppingCartUrl: helpers.urlFormat('/cart/index/index'), // 购物车 |
17 | mineUrl: helpers.urlFormat('/home') // 个人中心 | 24 | mineUrl: helpers.urlFormat('/home') // 个人中心 |
18 | }; | 25 | }; |
-
Please register or login to post a comment