Authored by yyq

头部菜单联调

... ... @@ -34,7 +34,7 @@ module.exports = () => {
}
res.render(path, data);
} else {
header.requestHeaderData('boys').then(result => {
header.requestHeaderData(req.yoho.channel).then(result => {
Object.assign(data, result);
// 登录状态
... ...
... ... @@ -11,9 +11,15 @@ module.exports = () => {
let yoho = {
pageChannel: {}
};
const channel = req.query.channel || req.cookies._Channel || 'boys';
const channel = req.query.channel || req.cookies._Channel || 'men';
// 用于头部颜色控制
yoho.pageChannel[channel] = true;
// 当前频道设置
yoho.channel = channel;
// 判断请求是否来自app
yoho.isApp = req.query.app_version || req.query.appVersion;
Object.assign(res.locals, yoho);
... ...
... ... @@ -57,7 +57,6 @@ const getNavBar = (data, type) => {
let obj = {},
lowEn = _.camelCase(item.sort_name_en).toLowerCase();
obj.link = item.sort_url;
obj.cn = item.sort_name;
obj.en = item.sort_name_en;
... ... @@ -67,11 +66,6 @@ const getNavBar = (data, type) => {
obj.cur = true;
}
// 奥莱频道显示图片,特殊处理
if (lowEn === 'outlets') {
obj.ico = item.sort_ico;
}
navBars.push(obj);
});
... ... @@ -95,7 +89,6 @@ const getBrandItems = (data) => {
});
});
return brandItems;
};
... ... @@ -179,9 +172,15 @@ const setHeaderData = (resData, type) => (
}
);
/**
* 请求头部菜单数据
* @param {String} 频道类型
* @return {promise}
*/
const requestNavBar = (type) => {
return serviceApi.get('operations/api/v6/category/getCategory', {
client_type: 'web'
client_type: 'web',
parent_id: 1155 // 接口写死blk菜单pid为1155
}, {
cache: true,
code: 200
... ... @@ -198,8 +197,6 @@ const requestNavBar = (type) => {
* @return {promise}
*/
exports.requestHeaderData = (type) => {
let data = {};
let arr = [
getMenuData()
];
... ... @@ -209,7 +206,7 @@ exports.requestHeaderData = (type) => {
}
return Promise.all(arr).then(result => {
return Object.assign(data, {
return Object.assign({
pageHeader: result[0]
}, result[1]);
});
... ...