Browse Source

修复筛选时数据未加载完成时的页面显示问题

pull/4/head
徐飞洋 2 months ago
parent
commit
4dd891d553
  1. 9
      pages/index/index.js
  2. 11
      pages/index/index.wxml

9
pages/index/index.js

@ -706,6 +706,7 @@ Page({
filteredGoods: filteredGoods,
loadingMore: false,
isLoading: false,
isRefreshing: false, // 确保下拉刷新状态被重置
page: this.data.page + 1,
// 更新缓存时间戳
lastDataTimestamp: new Date().getTime()
@ -956,7 +957,11 @@ Page({
})
.catch(err => {
console.error('加载商品数据失败:', err)
this.setData({ loadingMore: false, isLoading: false })
this.setData({
loadingMore: false,
isLoading: false,
isRefreshing: false // 确保下拉刷新状态被重置
})
})
},
@ -1056,6 +1061,7 @@ Page({
filteredGoods: filteredGoods,
loadingMore: false,
isLoading: false,
isRefreshing: false, // 确保下拉刷新状态被重置
hasMoreData: false // 缓存数据不分页
});
},
@ -1418,6 +1424,7 @@ Page({
goods: [],
filteredGoods: [],
isLoading: true,
isRefreshing: true, // 添加下拉刷新状态
// 清除所有缓存以获取最新数据
categoryQueryCache: {},
lastDataTimestamp: 0,

11
pages/index/index.wxml

@ -105,7 +105,7 @@
</view>
<!-- 骨架屏加载 -->
<view wx:if="{{isLoading && goods.length === 0}}" class="skeleton-container">
<view wx:if="{{isLoading}}" class="skeleton-container">
<view class="skeleton-grid">
<view class="skeleton-grid-item" wx:for="{{[1,2,3,4,5,6,7,8]}}" wx:key="index">
<view class="skeleton-image"></view>
@ -119,7 +119,7 @@
</view>
<!-- 商品列表区域 -->
<view class="goods-section">
<view class="goods-section" wx:if="{{!isLoading && filteredGoods.length > 0}}">
<scroll-view
class="goods-list"
id="goodsScrollView"
@ -213,6 +213,13 @@
</view>
</scroll-view>
</view>
<!-- 无商品时显示(初始加载时) -->
<view wx:if="{{!isLoading && filteredGoods.length === 0}}" class="empty-goods" style="margin-top: 100rpx;">
<view class="empty-icon">📦</view>
<text class="empty-text">暂无商品数据</text>
<text class="empty-hint">下拉刷新试试</text>
</view>
<!-- 登录弹窗 -->
<view wx:if="{{showOneKeyLoginModal}}" class="auth-modal-overlay">
<view class="auth-modal-container">

Loading…
Cancel
Save