Authored by yyq

头部菜单联调

@@ -34,7 +34,7 @@ module.exports = () => { @@ -34,7 +34,7 @@ module.exports = () => {
34 } 34 }
35 res.render(path, data); 35 res.render(path, data);
36 } else { 36 } else {
37 - header.requestHeaderData('boys').then(result => { 37 + header.requestHeaderData(req.yoho.channel).then(result => {
38 Object.assign(data, result); 38 Object.assign(data, result);
39 39
40 // 登录状态 40 // 登录状态
@@ -11,9 +11,15 @@ module.exports = () => { @@ -11,9 +11,15 @@ module.exports = () => {
11 let yoho = { 11 let yoho = {
12 pageChannel: {} 12 pageChannel: {}
13 }; 13 };
14 - const channel = req.query.channel || req.cookies._Channel || 'boys'; 14 + const channel = req.query.channel || req.cookies._Channel || 'men';
15 15
  16 + // 用于头部颜色控制
16 yoho.pageChannel[channel] = true; 17 yoho.pageChannel[channel] = true;
  18 +
  19 + // 当前频道设置
  20 + yoho.channel = channel;
  21 +
  22 + // 判断请求是否来自app
17 yoho.isApp = req.query.app_version || req.query.appVersion; 23 yoho.isApp = req.query.app_version || req.query.appVersion;
18 24
19 Object.assign(res.locals, yoho); 25 Object.assign(res.locals, yoho);
@@ -57,7 +57,6 @@ const getNavBar = (data, type) => { @@ -57,7 +57,6 @@ const getNavBar = (data, type) => {
57 let obj = {}, 57 let obj = {},
58 lowEn = _.camelCase(item.sort_name_en).toLowerCase(); 58 lowEn = _.camelCase(item.sort_name_en).toLowerCase();
59 59
60 -  
61 obj.link = item.sort_url; 60 obj.link = item.sort_url;
62 obj.cn = item.sort_name; 61 obj.cn = item.sort_name;
63 obj.en = item.sort_name_en; 62 obj.en = item.sort_name_en;
@@ -67,11 +66,6 @@ const getNavBar = (data, type) => { @@ -67,11 +66,6 @@ const getNavBar = (data, type) => {
67 obj.cur = true; 66 obj.cur = true;
68 } 67 }
69 68
70 - // 奥莱频道显示图片,特殊处理  
71 - if (lowEn === 'outlets') {  
72 - obj.ico = item.sort_ico;  
73 - }  
74 -  
75 navBars.push(obj); 69 navBars.push(obj);
76 }); 70 });
77 71
@@ -95,7 +89,6 @@ const getBrandItems = (data) => { @@ -95,7 +89,6 @@ const getBrandItems = (data) => {
95 }); 89 });
96 }); 90 });
97 91
98 -  
99 return brandItems; 92 return brandItems;
100 }; 93 };
101 94
@@ -179,9 +172,15 @@ const setHeaderData = (resData, type) => ( @@ -179,9 +172,15 @@ const setHeaderData = (resData, type) => (
179 } 172 }
180 ); 173 );
181 174
  175 +/**
  176 + * 请求头部菜单数据
  177 + * @param {String} 频道类型
  178 + * @return {promise}
  179 + */
182 const requestNavBar = (type) => { 180 const requestNavBar = (type) => {
183 return serviceApi.get('operations/api/v6/category/getCategory', { 181 return serviceApi.get('operations/api/v6/category/getCategory', {
184 - client_type: 'web' 182 + client_type: 'web',
  183 + parent_id: 1155 // 接口写死blk菜单pid为1155
185 }, { 184 }, {
186 cache: true, 185 cache: true,
187 code: 200 186 code: 200
@@ -198,8 +197,6 @@ const requestNavBar = (type) => { @@ -198,8 +197,6 @@ const requestNavBar = (type) => {
198 * @return {promise} 197 * @return {promise}
199 */ 198 */
200 exports.requestHeaderData = (type) => { 199 exports.requestHeaderData = (type) => {
201 - let data = {};  
202 -  
203 let arr = [ 200 let arr = [
204 getMenuData() 201 getMenuData()
205 ]; 202 ];
@@ -209,7 +206,7 @@ exports.requestHeaderData = (type) => { @@ -209,7 +206,7 @@ exports.requestHeaderData = (type) => {
209 } 206 }
210 207
211 return Promise.all(arr).then(result => { 208 return Promise.all(arr).then(result => {
212 - return Object.assign(data, { 209 + return Object.assign({
213 pageHeader: result[0] 210 pageHeader: result[0]
214 }, result[1]); 211 }, result[1]);
215 }); 212 });