|
|
'use strict';
|
|
|
|
|
|
// const serviceAPI = global.yoho.ServiceAPI;
|
|
|
const serviceAPI = global.yoho.ServiceAPI;
|
|
|
const api = global.yoho.API;
|
|
|
const camelCase = global.yoho.camelCase;
|
|
|
const _ = require('lodash');
|
...
|
...
|
@@ -16,36 +16,55 @@ const _processListData = (list) => { |
|
|
|
|
|
list = list || [];
|
|
|
list = camelCase(list);
|
|
|
console.log(list)
|
|
|
|
|
|
_.forEach(list.data, function(value, index) {
|
|
|
_.forEach(list.data.allList, function(value, index) {
|
|
|
|
|
|
_.forEach(value, function(obj) {
|
|
|
obj.brandIco = `//img13.static.yhbimg.com/brandLogo/${obj.brandIco}?imageView2/3/w/{width}/h/{height}`;
|
|
|
if (index === '0~9') {
|
|
|
index = '0-9';
|
|
|
}
|
|
|
|
|
|
if (!_.isNaN(+index)) {
|
|
|
category.key = '0-9';
|
|
|
category.brands.push(obj);
|
|
|
listData.push(
|
|
|
{
|
|
|
key: index,
|
|
|
brands: value
|
|
|
}
|
|
|
});
|
|
|
|
|
|
if (_.isNaN(+index)) {
|
|
|
listData.push(
|
|
|
{
|
|
|
key: index,
|
|
|
brands: value
|
|
|
}
|
|
|
);
|
|
|
}
|
|
|
console.log(value);
|
|
|
);
|
|
|
});
|
|
|
|
|
|
listData.push(category);
|
|
|
|
|
|
return listData;
|
|
|
};
|
|
|
|
|
|
const getListData = () => {
|
|
|
return api.get('', {
|
|
|
const _processTabData = (list) => {
|
|
|
list = list || [];
|
|
|
list = camelCase(list);
|
|
|
|
|
|
console.log(list)
|
|
|
|
|
|
// let artList = list.list.artList.map(data =>{
|
|
|
// data.publishTime = data.publishTime.replace(/年|月/g, '/');
|
|
|
// data.publishTime = data.publishTime.replace(/日/g, '');
|
|
|
|
|
|
// return data;
|
|
|
// });
|
|
|
|
|
|
}
|
|
|
|
|
|
const _getResources = () => {
|
|
|
return api.get('', {
|
|
|
method: 'web.brand.series'
|
|
|
}).then((result) => {
|
|
|
if (result && result.code === 200) {
|
|
|
return _processTabData(result.data);
|
|
|
} else {
|
|
|
logger.error('品牌页Tab数据返回 code 不是 200');
|
|
|
return {};
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
|
|
|
const _getBreakingSort = () => {
|
|
|
return api.get('', {
|
|
|
method: 'app.brand.newBrandList'
|
|
|
}).then((result) => {
|
|
|
if (result && result.code === 200) {
|
...
|
...
|
@@ -57,6 +76,31 @@ const getListData = () => { |
|
|
});
|
|
|
};
|
|
|
|
|
|
|
|
|
// const getListData = () => {
|
|
|
// return api.get('', {
|
|
|
// method: 'app.brand.newBrandList'
|
|
|
// }).then((result) => {
|
|
|
// if (result && result.code === 200) {
|
|
|
// return _processListData(result);
|
|
|
// } else {
|
|
|
// logger.error('品牌页数据返回 code 不是 200');
|
|
|
// return {};
|
|
|
// }
|
|
|
// });
|
|
|
// };
|
|
|
|
|
|
const getListData = () => {
|
|
|
return Promise.all([_getResources(), _getBreakingSort()])
|
|
|
.then((result) => {
|
|
|
|
|
|
return {
|
|
|
tabs: result[0],
|
|
|
category: result[1]
|
|
|
};
|
|
|
});
|
|
|
};
|
|
|
|
|
|
module.exports = {
|
|
|
getListData: getListData
|
|
|
}; |
...
|
...
|
|