...
|
...
|
@@ -6,13 +6,13 @@ const helpers = global.yoho.helpers; |
|
|
|
|
|
const yhChannel = {
|
|
|
1: {
|
|
|
channel: '301'
|
|
|
channel: '1'
|
|
|
},
|
|
|
2: {
|
|
|
channel: '302'
|
|
|
channel: '2'
|
|
|
},
|
|
|
4: {
|
|
|
channel: '303'
|
|
|
channel: '3'
|
|
|
}
|
|
|
};
|
|
|
|
...
|
...
|
@@ -219,20 +219,25 @@ const _processCateData = (list, channel, appType) => { |
|
|
};
|
|
|
};
|
|
|
|
|
|
// const _dealBrandUrl = (list) => {
|
|
|
// var domain;
|
|
|
|
|
|
// _.forEach(list.data, function(val) {
|
|
|
// domain = val.url.substring(val.url.indexOf('shop/') + 5, val.url.indexOf('?'));
|
|
|
|
|
|
// val.url = '//m.yohobuy.com/product/index/brand?domain=' + domain;
|
|
|
// });
|
|
|
const _getCateData = (channel, appType) => {
|
|
|
return api.get('', {
|
|
|
method: 'app.sort.get',
|
|
|
app_type: 1
|
|
|
}, {
|
|
|
cache: true
|
|
|
}).then((result) => {
|
|
|
if (!result.code || result.code !== 200 || !result.data) {
|
|
|
return [];
|
|
|
}
|
|
|
|
|
|
// return list;
|
|
|
// };
|
|
|
return result.data;
|
|
|
}).then((list) => {
|
|
|
return _processCateData(list, channel, appType);
|
|
|
});
|
|
|
};
|
|
|
|
|
|
const indexData = (gender, brandCode, cateCode) => {
|
|
|
return Promise.all([_getChannelData(gender), _getResourcesData(brandCode), _getBrandListOriginData(gender), _getResourcesData(cateCode)]).then(result => {
|
|
|
const indexData = (gender, brandCode, channel, appType) => {
|
|
|
return Promise.all([_getChannelData(gender), _getResourcesData(brandCode), _getBrandListOriginData(gender), _getCateData(channel, appType)]).then(result => {
|
|
|
let brandList = {};
|
|
|
let list = {};
|
|
|
let categoryData = {};
|
...
|
...
|
@@ -245,10 +250,8 @@ const indexData = (gender, brandCode, cateCode) => { |
|
|
if (result[1]) {
|
|
|
_.forEach(result[1], function(data) {
|
|
|
if (data.focus_type && data.focus_type === '1') {
|
|
|
// brandList.bannerTop = _dealBrandUrl(data);
|
|
|
brandList.bannerTop = data;
|
|
|
} else if (data.focus_type && data.focus_type === '2') {
|
|
|
// brandList.focusData = _dealBrandUrl(data).data;
|
|
|
brandList.focusData = data.data;
|
|
|
} else if (data.template_name === 'single_image') {
|
|
|
brandList.bannerTop = data;
|
...
|
...
|
@@ -263,26 +266,12 @@ const indexData = (gender, brandCode, cateCode) => { |
|
|
}
|
|
|
|
|
|
if (result[3]) {
|
|
|
_.forEach(result[3], function(data) {
|
|
|
if (data.template_name === 'recommend_content_five') {
|
|
|
// _.forEach(data.data.list, function(val) {
|
|
|
// var param = val.url.substring(val.url.indexOf('list?') + 5);
|
|
|
|
|
|
// val.url = '//list.m.yohobuy.com/?' + param;
|
|
|
// });
|
|
|
categoryData.list = data.data.list;
|
|
|
} else if (data.template_name === 'focus') {
|
|
|
// _.forEach(data.data, function(val) {
|
|
|
|
|
|
// val.url = '//m.yohobuy.com/guang/cate-all';
|
|
|
// });
|
|
|
categoryData.focusData = data;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
list.categoryData = result[3];
|
|
|
}
|
|
|
|
|
|
list.brandList = brandList;
|
|
|
list.categoryData = categoryData;
|
|
|
|
|
|
return list;
|
|
|
});
|
|
|
};
|
...
|
...
|
@@ -295,10 +284,8 @@ const brandListData = (code, gender) => { |
|
|
if (result[0]) {
|
|
|
_.forEach(result[0], function(data) {
|
|
|
if (data.focus_type && data.focus_type === '1') {
|
|
|
// brandList.bannerTop = _dealBrandUrl(data);
|
|
|
brandList.bannerTop = data;
|
|
|
} else if (data.focus_type && data.focus_type === '2') {
|
|
|
// brandList.focusData = _dealBrandUrl(data).data;
|
|
|
brandList.focusData = data.data;
|
|
|
} else if (data.template_name === 'single_image') {
|
|
|
brandList.bannerTop = data;
|
...
|
...
|
@@ -316,64 +303,9 @@ const brandListData = (code, gender) => { |
|
|
});
|
|
|
};
|
|
|
|
|
|
const categoryData = (code) => {
|
|
|
|
|
|
return _getResourcesData(code).then(result => {
|
|
|
let category = {};
|
|
|
let list = {};
|
|
|
|
|
|
if (result) {
|
|
|
_.forEach(result, function(data) {
|
|
|
if (data.template_name === 'recommend_content_five') {
|
|
|
// _.forEach(data.data.list, function(val) {
|
|
|
// var param = val.url.substring(val.url.indexOf('list?') + 5);
|
|
|
|
|
|
// val.url = '//list.m.yohobuy.com/?' + param;
|
|
|
// });
|
|
|
category.list = data.data.list;
|
|
|
} else if (data.template_name === 'focus') {
|
|
|
// _.forEach(data.data, function(val) {
|
|
|
|
|
|
// val.url = '//m.yohobuy.com/guang/cate-all';
|
|
|
// });
|
|
|
|
|
|
category.focusData = data;
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
list.categoryData = category;
|
|
|
return list;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
const getCateData = (channel, appType) => {
|
|
|
return api.get('', {
|
|
|
method: 'app.sort.get',
|
|
|
app_type: 1
|
|
|
}, {
|
|
|
cache: true
|
|
|
}).then((result) => {
|
|
|
if (!result.code || result.code !== 200 || !result.data) {
|
|
|
return [];
|
|
|
}
|
|
|
|
|
|
// 统一频道名称
|
|
|
// result.data.boys = result.data.boy;
|
|
|
// result.data.girls = result.data.girl;
|
|
|
// _.unset(result.data, 'boy');
|
|
|
// _.unset(result.data, 'girl');
|
|
|
|
|
|
|
|
|
return result.data;
|
|
|
}).then((list) => {
|
|
|
return _processCateData(list, channel, appType);
|
|
|
});
|
|
|
};
|
|
|
|
|
|
module.exports = {
|
|
|
indexData,
|
|
|
brandListData,
|
|
|
categoryData,
|
|
|
getCateData
|
|
|
brandListData
|
|
|
}; |
...
|
...
|
|