Browse Source

修复默认筛选下在售商品出现在售空商品之后的问题

pull/11/head
徐飞洋 2 months ago
parent
commit
f9068b47d4
  1. 28
      pages/index/index.js

28
pages/index/index.js

@ -431,7 +431,7 @@ Page({
}) })
}, },
onRefresh: function (showToast = true) { onRefresh: function () {
if (this.data.isRefreshing) { if (this.data.isRefreshing) {
return return
} }
@ -482,13 +482,11 @@ Page({
if (res.success && res.products) { if (res.success && res.products) {
this.processRefreshData(res.products, existingGoods) this.processRefreshData(res.products, existingGoods)
if (showToast) { wx.showToast({
wx.showToast({ title: '刷新成功',
title: '刷新成功', icon: 'success',
icon: 'success', duration: 1500
duration: 1500 })
})
}
} else if (res.products.length === 0) { } else if (res.products.length === 0) {
// 如果published状态没有商品,则查询sold_out状态 // 如果published状态没有商品,则查询sold_out状态
console.log('没有published状态的商品,查询sold_out状态的商品'); console.log('没有published状态的商品,查询sold_out状态的商品');
@ -509,13 +507,11 @@ Page({
if (soldOutRes.success && soldOutRes.products && soldOutRes.products.length > 0) { if (soldOutRes.success && soldOutRes.products && soldOutRes.products.length > 0) {
this.processRefreshData(soldOutRes.products, existingGoods); this.processRefreshData(soldOutRes.products, existingGoods);
if (showToast) { wx.showToast({
wx.showToast({ title: '刷新成功',
title: '刷新成功', icon: 'success',
icon: 'success', duration: 1500
duration: 1500 });
});
}
} else { } else {
this.setData({ this.setData({
isLoading: false, isLoading: false,
@ -1587,7 +1583,7 @@ Page({
if (filteredGoods.length < 3 && this.data.searchKeyword) { if (filteredGoods.length < 3 && this.data.searchKeyword) {
console.log('searchGoods - 本地过滤结果不足3个,将重新加载数据'); console.log('searchGoods - 本地过滤结果不足3个,将重新加载数据');
// 调用下拉刷新函数实现自动刷新 // 调用下拉刷新函数实现自动刷新
this.onRefresh(false); this.onRefresh();
} else { } else {
// 本地商品足够,直接使用本地过滤结果 // 本地商品足够,直接使用本地过滤结果
console.log('searchGoods:使用本地商品过滤结果,数量:', filteredGoods.length); console.log('searchGoods:使用本地商品过滤结果,数量:', filteredGoods.length);

Loading…
Cancel
Save