|
|
|
@ -645,6 +645,7 @@ Page({ |
|
|
|
favoriteGoods: [], // 收藏商品数据
|
|
|
|
loadingHome: false, // 首页数据加载状态
|
|
|
|
loadingFavorite: false, // 收藏数据加载状态
|
|
|
|
scrollTop: 0, // 记录页面滚动位置
|
|
|
|
// 新增以下字段:
|
|
|
|
videoCoverUrl: null, // 视频封面图片URL
|
|
|
|
isExtractingCover: false, // 是否正在提取封面
|
|
|
|
@ -2426,20 +2427,26 @@ Page({ |
|
|
|
// 对比价格功能:处理按钮点击事件
|
|
|
|
onCompareClick: function () { |
|
|
|
console.log('用户点击了对比价格按钮,准备显示弹窗'); |
|
|
|
// 立即显示弹窗,不等待数据加载
|
|
|
|
this.setData({ |
|
|
|
showCompareModal: true, |
|
|
|
activeTab: 'home' // 默认显示首页数据选项卡
|
|
|
|
}); |
|
|
|
|
|
|
|
// 打印弹窗状态,用于调试
|
|
|
|
console.log('弹窗状态设置为:', this.data.showCompareModal); |
|
|
|
|
|
|
|
// 加载首页数据
|
|
|
|
this.loadHomeGoods(); |
|
|
|
|
|
|
|
// 加载收藏数据
|
|
|
|
this.loadFavoriteGoods(); |
|
|
|
// 直接获取当前页面滚动位置
|
|
|
|
wx.createSelectorQuery().selectViewport().scrollOffset(function(res) { |
|
|
|
console.log('记录当前滚动位置:', res.scrollTop); |
|
|
|
// 保存滚动位置并显示弹窗
|
|
|
|
this.setData({ |
|
|
|
scrollTop: res.scrollTop, |
|
|
|
showCompareModal: true, |
|
|
|
activeTab: 'home' // 默认显示首页数据选项卡
|
|
|
|
}); |
|
|
|
|
|
|
|
// 打印弹窗状态,用于调试
|
|
|
|
console.log('弹窗状态设置为:', this.data.showCompareModal); |
|
|
|
|
|
|
|
// 加载首页数据
|
|
|
|
this.loadHomeGoods(); |
|
|
|
|
|
|
|
// 加载收藏数据
|
|
|
|
this.loadFavoriteGoods(); |
|
|
|
}.bind(this)).exec(); |
|
|
|
}, |
|
|
|
|
|
|
|
// 关闭对比价格弹窗
|
|
|
|
@ -2447,6 +2454,15 @@ Page({ |
|
|
|
this.setData({ |
|
|
|
showCompareModal: false |
|
|
|
}); |
|
|
|
|
|
|
|
// 恢复页面滚动位置
|
|
|
|
setTimeout(() => { |
|
|
|
console.log('恢复滚动位置:', this.data.scrollTop); |
|
|
|
wx.pageScrollTo({ |
|
|
|
scrollTop: this.data.scrollTop, |
|
|
|
duration: 0 |
|
|
|
}); |
|
|
|
}, 100); |
|
|
|
}, |
|
|
|
|
|
|
|
// 阻止事件冒泡
|
|
|
|
|