Authored by 李奇

列表页筛选修改

... ... @@ -18,9 +18,9 @@ module.exports = {
app_type: 1
},
domains: {
api: 'http://api-test3.yohops.com:9999/',
service: 'http://service-test3.yohops.com:9999/',
singleApi: 'http://api-test3.yohops.com:9999/',
// api: 'http://api-test3.yohops.com:9999/',
// service: 'http://service-test3.yohops.com:9999/',
// singleApi: 'http://api-test3.yohops.com:9999/',
// api: 'http://api-test3.yohops.com:9999/',
// service: 'http://service-test3.yohops.com:9999/',
... ... @@ -29,9 +29,9 @@ module.exports = {
// api: 'http://dev-api.yohops.com:9999/',
// service: 'http://dev-service.yohops.com:9999/',
// api: 'http://api.yoho.cn/',
// service: 'http://service.yoho.cn/',
// singleApi: 'http://single.yoho.cn/'
api: 'http://api.yoho.cn/',
service: 'http://service.yoho.cn/',
singleApi: 'http://single.yoho.cn/'
},
subDomains: {
host: '.m.yohoblk.com',
... ...
... ... @@ -24,7 +24,9 @@ const typeMap = {
品牌: 'brand',
品类: 'group_sort',
颜色: 'color',
尺寸: 'size'
尺寸: 'size',
价格: 'price',
折扣: 'discount'
};
module.exports = {
... ... @@ -66,7 +68,7 @@ module.exports = {
newChoice.isChosen && (this.chosen[index] = newChoice);
this.calcChosenVal();
bus.$emit('choice.change', this.name, this.chosen);
bus.$emit('subChosen.change', typeMap[this.name], this.chosen);
},
calcChosenVal(){
let name;
... ... @@ -100,10 +102,10 @@ module.exports = {
},
clearChosenVal(){
this.show = false;
this.chosen = [];
this.chosen = {};
this.chosenVal = '';
this.allChoices = this.initialChoices.slice();
bus.$emit('choice.change', this.name, this.chosen);
bus.$emit('subChosen.change', this.name, this.chosen);
},
searchChosenVal(){
this.show = false;
... ... @@ -116,8 +118,26 @@ module.exports = {
let names = [];
if (sub.value && sub.value.length) {
this.allChoices = this.initialChoices.slice();
_.each(sub.value, item => {
names.push(item.name);
_.each(this.allChoices, (choice, index) => {
const isSort = this.name === '品类';
const id = isSort ? choice.category_id : choice.id;
if (item.id === id) {
let newChoice = {
id: choice.id,
name: choice.name,
isChosen: !choice.isChosen,
category_name: choice.category_name,
relation_parameter: choice.relation_parameter
};
this.chosen[index] = newChoice;
this.allChoices.$set(index, newChoice);
}
});
});
this.show = false;
this.chosenVal = names.join(',');
... ...
... ... @@ -41,6 +41,15 @@ const keyMap = {
折扣: 'discount'
};
const convertMap = {
brand: 'brand',
group_sort: 'sort',
color: 'color',
size: 'size',
price: 'price',
discount: 'discount',
};
module.exports = {
props: {
val: String,
... ... @@ -166,10 +175,11 @@ module.exports = {
_.each(this.chosen, (val, key) => {
ids = [];
key = convertMap[key];
keys = Object.keys(val);
_.each(keys, v => {
if (key !== '品类') {
if (key !== 'sort') {
ids.push(val[v].id);
} else {
ids.push(val[v].relation_parameter.sort);
... ... @@ -177,9 +187,9 @@ module.exports = {
});
if (ids.length) {
filter[keyMap[key]] = ids.join(',');
filter[key] = ids.join(',');
} else {
delete filter[keyMap[key]];
delete filter[key];
}
});
... ... @@ -208,10 +218,39 @@ module.exports = {
},
expandSub(type){
this.subType = type;
this.valueData = this.values && this.values[type];
this.subFilterData = this.filter ? this.filter[type] : {};
this.$refs.filterSub.isVisible = true;
},
subFilterChange(sub){
bus.$emit('subFilter.change', sub);
},
subChosenChange(name, chosen) {
let keyArr = Object.keys(chosen);
if (keyArr.length) {
let id, nm;
this.values[name] = [];
_.each(keyArr, key => {
id = name !== 'group_sort' ?
chosen[key].id :
chosen[key].relation_parameter.sort;
nm = name !== 'group_sort' ?
chosen[key].name :
chosen[key].category_name;
this.values[name].push({
id,
name: nm
});
});
this.chosen[name] = chosen;
} else {
this.values[name] = [];
delete this.chosen[name];
}
}
},
watch: {
... ... @@ -230,10 +269,6 @@ module.exports = {
}
this.showLay();
},
subType(type){
this.valueData = this.values && this.values[type];
this.subFilterData = this.filter ? this.filter[type] : {};
}
},
components: {
... ... @@ -253,13 +288,7 @@ module.exports = {
this.filterItems[4].choices = this.filter.priceRange;
this.filterItems[5].choices = this.filter.discount;
bus.$on('choice.change', (name, chosen) => {
if (!_.isArray(chosen)) {
this.chosen[name] = chosen;
} else {
delete this.chosen[name];
}
});
bus.$on('subChosen.change', this.subChosenChange);
bus.$on('expand.choice.only', name => {
bus.$emit('fold.choice.except', name);
... ...