|
|
@ -735,6 +735,7 @@ Page({ |
|
|
id: 'ad_slot_1', |
|
|
id: 'ad_slot_1', |
|
|
name: '广告位1', |
|
|
name: '广告位1', |
|
|
imageUrls: ['/images/轮播图1.jpg'], |
|
|
imageUrls: ['/images/轮播图1.jpg'], |
|
|
|
|
|
mediaItems: [{ url: '/images/轮播图1.jpg', type: 'image' }], |
|
|
price: 0, |
|
|
price: 0, |
|
|
adType: 'full_card', |
|
|
adType: 'full_card', |
|
|
isAd: true |
|
|
isAd: true |
|
|
@ -743,6 +744,7 @@ Page({ |
|
|
id: 'ad_slot_2', |
|
|
id: 'ad_slot_2', |
|
|
name: '广告位2', |
|
|
name: '广告位2', |
|
|
imageUrls: ['/images/轮播图1.jpg'], |
|
|
imageUrls: ['/images/轮播图1.jpg'], |
|
|
|
|
|
mediaItems: [{ url: '/images/轮播图1.jpg', type: 'image' }], |
|
|
price: 0, |
|
|
price: 0, |
|
|
adType: 'half_image', |
|
|
adType: 'half_image', |
|
|
isAd: true |
|
|
isAd: true |
|
|
@ -803,6 +805,14 @@ Page({ |
|
|
// 确保商品ID的一致性
|
|
|
// 确保商品ID的一致性
|
|
|
const productId = product.productId || product.id; |
|
|
const productId = product.productId || product.id; |
|
|
|
|
|
|
|
|
|
|
|
// 预处理媒体URL,添加类型信息
|
|
|
|
|
|
const mediaItems = formattedImageUrls.map(url => { |
|
|
|
|
|
return { |
|
|
|
|
|
url: url, |
|
|
|
|
|
type: isVideoUrl(url) ? 'video' : 'image' |
|
|
|
|
|
}; |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
return { |
|
|
return { |
|
|
...product, |
|
|
...product, |
|
|
id: productId, // 统一使用id字段
|
|
|
id: productId, // 统一使用id字段
|
|
|
@ -825,7 +835,9 @@ Page({ |
|
|
isReserved: false, |
|
|
isReserved: false, |
|
|
isFavorite: false, |
|
|
isFavorite: false, |
|
|
currentImageIndex: 0, |
|
|
currentImageIndex: 0, |
|
|
imageUrls: formattedImageUrls |
|
|
imageUrls: formattedImageUrls, |
|
|
|
|
|
// 添加预处理后的媒体数据,包含类型信息
|
|
|
|
|
|
mediaItems: mediaItems |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
@ -894,6 +906,7 @@ Page({ |
|
|
id: 'ad_slot_1', |
|
|
id: 'ad_slot_1', |
|
|
name: '广告位1', |
|
|
name: '广告位1', |
|
|
imageUrls: ['/images/轮播图1.jpg'], |
|
|
imageUrls: ['/images/轮播图1.jpg'], |
|
|
|
|
|
mediaItems: [{ url: '/images/轮播图1.jpg', type: 'image' }], |
|
|
price: 0, |
|
|
price: 0, |
|
|
adType: 'full_card', |
|
|
adType: 'full_card', |
|
|
isAd: true |
|
|
isAd: true |
|
|
@ -903,6 +916,7 @@ Page({ |
|
|
id: 'ad_slot_2', |
|
|
id: 'ad_slot_2', |
|
|
name: '广告位2', |
|
|
name: '广告位2', |
|
|
imageUrls: ['/images/轮播图1.jpg'], |
|
|
imageUrls: ['/images/轮播图1.jpg'], |
|
|
|
|
|
mediaItems: [{ url: '/images/轮播图1.jpg', type: 'image' }], |
|
|
price: 0, |
|
|
price: 0, |
|
|
adType: 'half_image', |
|
|
adType: 'half_image', |
|
|
isAd: true |
|
|
isAd: true |
|
|
@ -1568,22 +1582,8 @@ Page({ |
|
|
// 如果本地过滤结果不足,或者没有匹配的商品,则重新加载数据
|
|
|
// 如果本地过滤结果不足,或者没有匹配的商品,则重新加载数据
|
|
|
if (filteredGoods.length < 3 && this.data.searchKeyword) { |
|
|
if (filteredGoods.length < 3 && this.data.searchKeyword) { |
|
|
console.log('searchGoods - 本地过滤结果不足3个,将重新加载数据'); |
|
|
console.log('searchGoods - 本地过滤结果不足3个,将重新加载数据'); |
|
|
this.setData({ |
|
|
// 调用下拉刷新函数实现自动刷新
|
|
|
page: 1, |
|
|
this.onRefresh(); |
|
|
hasMoreData: true, |
|
|
|
|
|
goods: [], |
|
|
|
|
|
filteredGoods: [], |
|
|
|
|
|
loadingMore: false, |
|
|
|
|
|
// 清除相关缓存以获取最新数据
|
|
|
|
|
|
lastDataTimestamp: 0, |
|
|
|
|
|
categoryQueryCache: {}, |
|
|
|
|
|
isQueryingSoldOut: false, |
|
|
|
|
|
publishedHasMore: true, |
|
|
|
|
|
soldOutPage: 1 |
|
|
|
|
|
}, () => { |
|
|
|
|
|
console.log('searchGoods:本地商品不足,重新加载数据,搜索关键词:', this.data.searchKeyword); |
|
|
|
|
|
this.loadGoods(false, true); // 第二个参数true表示强制刷新
|
|
|
|
|
|
}); |
|
|
|
|
|
} else { |
|
|
} else { |
|
|
// 本地商品足够,直接使用本地过滤结果
|
|
|
// 本地商品足够,直接使用本地过滤结果
|
|
|
console.log('searchGoods:使用本地商品过滤结果,数量:', filteredGoods.length); |
|
|
console.log('searchGoods:使用本地商品过滤结果,数量:', filteredGoods.length); |
|
|
@ -1606,7 +1606,7 @@ Page({ |
|
|
selectRegion: function (e) { |
|
|
selectRegion: function (e) { |
|
|
const region = e.currentTarget.dataset.region |
|
|
const region = e.currentTarget.dataset.region |
|
|
|
|
|
|
|
|
// 立即关闭弹窗
|
|
|
// 立即关闭弹窗并设置新的地区
|
|
|
this.setData({ |
|
|
this.setData({ |
|
|
selectedRegion: region, |
|
|
selectedRegion: region, |
|
|
searchKeyword: '', // 清除搜索关键词,筛选框优先级更高
|
|
|
searchKeyword: '', // 清除搜索关键词,筛选框优先级更高
|
|
|
@ -1619,21 +1619,8 @@ Page({ |
|
|
app.globalData.showTabBar = true; |
|
|
app.globalData.showTabBar = true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 清除缓存并重新加载数据 - 仿照下拉刷新机制
|
|
|
// 调用下拉刷新函数实现自动刷新
|
|
|
this.setData({ |
|
|
this.onRefresh(); |
|
|
page: 1, |
|
|
|
|
|
hasMoreData: true, |
|
|
|
|
|
goods: [], |
|
|
|
|
|
filteredGoods: [], |
|
|
|
|
|
loadingMore: false, |
|
|
|
|
|
// 清除所有缓存以获取最新数据
|
|
|
|
|
|
categoryQueryCache: {}, |
|
|
|
|
|
lastDataTimestamp: 0, |
|
|
|
|
|
goodsCache: [] |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.loadGoods(false, true); // 强制刷新
|
|
|
|
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
// 阻止事件冒泡
|
|
|
// 阻止事件冒泡
|
|
|
@ -1654,26 +1641,14 @@ Page({ |
|
|
return // 如果选择的分类和当前相同,不重复加载
|
|
|
return // 如果选择的分类和当前相同,不重复加载
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 清除缓存并重新加载数据 - 筛选时不显示骨架屏,直接显示内容
|
|
|
// 设置新的分类并清除搜索关键词
|
|
|
this.setData({ |
|
|
this.setData({ |
|
|
selectedCategory: category, |
|
|
selectedCategory: category, |
|
|
searchKeyword: '', // 清除搜索关键词,筛选框优先级更高
|
|
|
searchKeyword: '', // 清除搜索关键词,筛选框优先级更高
|
|
|
loadingMore: false, |
|
|
|
|
|
page: 1, |
|
|
|
|
|
hasMoreData: true, |
|
|
|
|
|
goods: [], |
|
|
|
|
|
filteredGoods: [], |
|
|
|
|
|
isLoading: false, // 筛选时不显示骨架屏
|
|
|
|
|
|
isRefreshing: false, // 筛选时不显示下拉刷新状态
|
|
|
|
|
|
// 清除所有缓存以获取最新数据
|
|
|
|
|
|
categoryQueryCache: {}, |
|
|
|
|
|
lastDataTimestamp: 0, |
|
|
|
|
|
goodsCache: [] |
|
|
|
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
// 强制刷新:从数据库重新加载数据
|
|
|
// 调用下拉刷新函数实现自动刷新
|
|
|
|
|
|
this.onRefresh(); |
|
|
this.loadGoods(false, true); // 第二个参数true表示强制刷新
|
|
|
|
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
// 查看商品详情
|
|
|
// 查看商品详情
|
|
|
|