...
|
...
|
@@ -52,11 +52,25 @@ const fullToMinMap = _.transform(minToFullMap, (result, value, key) => { |
|
|
}
|
|
|
}, {});
|
|
|
|
|
|
const genderMap = {
|
|
|
minToFull: {
|
|
|
1: '1,3',
|
|
|
2: '2,3'
|
|
|
},
|
|
|
fullToMin: {
|
|
|
'1,3': 1,
|
|
|
'2,3': 2,
|
|
|
'1,2,3': ''
|
|
|
}
|
|
|
};
|
|
|
|
|
|
const sringifyParam = (param) => {
|
|
|
let arr = [];
|
|
|
|
|
|
_.forEach(param, (value, key) => {
|
|
|
arr.push(`${key}=${value}`);
|
|
|
if (value) {
|
|
|
arr.push(`${key}=${value}`);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
return arr.join('&');
|
...
|
...
|
@@ -74,7 +88,8 @@ const transformKey = (params, isFull) => { |
|
|
_.forEach(params, (value, key) => {
|
|
|
let name = map[key];
|
|
|
|
|
|
if (name) {
|
|
|
// 包含',' & 等于{seat} 表示为多选,不需要伪静态
|
|
|
if (name && _.indexOf(value, ',') === -1 && value !== '{seat}') {
|
|
|
matchParams[name] = value;
|
|
|
} else {
|
|
|
extraParams[key] = value;
|
...
|
...
|
@@ -111,6 +126,8 @@ const minPathToFullParam = (path) => { |
|
|
}
|
|
|
});
|
|
|
|
|
|
obj.gender = genderMap.minToFull[obj.gender] || obj.gender || '1,2,3';
|
|
|
|
|
|
return obj;
|
|
|
};
|
|
|
|
...
|
...
|
@@ -133,6 +150,10 @@ const fullParamToMinPath = (uri, params, newObj, delObj = {}) => { |
|
|
_.has(obj, key) && _.unset(obj, key);
|
|
|
});
|
|
|
|
|
|
if (obj.gender) {
|
|
|
obj.gender = _.has(genderMap.fullToMin, obj.gender) ? genderMap.fullToMin[obj.gender] : obj.gender;
|
|
|
}
|
|
|
|
|
|
let transParams = transformKey(obj, true);
|
|
|
|
|
|
_.forEach(transParams.matchParams, (value, key) => {
|
...
|
...
|
@@ -145,7 +166,9 @@ const fullParamToMinPath = (uri, params, newObj, delObj = {}) => { |
|
|
extraQs = '?' + sringifyParam(transParams.extraParams);
|
|
|
}
|
|
|
|
|
|
return _.trimEnd(uri, '/') + '/' + _.sortBy(pathArr).join('-') + extraQs;
|
|
|
let minPath = _.sortBy(pathArr).join('-') + (pathArr.length ? '.html' : '');
|
|
|
|
|
|
return `${_.trimEnd(uri, '/')}/${minPath}${extraQs}`;
|
|
|
};
|
|
|
|
|
|
|
...
|
...
|
|