...
|
...
|
@@ -35,7 +35,8 @@ const typeCont = { |
|
|
price: ['s_p_desc', 's_p_asc'],
|
|
|
discount: ['p_d_desc', 'p_d_asc'],
|
|
|
sales: ['s_n_desc', 's_n_asc'],
|
|
|
newest: ['s_t_desc', 's_t_asc']
|
|
|
newest: ['s_t_desc', 's_t_asc'],
|
|
|
stock: ['s_s_desc', 's_s_asc']
|
|
|
};
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -248,9 +249,57 @@ const processProductList = (list, options) => { |
|
|
*/
|
|
|
const processFilter = (list, options) => {
|
|
|
const filters = {
|
|
|
classify: {}
|
|
|
classify: []
|
|
|
};
|
|
|
|
|
|
const filtersType = {
|
|
|
brand: {
|
|
|
name: '所有品牌',
|
|
|
title: '品牌',
|
|
|
dataId: 'id',
|
|
|
subsName: 'brandName'
|
|
|
},
|
|
|
color: {
|
|
|
name: '所有颜色',
|
|
|
title: '颜色',
|
|
|
dataId: 'colorId',
|
|
|
subsName: 'colorName'
|
|
|
},
|
|
|
discount: {
|
|
|
name: '所有商品',
|
|
|
title: '折扣',
|
|
|
dataId: 'key',
|
|
|
subsName: 'name'
|
|
|
},
|
|
|
gender: {
|
|
|
name: '所有性别',
|
|
|
title: '性别',
|
|
|
dataId: 'key',
|
|
|
subsName: 'flag'
|
|
|
},
|
|
|
groupSort: {
|
|
|
name: '所有品类',
|
|
|
title: '品类',
|
|
|
dataId: 'relationParameter',
|
|
|
subsName: 'categoryName'
|
|
|
},
|
|
|
priceRange: {
|
|
|
name: '所有价格',
|
|
|
title: '价格',
|
|
|
dataId: 'key',
|
|
|
subsName: 'flag'
|
|
|
},
|
|
|
size: {
|
|
|
name: '所有尺码',
|
|
|
title: '尺码',
|
|
|
dataId: 'sizeId',
|
|
|
subsName: 'sizeName'
|
|
|
}
|
|
|
};
|
|
|
|
|
|
let subs = {};
|
|
|
let classify = {};
|
|
|
|
|
|
options = Object.assign({
|
|
|
gender: '1,2,3', // 默认选择的性别,默认1,2,3表示所有
|
|
|
exclude: null // 需要排除的字段
|
...
|
...
|
@@ -258,8 +307,33 @@ const processFilter = (list, options) => { |
|
|
list = camelCase(list);
|
|
|
|
|
|
_.forEach(list, (item, key) => {
|
|
|
console.log(key);
|
|
|
if (key === 'group_sort') {
|
|
|
return;
|
|
|
}
|
|
|
classify.dataType = key;
|
|
|
classify.name = filtersType[key].name;
|
|
|
classify.title = filtersType[key].typeCont;
|
|
|
|
|
|
_.forEach(item, (sub, index) => {
|
|
|
if (filtersType[key].dataId === 'key') {
|
|
|
subs.dataId = index;
|
|
|
} else if (filtersType[key].dataId === 'relationParameter') {
|
|
|
subs.dataId = item.relationParameter.sort;
|
|
|
} else {
|
|
|
subs.dataId = item[filtersType[key].dataId];
|
|
|
}
|
|
|
|
|
|
if (filtersType[key].subsName === 'flag') {
|
|
|
subs.name = index;
|
|
|
} else {
|
|
|
subs.name = sub[filtersType[key].subsName];
|
|
|
}
|
|
|
classify.subs.push(subs)
|
|
|
});
|
|
|
|
|
|
filters.classify.push(classify);
|
|
|
});
|
|
|
|
|
|
return filters;
|
|
|
};
|
|
|
|
...
|
...
|
|