From 658396c9a39d6f2726a8da5ab328fd6ef2742bdb Mon Sep 17 00:00:00 2001 From: jinhhanhan <1683105490@qq.com> Date: Wed, 22 Jul 2026 17:49:08 +0800 Subject: [PATCH] =?UTF-8?q?chore=EF=BC=9A=E4=BA=8C=E7=BA=A7=E6=A0=87?= =?UTF-8?q?=E9=A2=98=E6=8C=89=E9=92=AE=E5=92=8C=E4=B8=80=E7=BA=A7=E6=A0=87?= =?UTF-8?q?=E9=A2=98=E7=AC=AC=E4=B8=80=E4=B8=AA=E5=AF=B9=E9=BD=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components-diy/diy-category-item.vue | 1 + components-diy/diy-category.vue | 41 +++++++++++++++------------- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/components-diy/diy-category-item.vue b/components-diy/diy-category-item.vue index ba37b3b..cc050bb 100644 --- a/components-diy/diy-category-item.vue +++ b/components-diy/diy-category-item.vue @@ -2404,6 +2404,7 @@ export default { align-items: center; justify-content: flex-start; padding: 20rpx 20rpx 20rpx 24rpx; + min-height: 96rpx; background: #fff; border-bottom: 1rpx solid #f0f0f0; box-sizing: border-box; diff --git a/components-diy/diy-category.vue b/components-diy/diy-category.vue index 51aa627..eedd79e 100644 --- a/components-diy/diy-category.vue +++ b/components-diy/diy-category.vue @@ -299,12 +299,20 @@ export default { }) .exec(); if (this.value.template == 1) this.getHeightArea(-1); - if (this.value.template == 99) this.getOneCategoryItemHeight(0); }, 500); }, watch: { // 组件刷新监听 - componentRefresh: function (nval) { } + componentRefresh: function (nval) { }, + categoryTreeLoading: function (nval, oval) { + if (nval === false && oval === true && this.value.template == 99) { + this.$nextTick(() => { + setTimeout(() => { + this.measureFirstCategoryItemHeight(); + }, 500); + }); + } + } }, computed: { cartTotalMoney() { @@ -378,6 +386,18 @@ export default { this.$store.dispatch('getCartNumber'); if (!this.heightArea.length) this.getHeightArea(-1); }, + measureFirstCategoryItemHeight() { + if (this.value.template != 99) return; + const query = uni.createSelectorQuery().in(this); + query + .selectAll('.tree-wrap .category-item') + .boundingClientRect(data => { + if (data && data.length > 0 && data[0].height) { + this.oneCategoryItemHeight = data[0].height; + } + }) + .exec(); + }, /** * 获取高度区间 * @@ -534,23 +554,6 @@ export default { this.select = index; this.categoryId = 'category-' + index; this.scrollLock = true; - this.getOneCategoryItemHeight(index); - }, - getOneCategoryItemHeight(index) { - setTimeout(() => { - const newQuery = uni.createSelectorQuery && uni.createSelectorQuery().in(this); - if (!newQuery || typeof newQuery.selectAll !== 'function') { - return; - } - newQuery - .selectAll('.category-item-wrap .category-item') - .boundingClientRect(data => { - if (data && data.length > index && data[index].height) { - this.oneCategoryItemHeight = data[index].height; - } - }) - .exec(); - }, 200); }, saveSecondCategoryName(name) { this.lastSecondCategoryName = name;