Authored by ccbikai

价格排序修改

... ... @@ -15,8 +15,11 @@ module.exports = {
port: 6001,
siteUrl: '//m.yohobuy.com',
domains: {
api: 'http://devapi.yoho.cn:58078/',
service: 'http://devservice.yoho.cn:58077/'
api: 'http://testapi.yoho.cn:28078/',
service: 'http://testservice.yoho.cn:28077/'
// api: 'http://devapi.yoho.cn:58078/',
// service: 'http://devservice.yoho.cn:58077/'
},
subDomains: {
host: '.m.yohobuy.com',
... ... @@ -31,9 +34,9 @@ module.exports = {
useOneapm: false,
useCache: false,
memcache: {
master: ['192.168.102.161:11213'],
slave: ['192.168.102.161:11213'],
session: ['192.168.102.161:11213'],
master: ['192.168.102.222:12111'],
slave: ['192.168.102.222:12111'],
session: ['192.168.102.222:12111'],
timeout: 1000,
retries: 0
},
... ...
... ... @@ -21,4 +21,4 @@
</ul>
</div>
</div>
{{/ filter}}
\ No newline at end of file
{{/ filter}}
... ...
... ... @@ -19,6 +19,27 @@ const _procProductImg = (product, gender, yhChannel) => {
return product.cover1 || product.imagesUrl || product.cover2 || '';
};
const toArray = (obj) => {
if (_.isArray(obj)) {
return obj;
}
let arr = [];
_.forEach(obj, (v, k) => {
if (_.isObject(v)) {
v._key = k;
} else {
v = {
_key: k,
_value: v
};
}
arr.push(v);
});
return arr;
};
/**
* 按照数组中指定字段排序二维数组
*
... ... @@ -27,8 +48,9 @@ const _procProductImg = (product, gender, yhChannel) => {
* @param boolean 有 desc 时候降序排列,默认为false
*/
const _sortListByField = (list, key, desc) => {
list = _.toArray(list);
list = list.sort((a, b) => {
let array = toArray(list);
array = array.sort((a, b) => {
let matchNumber = /([\d]+)/g;
// 有键,使用键的值排序
... ... @@ -40,12 +62,13 @@ const _sortListByField = (list, key, desc) => {
}
// 无键, 使用本身
let numA = +(_.toArray(a.match(matchNumber))[0] || 0);
let numB = +(_.toArray(b.match(matchNumber))[0] || 0);
let numA = +(_.toArray(a._value.match(matchNumber))[0] || 0);
let numB = +(_.toArray(b._value.match(matchNumber))[0] || 0);
return numA < numB ? -1 : 1;
});
return list;
return array;
};
/**
... ... @@ -256,7 +279,11 @@ exports.processFilter = (list, options) => {
_.forEach(item, (sub, index) => {
let subs = {};
if (filtersType[key].dataId === 'key') {
if (key === 'discount') {
subs.dataId = sub._key;
} else if (key === 'priceRange') {
subs.dataId = sub._key;
} else if (filtersType[key].dataId === 'key') {
subs.dataId = index;
} else if (filtersType[key].dataId === 'relationParameter') {
subs.dataId = sub.relationParameter['sort']; // eslint-disable-line
... ... @@ -264,7 +291,9 @@ exports.processFilter = (list, options) => {
subs.dataId = sub[filtersType[key].dataId];
}
if (filtersType[key].subsName === 'flag') {
if (key === 'priceRange') {
subs.name = sub._value;
} else if (filtersType[key].subsName === 'flag') {
subs.name = sub;
} else {
subs.name = sub[filtersType[key].subsName];
... ...