Authored by 郭成尧

'奥莱首页codereview'

... ... @@ -24,9 +24,10 @@ exports.index = (req, res) => {
let channel = req.query.channel || req.cookies._Channel || 'boys';
outlets.getOutletsIndexData(req.query, channel).then(result => {
resData.result = result;
resData.headerData = result.headerData;
resData.resultShow = JSON.stringify(result, null, 4);
Object.assign(resData, {
result: result,
headerData: result.headerData
});
res.render('outlets/index', resData);
}).catch((e) => {
log.error(e);
... ...
... ... @@ -171,8 +171,9 @@ exports.handleOutletsBannersData = (origin, params) => {
// 处理焦点图数据
if (value.template_name === 'focus') {
dest.mainBanner = {};
dest.mainBanner.list = value.data;
dest.mainBanner = {
list: value.data
};
}
// 处理三张小图数据
... ... @@ -182,16 +183,18 @@ exports.handleOutletsBannersData = (origin, params) => {
// 处理右侧一张图片
if (value.template_name === 'single_image') {
dest.limitedBuy.extra.sourceImg = {};
dest.limitedBuy.extra.sourceImg.href = value.data[0].url;
dest.limitedBuy.extra.sourceImg.img = value.data[0].src;
dest.limitedBuy.extra.sourceImg = {
href: value.data[0].url,
img: value.data[0].src
};
}
// 处理热销推荐数据
if (value.template_name === 'recommendCategory') {
dest.limitedBuy.extra.hotType = {};
dest.limitedBuy.extra.hotType.title = _.isEmpty(value.data.title) ? '热销推荐' : value.data.title;
dest.limitedBuy.extra.hotType.classify = [];
dest.limitedBuy.extra.hotType = {
title: _.isEmpty(value.data.title) ? '热销推荐' : value.data.title,
classify: []
};
_.forEach(value.data.categoryList, subValue => {
let category = {};
... ... @@ -207,9 +210,9 @@ exports.handleOutletsBannersData = (origin, params) => {
// 处理品类导航数据
if (value.template_name === 'categoryNavigation') {
dest.goodsBoard = {};
dest.goodsBoard.goodsMenu = handleOutletsGoodsMenuData(value.data, params);
dest.goodsBoard = {
goodsMenu: handleOutletsGoodsMenuData(value.data, params)
};
}
});
... ... @@ -233,9 +236,11 @@ exports.handleOutletsActivityData = (origin, name) => {
// 处理奥莱活动列表数据
_.forEach(origin, value => {
let activity = {};
let activity = {
href: helpers.urlFormat('/product/outlets/special/detail', {id: value.id})
};
activity.href = helpers.urlFormat('/product/outlets/special/detail', { id: value.id });
activity.href = helpers.urlFormat('/product/outlets/special/detail', {id: value.id});
activity.img = value.webCoverUrl;
activity.logo = value.logoUrl;
activity.title = value.title;
... ...
... ... @@ -37,11 +37,11 @@ exports.getOutletsIndexData = (params, channel) => {
return api.all([
headerModel.requestHeaderData('outlets'),
outletsApi.getChannelResouceData({ content_code: channelCode.index }),
outletsApi.getOutletsActivityOrigin({ type: '1', channel: channel }), // 获取限时活动列表
outletsApi.getOutletsActivityOrigin({ type: '2', channel: channel }), // 获取即将结束列表
outletsApi.getOutletsTrendData({ limit: '30' }), // 获取潮流速递商品数据
outletsApi.getOutletsGoodsList({ limit: params.limit || '100' }) // 获取底部商品数据
outletsApi.getChannelResouceData({content_code: channelCode.index}),
outletsApi.getOutletsActivityOrigin({type: '1', channel: channel}), // 获取限时活动列表
outletsApi.getOutletsActivityOrigin({type: '2', channel: channel}), // 获取即将结束列表
outletsApi.getOutletsTrendData({limit: '30'}), // 获取潮流速递商品数据
outletsApi.getOutletsGoodsList({limit: params.limit || '100'}) // 获取底部商品数据
]).then(result => {
let finalResult = {};
... ... @@ -76,9 +76,10 @@ exports.getOutletsIndexData = (params, channel) => {
// 处理底部商品数据
if (result[5].code === 200) {
finalResult.goodsBoard.list = productProcess.processProductList(result[5].data.product_list);
finalResult.goodsBoard.sort = publicHandler.handleSaleOptsData(params, result[5].data.total);
finalResult.goodsBoard.sort.newPage = true;
finalResult.goodsBoard = {
list: productProcess.processProductList(result[5].data.product_list),
sort: Object.assign(publicHandler.handleSaleOptsData(params, result[5].data.total), {newPage: true})
};
finalResult.pager = publicHandler.handleSalePagerData(result[5].data.total, params);
}
... ... @@ -129,6 +130,7 @@ exports.getOutletsChannelData = (params, channel) => {
if (result[1].code === 200) {
Object.assign(channelData, outletsProcess.processFloor(result[1].data.list, params));
}
// 限时嗨购
if (result[2].code === 200) {
channelData.nearOver = outletsProcess.handleOutletsActivityData(result[2].data, '限时嗨购');
... ...
... ... @@ -5,7 +5,7 @@
<div class="limit-extra right">
{{# extra}}
{{# sourceImg}}
<a href="{{#if herf}}{{href}}{{^}}javascript:;{{/if}}" class="source-img" target="_blank">
<a href="{{#if href}}{{href}}{{^}}javascript:;{{/if}}" class="source-img" target="_blank">
<img class="lazy" data-original="{{image img 380 506}}" width=100%>
</a>
{{/ sourceImg}}
... ...