Browse Source

修复商品排序和加载逻辑问题:1. 实现默认排序规则(先按状态分组,组内按预订数量降序、价格升序、创建时间降序);2. 修复sold_out商品加载逻辑错误;3. 修复下滑到底部不加载售空商品的问题;4. 修复下拉刷新时改变已加载商品顺序的问题;5. 确保下滑时数据顺序不改变

pull/11/head
徐飞洋 2 months ago
parent
commit
0ecc9cc3d5
  1. 9
      pages/index/index.js

9
pages/index/index.js

@ -930,7 +930,8 @@ Page({
// 加载商品数据 - 优化版带缓存,支持状态优先级
loadGoods: function (isLoadMore = false, forceRefresh = false) {
if (isLoadMore && !this.data.hasMoreData) {
// 当正在加载售空商品时,即使hasMoreData为false也继续加载
if (isLoadMore && !this.data.hasMoreData && !this.data.isQueryingSoldOut) {
return
}
@ -946,7 +947,7 @@ Page({
// 如果正在加载sold_out,继续加载sold_out
if (isLoadMore && this.data.isQueryingSoldOut) {
this.loadSoldOutData(cacheKey, currentKeyword, currentCategory, timestamp, true);
this.loadSoldOutData(cacheKey, currentKeyword, currentCategory, timestamp, isLoadMore);
return;
}
@ -1021,7 +1022,7 @@ Page({
}
this.setData({
hasMoreData: publishedHasMore || true, // 当切换到加载售空商品时,保持hasMoreData为true以允许继续加载
hasMoreData: true, // 保持hasMoreData为true,以便在已发布商品加载完毕后继续加载售空商品
isQueryingSoldOut: !publishedHasMore, // 当已发布商品加载完毕时,切换到加载售空商品
publishedHasMore: publishedHasMore,
categoryQueryCache: updatedCache,
@ -1102,7 +1103,7 @@ Page({
goodsCache: updatedCache[cacheKey]
});
this.processGoodsData(updatedCache[cacheKey], isLoadMore);
this.processGoodsData(uniqueSoldOutProducts, isLoadMore);
console.log('sold_out数据加载完成,总商品数:', updatedCache[cacheKey].length, 'hasMoreData:', soldOutHasMore);
} else {
console.log('没有找到更多sold_out商品');

Loading…
Cancel
Save