|
|
|
@ -777,8 +777,8 @@ Page({ |
|
|
|
isLoading: false, |
|
|
|
isRefreshing: false, |
|
|
|
// 根据当前是否在查询售空商品来更新对应的页码
|
|
|
|
// soldOutPage 已经在 loadSoldOutData 函数中直接更新
|
|
|
|
page: this.data.isQueryingSoldOut ? this.data.page : this.data.page + 1, |
|
|
|
soldOutPage: this.data.isQueryingSoldOut ? this.data.soldOutPage + 1 : this.data.soldOutPage, |
|
|
|
lastDataTimestamp: new Date().getTime() |
|
|
|
}) |
|
|
|
|
|
|
|
@ -1046,10 +1046,8 @@ Page({ |
|
|
|
// 如果有published商品,直接处理
|
|
|
|
if (res.success && res.products && res.products.length > 0) { |
|
|
|
console.log('有published商品,处理商品数据'); |
|
|
|
const totalGoods = res.total || 0; |
|
|
|
const totalPages = res.totalPages || Math.ceil(totalGoods / pageSize); |
|
|
|
// 只需要判断是否还有下一页,不需要检查当前页数据量是否等于pageSize
|
|
|
|
const publishedHasMore = page < totalPages; |
|
|
|
// 使用返回的商品数量来判断是否还有下一页
|
|
|
|
const publishedHasMore = res.products.length === pageSize; |
|
|
|
|
|
|
|
// 更新缓存(加载更多时追加数据)
|
|
|
|
const updatedCache = { ...this.data.categoryQueryCache }; |
|
|
|
@ -1069,7 +1067,9 @@ Page({ |
|
|
|
publishedHasMore: publishedHasMore, |
|
|
|
categoryQueryCache: updatedCache, |
|
|
|
lastDataTimestamp: now, |
|
|
|
goodsCache: updatedCache[cacheKey] |
|
|
|
goodsCache: updatedCache[cacheKey], |
|
|
|
// 当切换到加载售空商品时,重置售空商品的页码为1
|
|
|
|
soldOutPage: !publishedHasMore ? 1 : this.data.soldOutPage |
|
|
|
}); |
|
|
|
|
|
|
|
this.processGoodsData(res.products, isLoadMore); |
|
|
|
@ -1120,9 +1120,8 @@ Page({ |
|
|
|
console.log('soldOutRes.products.length:', soldOutRes.products ? soldOutRes.products.length : 'undefined'); |
|
|
|
|
|
|
|
if (soldOutRes.success && soldOutRes.products && soldOutRes.products.length > 0) { |
|
|
|
const soldOutTotal = soldOutRes.total || 0; |
|
|
|
const soldOutTotalPages = soldOutRes.totalPages || Math.ceil(soldOutTotal / pageSize); |
|
|
|
const soldOutHasMore = soldOutPageNum < soldOutTotalPages; |
|
|
|
// 使用返回的商品数量来判断是否还有下一页
|
|
|
|
const soldOutHasMore = soldOutRes.products.length === pageSize; |
|
|
|
|
|
|
|
// 更新缓存
|
|
|
|
const updatedCache = { ...this.data.categoryQueryCache }; |
|
|
|
@ -1132,15 +1131,17 @@ Page({ |
|
|
|
|
|
|
|
updatedCache[cacheKey] = [...existingCache, ...uniqueSoldOutProducts]; |
|
|
|
|
|
|
|
this.processGoodsData(uniqueSoldOutProducts, isLoadMore); |
|
|
|
|
|
|
|
this.setData({ |
|
|
|
hasMoreData: soldOutHasMore, |
|
|
|
isQueryingSoldOut: soldOutHasMore, |
|
|
|
categoryQueryCache: updatedCache, |
|
|
|
lastDataTimestamp: new Date().getTime(), |
|
|
|
goodsCache: updatedCache[cacheKey] |
|
|
|
goodsCache: updatedCache[cacheKey], |
|
|
|
// 直接更新售空商品的页码
|
|
|
|
soldOutPage: soldOutPageNum + 1 |
|
|
|
}); |
|
|
|
|
|
|
|
this.processGoodsData(uniqueSoldOutProducts, isLoadMore); |
|
|
|
console.log('sold_out数据加载完成,总商品数:', updatedCache[cacheKey].length, 'hasMoreData:', soldOutHasMore); |
|
|
|
} else { |
|
|
|
console.log('没有找到更多sold_out商品'); |
|
|
|
@ -1318,18 +1319,14 @@ Page({ |
|
|
|
|
|
|
|
console.log('applyFilters - 开始过滤,原始商品数量:', goods.length, '关键词:', this.data.searchKeyword); |
|
|
|
|
|
|
|
// 筛选条件:销售价为空并且没有联系人信息的不显示在主页上
|
|
|
|
// 移除所有不必要的过滤条件,确保所有published和sold_out状态的商品都能显示
|
|
|
|
filtered = filtered.filter(item => { |
|
|
|
// 广告位不受影响
|
|
|
|
if (item.isAd) { |
|
|
|
return true; |
|
|
|
} |
|
|
|
// 销售价为空
|
|
|
|
const hasEmptyPrice = !item.price || item.price === '' || parseFloat(item.price) === 0; |
|
|
|
// 没有联系人信息
|
|
|
|
const hasNoContact = !item.product_contact || item.product_contact === '' || !item.contact_phone || item.contact_phone === ''; |
|
|
|
// 只保留:销售价不为空 或 有联系人信息 的商品
|
|
|
|
return !(hasEmptyPrice && hasNoContact); |
|
|
|
// 所有published和sold_out状态的商品都保留
|
|
|
|
return true; |
|
|
|
}); |
|
|
|
|
|
|
|
if (this.data.selectedCategory !== '全部') { |
|
|
|
|