From fd0dc45b7d3bbade4c9e88a21cbbc471508ff324 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E9=A3=9E=E6=B4=8B?= <15778543+xufeiyang6017@user.noreply.gitee.com> Date: Mon, 29 Dec 2025 14:48:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=B8=8B=E6=BB=91=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E6=94=B6=E7=BC=A9=E4=BE=A7=E8=BE=B9=E6=A0=8F=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/index/index.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pages/index/index.js b/pages/index/index.js index b87be16..254fb01 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -1127,6 +1127,9 @@ Page({ const threshold = 50; const backToTopThreshold = 300; + const lastScrollTop = this.data.lastScrollTop || 0; + const isScrollingDown = scrollTop > lastScrollTop; + let needUpdate = false; const updates = { lastScrollTop: scrollTop @@ -1135,7 +1138,15 @@ Page({ // 搜索框始终固定显示,不做隐藏处理 // 侧边栏按钮显示逻辑 - if (scrollTop <= threshold && this.data.sidebarBtnHidden) { + // 下滑时隐藏按钮(除非用户未手动隐藏过且在顶部) + if (isScrollingDown && scrollTop > threshold && !this.data.sidebarBtnHidden) { + updates.sidebarBtnHidden = true; + needUpdate = true; + wx.setStorageSync('sidebarBtnHidden', true); + wx.setStorageSync('userManuallyHidden', true); + } + // 上滑到顶部时显示按钮 + else if (scrollTop <= threshold && this.data.sidebarBtnHidden && !this.data.userManuallyHidden) { updates.sidebarBtnHidden = false; needUpdate = true; wx.setStorageSync('sidebarBtnHidden', false);