...
|
...
|
@@ -10,11 +10,7 @@ const api = global.yoho.API; |
|
|
const brandApi = require('./brand-api');
|
|
|
const logger = global.yoho.logger;
|
|
|
const _ = require('lodash');
|
|
|
const querystring = require('querystring');
|
|
|
|
|
|
const urlFormat = (path, qs) => {
|
|
|
return path + '?' + querystring.stringify(qs);
|
|
|
};
|
|
|
const camelCase = global.yoho.camelCase;
|
|
|
|
|
|
/**
|
|
|
* 处理品牌一览品牌列表数据
|
...
|
...
|
@@ -33,8 +29,6 @@ const handleBrandList = origin => { |
|
|
_.forEach(value, (subValue) => {
|
|
|
brands.push({
|
|
|
name: subValue.brand_name,
|
|
|
|
|
|
// link: helpers.urlFormat('/brand', {domain: subValue.brand_domain}),
|
|
|
link: '/product/shop?domain=' + subValue.brand_domain,
|
|
|
logo: subValue.brand_ico
|
|
|
});
|
...
|
...
|
@@ -78,77 +72,12 @@ const getBrandListData = params => { |
|
|
* @returns {*|Promise.<TResult>}
|
|
|
*/
|
|
|
const getCateListData = params => {
|
|
|
let finalResult = [];
|
|
|
let item = {};
|
|
|
let oneClass = [];
|
|
|
let subitem = {};
|
|
|
let genderArr = {
|
|
|
MEN男士: '1,3',
|
|
|
WOMEN女士: '2,3',
|
|
|
LIFESTYLE生活: '1,2,3'
|
|
|
};
|
|
|
|
|
|
return brandApi.getCateListData(params).then(result => {
|
|
|
|
|
|
if (result.code !== 200) {
|
|
|
return [];
|
|
|
if (result.code === 200) {
|
|
|
return camelCase(result.data);
|
|
|
} else {
|
|
|
logger.error('getCateListData api code no 200 or data is null');
|
|
|
}
|
|
|
|
|
|
_.forEach(result.data, (category, categorykey) => {
|
|
|
oneClass = {name: categorykey, ca: []};
|
|
|
|
|
|
_.forEach(category, (cate) => {
|
|
|
item = {
|
|
|
id: cate.category_id,
|
|
|
name: cate.category_name,
|
|
|
sort: cate.relation_parameter.sort,
|
|
|
sub: []
|
|
|
};
|
|
|
if (_.isEmpty(cate.sub)) {
|
|
|
item.url = urlFormat('/list', {
|
|
|
sort: item.sort,
|
|
|
sort_name: item.name,
|
|
|
gender: genderArr[categorykey]
|
|
|
});
|
|
|
oneClass.ca.push(item);
|
|
|
return true;// equal continue;
|
|
|
}
|
|
|
|
|
|
// 有子分类的,首先添加一级分类
|
|
|
item.sub.push({
|
|
|
id: item.id,
|
|
|
name: '全部' + item.name,
|
|
|
sort: item.sort,
|
|
|
url: urlFormat('/list', {
|
|
|
sort: item.sort,
|
|
|
sort_name: item.name,
|
|
|
gender: genderArr[categorykey]
|
|
|
}),
|
|
|
sub: []
|
|
|
});
|
|
|
|
|
|
_.forEach(cate.sub, (sub) => {
|
|
|
subitem = {
|
|
|
id: sub.category_id,
|
|
|
name: sub.category_name,
|
|
|
sort: sub.relation_parameter.sort,
|
|
|
url: ''
|
|
|
};
|
|
|
subitem.url = urlFormat('/list', {
|
|
|
sort: subitem.sort,
|
|
|
sort_name: subitem.name,
|
|
|
gender: genderArr[categorykey]
|
|
|
});
|
|
|
item.sub.push(subitem);
|
|
|
});
|
|
|
|
|
|
oneClass.ca.push(item);
|
|
|
});
|
|
|
|
|
|
finalResult.push(oneClass);
|
|
|
});
|
|
|
|
|
|
return finalResult;
|
|
|
});
|
|
|
};
|
|
|
|
...
|
...
|
|