From 771bdb046658319eb5e2c30230f19027bdb69321 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 15:47:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BA=95=E9=83=A8=E9=81=AE?= =?UTF-8?q?=E6=8C=A1=E9=97=AE=E9=A2=98=E5=92=8C=E5=88=86=E9=A1=B5=E5=8A=A0?= =?UTF-8?q?=E8=BD=BD=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/index/index.js | 21 ++++++++------------- pages/index/index.wxml | 1 - pages/index/index.wxss | 19 ++++++++++++++----- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/pages/index/index.js b/pages/index/index.js index 9fc8961..367a380 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -132,18 +132,10 @@ Page({ // 切换按钮显示/隐藏到侧边栏 toggleSidebarBtn() { - // 如果当前不在顶部,点击则隐藏按钮 - if (this.data.lastScrollTop > 50) { - this.setData({ - sidebarBtnHidden: true - }); - wx.setStorageSync('sidebarBtnHidden', true); - } else { - this.setData({ - sidebarBtnHidden: !this.data.sidebarBtnHidden - }); - wx.setStorageSync('sidebarBtnHidden', !this.data.sidebarBtnHidden); - } + this.setData({ + sidebarBtnHidden: !this.data.sidebarBtnHidden + }); + wx.setStorageSync('sidebarBtnHidden', !this.data.sidebarBtnHidden); }, // 触摸开始事件 @@ -738,6 +730,9 @@ Page({ const totalPages = res.totalPages || Math.ceil(totalGoods / this.data.pageSize); const hasMoreData = page < totalPages && res.products.length > 0; + // 如果返回的商品数量小于每页数量,说明没有更多数据了 + const actualHasMoreData = res.products.length >= this.data.pageSize && page < totalPages; + // 更新缓存(加载更多时追加数据) const updatedCache = { ...this.data.categoryQueryCache }; if (isLoadMore && updatedCache[cacheKey]) { @@ -751,7 +746,7 @@ Page({ } this.setData({ - hasMoreData, + hasMoreData: actualHasMoreData, categoryQueryCache: updatedCache, lastDataTimestamp: now, goodsCache: updatedCache[cacheKey] diff --git a/pages/index/index.wxml b/pages/index/index.wxml index a7fd2ba..dd8a8c0 100644 --- a/pages/index/index.wxml +++ b/pages/index/index.wxml @@ -87,7 +87,6 @@ class="back-to-top-btn {{showBackToTop ? 'visible' : ''}}" bindtap="scrollToTop" > - top diff --git a/pages/index/index.wxss b/pages/index/index.wxss index df2b923..d12c91c 100644 --- a/pages/index/index.wxss +++ b/pages/index/index.wxss @@ -43,6 +43,9 @@ page { min-height: 120rpx; box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.08); border-bottom: 1rpx solid rgba(0, 0, 0, 0.05); + display: flex; + flex-direction: column; + align-items: center; } /* 确保所有主要区域背景一致 */ @@ -81,6 +84,8 @@ page { /* 搜索区域样式调整 */ .top-section-container .search-section { padding: 0 30rpx 15rpx; + width: 100%; + max-width: 800rpx; } /* 搜索框样式 */ @@ -140,12 +145,14 @@ page { min-height: calc(100vh - 60rpx); position: relative; background: #f5f5f5; + padding-bottom: calc(env(safe-area-inset-bottom) ); } .goods-list { height: auto; box-sizing: border-box; background: #f5f5f5; + padding-bottom: calc(env(safe-area-inset-bottom) ); } /* 标题样式 */ @@ -161,7 +168,7 @@ page { /* 搜索区域样式 */ .search-section { width: 100%; - margin: 0 30rpx 0 10rpx; + margin: 0; box-sizing: border-box; } @@ -337,7 +344,7 @@ wx-button:not([size=mini]) { background: transparent; border-radius: 0; border: none; - justify-content: flex-start; + justify-content: center; align-items: center; } @@ -606,6 +613,7 @@ wx-button:not([size=mini]) { .goods-list-container { padding: 20rpx 24rpx; padding-bottom: 20rpx; + padding-bottom: calc(env(safe-area-inset-bottom) + 140rpx); } .waterfall-container { @@ -1177,6 +1185,7 @@ wx-button:not([size=mini]) { padding: 0 20rpx; padding-bottom: 20rpx; min-height: calc(100% - 40rpx); + padding-bottom: calc(env(safe-area-inset-bottom) + 140rpx); } /* 瀑布流容器 */ @@ -1407,7 +1416,7 @@ wx-button:not([size=mini]) { align-items: center; justify-content: center; padding: 30rpx 20rpx; - padding-bottom: 50rpx; + padding-bottom: calc(env(safe-area-inset-bottom) + 10rpx); color: #999; font-size: 26rpx; gap: 20rpx; @@ -1546,9 +1555,9 @@ wx-button:not([size=mini]) { } .back-to-top-text { - font-size: 16rpx; + font-size: 30rpx; color: #1677ff; margin-top: 4rpx; - font-weight: 500; + font-weight: bold; text-shadow: 0 1rpx 2rpx rgba(255, 255, 255, 0.8); }