Authored by 陈轩

fix

... ... @@ -164,7 +164,7 @@ const enDict = {
color: 'Color',
gender: 'Gender',
size: 'Size',
brand: 'Brand品牌',
brand: 'Brand',
priceRange: 'Price',
groupSort: 'Category',
discount: 'Sale',
... ...
... ... @@ -8,9 +8,12 @@ const _ = require('lodash');
/**
* 处理 以风格的数据
* 风格1:
* [
* {filter_attribute: value}
* ]
* 风格2:
* {filter_attribute: value}
*
* 处理结果
* [
... ... @@ -22,18 +25,32 @@ let verboseAttrHandler = (filterField, dataArr) => {
let result = [];
let re = new RegExp(`^${filterField}_`);
dataArr.forEach(obj => {
// 处理 {filter_attribute: value}
function handlerAttrObj(obj) {
let item = {};
let keys = Object.keys(obj);
keys.forEach(key=>{
keys.forEach(key => {
let newKey = key.replace(re, '');
item[newKey] = obj[key];
});
return item;
}
result.push(item);
});
if (_.isPlainObject(dataArr)) {
// 风格2
let attr = handlerAttrObj(dataArr);
result.push(attr);
} else {
// 风格1
dataArr.forEach(obj => {
let attr = handlerAttrObj(obj);
result.push(attr);
});
}
return result;
};
... ... @@ -60,7 +77,7 @@ let keyIdHandler = (filterField, obj) => {
const keys = Object.keys(obj);
keys.sort();
keys.forEach(key=> {
keys.forEach(key => {
let item = {};
item.id = key;
... ...