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;