From dc4b3df715472a2b534f1a3196bf0950dbd7d4a1 Mon Sep 17 00:00:00 2001 From: ZF sun <34314687@qq.com> Date: Fri, 29 May 2026 14:58:08 +0800 Subject: [PATCH] =?UTF-8?q?fix(merch/detail):=20=E9=98=B2=E6=AD=A2?= =?UTF-8?q?=E9=87=8D=E5=A4=8D=E5=88=9D=E5=A7=8B=E5=8C=96=E5=A4=B4=E9=83=A8?= =?UTF-8?q?=E9=AB=98=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 新增headerHeightInited状态避免重复调用initHeaderHeight 2. 在initHeaderHeight中增加商品名称校验防止无效执行 3. 仅在页面首次获取商品数据后初始化头部高度 --- pages_promotion/merch/detail.vue | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pages_promotion/merch/detail.vue b/pages_promotion/merch/detail.vue index 122774c..6aaaec5 100644 --- a/pages_promotion/merch/detail.vue +++ b/pages_promotion/merch/detail.vue @@ -322,7 +322,8 @@ export default { return { headerHeight: 320, screenWidth: uni.getSystemInfoSync().windowWidth, - changeStyleDebounce: null + changeStyleDebounce: null, + headerHeightInited: false }; }, mixins: [list], @@ -337,7 +338,9 @@ export default { if (res.code >= 0 && res.data) { this.merch = res.data; this.$nextTick(() => { - this.initHeaderHeight(); + if (!this.headerHeightInited) { + this.initHeaderHeight(); + } }); } } @@ -353,10 +356,13 @@ export default { } }, initHeaderHeight() { + if (!this.merch || !this.merch.merch_name) return; + if (this.headerHeightInited) return; const query = uni.createSelectorQuery().in(this); query.select('.head-wrap').boundingClientRect(rect => { if (rect && rect.height > 0) { this.headerHeight = (rect.height / this.screenWidth) * 750; + this.headerHeightInited = true; } }).exec(); },