chore:切换左侧一级分类时,右侧默认选中第一个按钮

This commit is contained in:
2026-07-13 18:00:48 +08:00
parent bb34e32f87
commit 9915fb9bb1

View File

@@ -352,8 +352,11 @@ export default {
this.type = this.value.template == 1 ? 'category' : 'goods';
if (this.index == this.select && this.pageIndex == 0) this.getGoodsList();
this.loadType = this.value.goodsLevel == 1 && this.value.loadType == 'all' ? 'all' : 'part';
console.log('diy-category-item type:', this.type, 'value.level:', this.value.level, 'typeof value.level:', typeof this.value.level);
console.log('diy-category-item category.child_list:', this.category.child_list, 'length:', this.category.child_list ? this.category.child_list.length : 'undefined');
if (this.index == this.select && parseInt(this.value.level) == 2 && this.category.child_list && this.category.child_list.length > 0) {
this.selectedSecondCategory = this.category.child_list[0].category_id;
this.secondCategoryGoodsList = [];
this.getSecondCategoryGoods(this.category.child_list[0].category_id);
}
},
mounted() {
setTimeout(() => {
@@ -363,6 +366,11 @@ export default {
if (data) this.contentWrapHeight = data.height;
}).exec();
}, 1000);
if (parseInt(this.value.level) == 2 && this.category.child_list && this.category.child_list.length > 0) {
this.selectedSecondCategory = this.category.child_list[0].category_id;
this.secondCategoryGoodsList = [];
this.getSecondCategoryGoods(this.category.child_list[0].category_id);
}
},
watch: {
oneCategorySelect: function () {
@@ -391,6 +399,11 @@ export default {
} else if (this.loadType == 'part') {
this.scrollTop = -1;
}
if (parseInt(this.value.level) == 2 && this.category.child_list && this.category.child_list.length > 0) {
this.selectedSecondCategory = this.category.child_list[0].category_id;
this.secondCategoryGoodsList = [];
this.getSecondCategoryGoods(this.category.child_list[0].category_id);
}
},
'globalStoreInfo.store_id': {
handler(nval, oval) {