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);