Authored by biao

update for optimise code

... ... @@ -12,7 +12,6 @@ const _ = require('lodash');
const ServiceAPI = require(`${library}/api`).ServiceAPI;
const API = require(`${library}/api`).API;
const sign = require(`${library}/sign`);
const productProcess = require(`${utils}/product-process`);
const camelCase = require(`${library}/camel-case`);
const resourcesProcess = require(`${utils}/resources-process`);
... ... @@ -23,12 +22,10 @@ const api = new API();
const getOutletResource = (channel, contentcode) => {
console.log(contentcode);
const params = {
content_code: contentcode || 'c19ffa03f053f4cac3690b22c8da26b7',
limit: 25,
yh_channel: channel || '',
debug: 'XYZ'
yh_channel: channel || ''
};
return serviceApi.get('operations/api/v5/resource/home', sign.apiSign(params)).then(result => {
... ... @@ -53,6 +50,7 @@ const convertNavData = (list) => {
url: encodeURI(item.sortUrl)
});
});
return {data: formatData};
};
... ... @@ -75,25 +73,6 @@ const getNavData = (categoryId) => {
});
};
const getGoodsList = () => {
var params = {
method: 'app.search.category',
limit: 50,
page: 1,
outlets: 1
};
var data = {};
return api.get('', sign.apiSign(params)).then(res => {
if (res && res.code === 200) {
data = productProcess.processProductList(res.data.product_list);
}
return data;
});
};
const getActivityDetail = (id) => {
var params = {
method: 'app.outlets.activityGet',
... ... @@ -153,13 +132,12 @@ exports.getContent = (categoryId, channel, code) => {
id: 0
};
const p = [getNavData(categoryId), getOutletResource(channel, code), getHomeActivity(params), getGoodsList()];
const p = [getNavData(categoryId), getOutletResource(channel, code), getHomeActivity(params)];
return Promise.all(p).then(data => {
floorsData.nav = data[0] || [];
floorsData.content = data[1] || [];
floorsData.activity = {data: data[2]};
floorsData.goods = data[3];
return floorsData;
});
... ...