Browse Source

修复下拉刷新后加载错误商品状态的问题

pull/12/head
徐飞洋 2 months ago
parent
commit
701a29546f
  1. 13
      pages/index/index.js

13
pages/index/index.js

@ -457,7 +457,10 @@ Page({
// 保存当前筛选条件,用于验证请求结果
refreshCategory: currentCategory,
refreshKeyword: currentKeyword,
refreshRegion: currentRegion
refreshRegion: currentRegion,
// 下拉刷新时确保从published状态开始加载
isQueryingSoldOut: false,
publishedHasMore: true
})
const timestamp = new Date().getTime();
@ -956,6 +959,9 @@ Page({
const currentKeyword = this.data.searchKeyword;
const cacheKey = `${currentCategory}_${currentKeyword}`;
// 下拉刷新后检查返回的商品数量,决定是否还有更多published商品
const hasMorePublished = newGoodsOnly.length >= this.data.pageSize;
this.setData({
goods: newGoodsOnly,
filteredGoods: filteredGoods,
@ -963,6 +969,11 @@ Page({
loadingMore: false,
isLoading: false,
page: this.data.page + 1,
// 确保下拉刷新后继续加载published状态商品
isQueryingSoldOut: !hasMorePublished,
publishedHasMore: hasMorePublished,
// 如果切换到售空商品,重置售空商品页码
soldOutPage: !hasMorePublished ? 1 : this.data.soldOutPage,
// 更新缓存时间戳
lastDataTimestamp: new Date().getTime()
})

Loading…
Cancel
Save