...
|
...
|
@@ -4,6 +4,7 @@ |
|
|
* @date: 2016/05/09
|
|
|
*/
|
|
|
'use strict';
|
|
|
|
|
|
const library = '../../../library';
|
|
|
const utils = '../../../utils';
|
|
|
|
...
|
...
|
@@ -20,6 +21,7 @@ const log = require(`${library}/logger`); |
|
|
const serviceApi = new ServiceAPI();
|
|
|
const api = new API();
|
|
|
|
|
|
|
|
|
const getOutletResource = () => {
|
|
|
const params = {
|
|
|
content_code: 'c19ffa03f053f4cac3690b22c8da26b7',
|
...
|
...
|
@@ -112,14 +114,62 @@ const getActivityDetail = (id) => { |
|
|
});
|
|
|
};
|
|
|
|
|
|
const convertActicityData = (data) => {
|
|
|
const formatData = [];
|
|
|
var showMore = false;
|
|
|
var i;
|
|
|
|
|
|
data = data || [];
|
|
|
_.forEach(data, (item) => {
|
|
|
formatData.push({
|
|
|
activityUrl: 'outlet/activity?id=' + item.id,
|
|
|
coverUrl: item.coverUrl,
|
|
|
logoUrl: item.logoUrl,
|
|
|
title: item.title,
|
|
|
promotionName: item.promotionName,
|
|
|
startLeftTime: item.startLeftTime,
|
|
|
hide: false
|
|
|
});
|
|
|
});
|
|
|
|
|
|
|
|
|
if (formatData.length > 10) {
|
|
|
for (i = 10; i < formatData.length; i++) {
|
|
|
formatData[i].hide = true;
|
|
|
}
|
|
|
showMore = true;
|
|
|
}
|
|
|
|
|
|
return {data: formatData, showMore: showMore};
|
|
|
};
|
|
|
|
|
|
const getHomeActivity = (id) => {
|
|
|
var params = {
|
|
|
method: 'app.outlets.activityGet',
|
|
|
platform: 2,
|
|
|
size: 0,
|
|
|
yh_channel: 1,
|
|
|
type: id,
|
|
|
sort: 2,
|
|
|
client_type: 'h5'
|
|
|
};
|
|
|
|
|
|
return api.get('', sign.apiSign(params)).then(res => {
|
|
|
if (id === 0) {
|
|
|
return convertActicityData(res.data);
|
|
|
}
|
|
|
return res.data;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
exports.getContent = () => {
|
|
|
let floorsData = {};
|
|
|
|
|
|
return Promise.all([getNavData(), getOutletResource(), getGoodsList()]).then(data => {
|
|
|
return Promise.all([getNavData(), getOutletResource(), getHomeActivity(0), getGoodsList()]).then(data => {
|
|
|
floorsData.nav = data[0] || [];
|
|
|
floorsData.content = data[1] || [];
|
|
|
floorsData.goods = data[2];
|
|
|
floorsData.activity = data[2] || [];
|
|
|
floorsData.goods = data[3];
|
|
|
|
|
|
return floorsData;
|
|
|
});
|
...
|
...
|
@@ -135,3 +185,21 @@ exports.getActivity = (id) => { |
|
|
return data;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
exports.willBeEnd = () => {
|
|
|
return getHomeActivity(3).then(res => {
|
|
|
var data = {};
|
|
|
|
|
|
data.activity = res;
|
|
|
return data;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
exports.willBeCome = () => {
|
|
|
return getHomeActivity(4).then(res => {
|
|
|
var data = {};
|
|
|
|
|
|
data.activity = res;
|
|
|
return res;
|
|
|
});
|
|
|
}; |
...
|
...
|
|