From f18577a46c6a8bc09c8148ab3a76bca58b610c9f Mon Sep 17 00:00:00 2001
From: jinhhanhan <1683105490@qq.com>
Date: Mon, 13 Jul 2026 18:05:36 +0800
Subject: [PATCH] =?UTF-8?q?chore:=E5=88=87=E6=8D=A2=E5=B7=A6=E4=BE=A7?=
=?UTF-8?q?=E4=B8=80=E7=BA=A7=E5=88=86=E7=B1=BB=E6=97=B6=EF=BC=8C=E5=8F=B3?=
=?UTF-8?q?=E4=BE=A7=E4=BC=9A=E8=87=AA=E5=8A=A8=E9=80=89=E4=B8=AD=E7=AC=AC?=
=?UTF-8?q?=E4=B8=80=E4=B8=AA=E4=BA=8C=E7=BA=A7=E5=88=86=E7=B1=BB=E6=8C=89?=
=?UTF-8?q?=E9=92=AE=EF=BC=88=E5=A6=82"=E7=A6=BB=E5=9E=8B=E7=BA=B8"?=
=?UTF-8?q?=EF=BC=89=20=E5=A6=82=E6=9E=9C=E7=94=A8=E6=88=B7=E4=B9=8B?=
=?UTF-8?q?=E5=89=8D=E7=82=B9=E5=87=BB=E8=BF=87=E6=9F=90=E4=B8=AA=E4=BA=8C?=
=?UTF-8?q?=E7=BA=A7=E5=88=86=E7=B1=BB=EF=BC=88=E5=A6=82"=E7=A6=BB?=
=?UTF-8?q?=E5=9E=8B=E8=86=9C"=EF=BC=89=EF=BC=8C=E5=88=87=E6=8D=A2?=
=?UTF-8?q?=E4=B8=80=E7=BA=A7=E5=88=86=E7=B1=BB=E5=90=8E=E4=BC=9A=E8=87=AA?=
=?UTF-8?q?=E5=8A=A8=E9=80=89=E4=B8=AD=E5=90=8C=E5=90=8D=E7=9A=84=E4=BA=8C?=
=?UTF-8?q?=E7=BA=A7=E5=88=86=E7=B1=BB?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
components-diy/diy-category-item.vue | 38 +++++++++++++++++++++++-----
components-diy/diy-category.vue | 10 +++++---
2 files changed, 39 insertions(+), 9 deletions(-)
diff --git a/components-diy/diy-category-item.vue b/components-diy/diy-category-item.vue
index 52a23a0..b91076d 100644
--- a/components-diy/diy-category-item.vue
+++ b/components-diy/diy-category-item.vue
@@ -323,6 +323,10 @@ export default {
isList: {
type: Boolean,
default: false
+ },
+ lastSecondCategoryName: {
+ type: String,
+ default: ''
}
},
mixins: [DiyMinx],
@@ -353,9 +357,16 @@ export default {
if (this.index == this.select && this.pageIndex == 0) this.getGoodsList();
this.loadType = this.value.goodsLevel == 1 && this.value.loadType == 'all' ? 'all' : 'part';
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;
+ let targetCategory = null;
+ if (this.lastSecondCategoryName) {
+ targetCategory = this.category.child_list.find(item => item.category_name === this.lastSecondCategoryName);
+ }
+ if (!targetCategory) {
+ targetCategory = this.category.child_list[0];
+ }
+ this.selectedSecondCategory = targetCategory.category_id;
this.secondCategoryGoodsList = [];
- this.getSecondCategoryGoods(this.category.child_list[0].category_id);
+ this.getSecondCategoryGoods(targetCategory.category_id);
}
},
mounted() {
@@ -367,9 +378,16 @@ export default {
}).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;
+ let targetCategory = null;
+ if (this.lastSecondCategoryName) {
+ targetCategory = this.category.child_list.find(item => item.category_name === this.lastSecondCategoryName);
+ }
+ if (!targetCategory) {
+ targetCategory = this.category.child_list[0];
+ }
+ this.selectedSecondCategory = targetCategory.category_id;
this.secondCategoryGoodsList = [];
- this.getSecondCategoryGoods(this.category.child_list[0].category_id);
+ this.getSecondCategoryGoods(targetCategory.category_id);
}
},
watch: {
@@ -400,9 +418,16 @@ export default {
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;
+ let targetCategory = null;
+ if (this.lastSecondCategoryName) {
+ targetCategory = this.category.child_list.find(item => item.category_name === this.lastSecondCategoryName);
+ }
+ if (!targetCategory) {
+ targetCategory = this.category.child_list[0];
+ }
+ this.selectedSecondCategory = targetCategory.category_id;
this.secondCategoryGoodsList = [];
- this.getSecondCategoryGoods(this.category.child_list[0].category_id);
+ this.getSecondCategoryGoods(targetCategory.category_id);
}
},
'globalStoreInfo.store_id': {
@@ -791,6 +816,7 @@ export default {
this.selectedSecondCategory = category.category_id;
this.secondCategoryGoodsList = [];
this.getSecondCategoryGoods(category.category_id);
+ this.$emit('saveSecondCategory', category.category_name);
}
},
getSecondCategoryGoods(categoryId) {
diff --git a/components-diy/diy-category.vue b/components-diy/diy-category.vue
index 5ff3844..330fd40 100644
--- a/components-diy/diy-category.vue
+++ b/components-diy/diy-category.vue
@@ -101,8 +101,9 @@
:id="'category-' + index" v-if="select == index">
+ @loadfinish="getHeightArea" @saveSecondCategory="saveSecondCategoryName">
{{ $lang('components-diy.diy-category.reachedBottom') }}
@@ -194,7 +195,8 @@ export default {
loadType: '',
templateFourData: [],
isList: false,
- lang: uni.getStorageSync("lang")//en-us 英文
+ lang: uni.getStorageSync("lang"),
+ lastSecondCategoryName: ''
};
},
created() {
@@ -373,9 +375,11 @@ export default {
if (index >= this.categoryTree.length) return;
this.select = index;
this.categoryId = 'category-' + index;
- // 阻止切换分类之后滚动事件也立即执行
this.scrollLock = true;
},
+ saveSecondCategoryName(name) {
+ this.lastSecondCategoryName = name;
+ },
touchStart() {
this.scrollLock = false;
},