...
|
...
|
@@ -15,6 +15,8 @@ const api = new API(); |
|
|
const sign = require(`${library}/sign`);
|
|
|
const helpers = require(`${library}/helpers`);
|
|
|
const camelCase = require('../../../library/camel-case');
|
|
|
const saleApi = require('./sale-api');
|
|
|
const outletsProcess = require('./outlets-handler');
|
|
|
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -75,84 +77,20 @@ const channelCode = { |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 处理楼层数据
|
|
|
* @param {[array]} list
|
|
|
* @return {[array]}
|
|
|
*/
|
|
|
const processFloor = (list) => {
|
|
|
const formatData = [];
|
|
|
var floorData;
|
|
|
list = list || [];
|
|
|
list = camelCase(list);
|
|
|
|
|
|
//格式化数据
|
|
|
_.forEach(list, (floor) => {
|
|
|
if (floor.templateName === 'NL2R' && floor.data) {
|
|
|
floorData = NL2R(floor.data);
|
|
|
}
|
|
|
|
|
|
if (floor.templateName === 'hotCategory' && floor.data) {
|
|
|
floorData = hotCategory(floor.data);
|
|
|
console.log(floorData)
|
|
|
}
|
|
|
Object.assign(formatData, floorData);
|
|
|
|
|
|
});
|
|
|
return formatData;
|
|
|
};
|
|
|
|
|
|
//NL2R图片轮播
|
|
|
const NL2R = (data) => {
|
|
|
const result = {
|
|
|
left: [],
|
|
|
right: [],
|
|
|
};
|
|
|
//左侧
|
|
|
_.forEach(data.left, (value, key) => {
|
|
|
result.left.push({
|
|
|
img: value.src,
|
|
|
url: value.url
|
|
|
});
|
|
|
})
|
|
|
//右侧
|
|
|
_.forEach(data.right, (value, key) => {
|
|
|
result.right.push({
|
|
|
img: value.src,
|
|
|
url: value.url
|
|
|
});
|
|
|
})
|
|
|
return result
|
|
|
}
|
|
|
|
|
|
// 热门分类
|
|
|
const hotCategory = (data) => {
|
|
|
return {
|
|
|
hotCategory: {
|
|
|
name: data.name,
|
|
|
list: data.menuNav.list,
|
|
|
blocks: data.menuNav.blocks,
|
|
|
brands: data.imgs.slice(0, 1),
|
|
|
types: data.imgs.slice(1, 7)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 获取奥莱频道页面数据
|
|
|
* @param {[object]} gender
|
|
|
* @return {[type]}
|
|
|
*/
|
|
|
exports.getOutletsChannelData = (params) => {
|
|
|
|
|
|
return api.all([getChannelResouceData({content_code: channelCode[params.channel]}), getOutletsActivityData()]).then(result => {
|
|
|
if (resul[0].code === 200) {
|
|
|
return processFloor(result[0].data.list);
|
|
|
var channelData = {};
|
|
|
return api.all([getChannelResouceData({content_code: channelCode[params.channel]}), getOutletsActivityData({platform: 2, size: 0, type:1})]).then(result => {
|
|
|
if (result[0].code === 200) {
|
|
|
Object.assign(channelData, outletsProcess.processFloor(result[0].data.list));
|
|
|
}
|
|
|
|
|
|
if (resul[1].code === 200) {
|
|
|
|
|
|
if (result[1].code === 200) {
|
|
|
Object.assign(channelData, {flashSale: outletsProcess.formatActivityData(result[1].data)});
|
|
|
}
|
|
|
return channelData;
|
|
|
});
|
|
|
}
|
|
|
|
...
|
...
|
@@ -162,7 +100,7 @@ exports.getOutletsChannelData = (params) => { |
|
|
* @return {[type]}
|
|
|
*/
|
|
|
const getChannelResouceData = (params) => {
|
|
|
return serviceApi.get('operations/api/v5/resource/home', params)
|
|
|
return serviceApi.get('operations/api/v5/resource/home', sign.apiSign(params))
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -181,3 +119,17 @@ const getOutletsActivityData = (params) => { |
|
|
method: 'app.outlets.activityGet',
|
|
|
}, params)));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取奥莱频道商品分类
|
|
|
* @param {[object]} params
|
|
|
* @return {[type]}
|
|
|
*/
|
|
|
const getOutletsSortData = (params) => {
|
|
|
return api.get('', sign.apiSign(
|
|
|
Object.assign({
|
|
|
method: 'app.outlets.activityGet',
|
|
|
}, params)));
|
|
|
}
|
|
|
|
|
|
|
...
|
...
|
|