From f58a6723de759036e22c43b28abe4a145b97a9f1 Mon Sep 17 00:00:00 2001 From: ZF sun <34314687@qq.com> Date: Sat, 30 May 2026 16:56:16 +0800 Subject: [PATCH] =?UTF-8?q?fix(merch/detail):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=95=86=E6=88=B7=E6=8F=8F=E8=BF=B0=E5=B1=95=E5=BC=80=E5=90=8E?= =?UTF-8?q?=E6=BB=9A=E5=8A=A8=E6=94=B6=E8=B5=B7=E4=BD=8D=E7=BD=AE=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 通过 key 强制重新渲染描述区域,重置滚动位置。合并重复的 toggleDesc 方法。 Sources: - 61243b8 feat(merch/detail): add scroll hint for long product description --- pages_promotion/merch/detail.vue | 39 ++++++++++++++++---------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/pages_promotion/merch/detail.vue b/pages_promotion/merch/detail.vue index ecdb08a..b226aa5 100644 --- a/pages_promotion/merch/detail.vue +++ b/pages_promotion/merch/detail.vue @@ -24,12 +24,12 @@ - - {{ merch.desc }} + + {{ merch.desc }} ↓ 上滑查看更多 - + {{ isDescExpanded ? '↑ 收起' : '↓ 展开' }} @@ -336,7 +336,8 @@ export default { changeStyleDebounce: null, headerHeightInited: false, isDescExpanded: false, - isShowScrollHint: false + isShowScrollHint: false, + descKey: 0 }; }, mixins: [list], @@ -360,22 +361,22 @@ export default { }); }, toggleDesc() { - if (this.merch.desc) { - this.isDescExpanded = !this.isDescExpanded; - } - }, - handleDescClick() { if (!this.merch.desc) return; - this.isDescExpanded = !this.isDescExpanded; - }, - toggleDesc() { - if (!this.merch.desc) return; - this.isDescExpanded = !this.isDescExpanded; - if (this.isDescExpanded && this.merch.desc.length > 200) { - this.isShowScrollHint = true; - setTimeout(() => { - this.isShowScrollHint = false; - }, 3000); + + if (this.isDescExpanded) { + // 收起时切换 key 强制重新渲染,重置滚动位置 + this.descKey = this.descKey === 0 ? 1 : 0; + this.isDescExpanded = false; + this.isShowScrollHint = false; + } else { + // 展开时直接设置展开状态 + this.isDescExpanded = true; + if (this.merch.desc.length > 200) { + this.isShowScrollHint = true; + setTimeout(() => { + this.isShowScrollHint = false; + }, 3000); + } } }, initHeaderHeight() {