统一排行榜对齐星雀UI,页面资源后台配置实时刷新

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
XingQue
2026-06-27 01:26:11 +08:00
parent 1ab2e2080a
commit 21112173f2
292 changed files with 64010 additions and 81 deletions

View File

@@ -0,0 +1,103 @@
Page({
onShow() {
// 原有代码...
// 🆕 注册通知组件
this.registerNotificationComponent();
},
// 🆕 新增:注册通知组件
registerNotificationComponent() {
const app = getApp();
const notificationComp = this.selectComponent('#global-notification');
if (notificationComp && notificationComp.showNotification) {
console.log('🏪 商城页面注册通知组件');
app.globalData.globalNotification = {
show: (data) => notificationComp.showNotification(data),
hide: () => notificationComp.hideNotification()
};
}
},
data: {
// 图片URL带时间戳避免缓存
imageUrl: '',
// 容器高度初始为100vh加载后调整为图片高度
containerHeight: 0
},
onLoad() {
// 初始设置容器高度为屏幕高度
this.getSystemInfo()
// 构建图片URL带时间戳
this.buildImageUrl()
},
// 获取系统信息
getSystemInfo() {
const res = wx.getSystemInfoSync()
this.setData({
containerHeight: res.windowHeight
})
},
// 构建图片URL关键加时间戳避免缓存
buildImageUrl() {
const app = getApp()
const ossImageUrl = app.globalData.ossImageUrl || ''
const dashouguize = app.globalData.dashouguize || ''
// 加上时间戳参数,强制每次重新加载
const timestamp = new Date().getTime()
const fullImageUrl = ossImageUrl + dashouguize + '?t=' + timestamp
//console.log('规则图片URL带时间戳:', fullImageUrl)
this.setData({
imageUrl: fullImageUrl
})
},
// 图片加载成功
onImageLoad(e) {
//console.log('图片加载成功,原始尺寸:', e.detail.width, 'x', e.detail.height)
// 根据图片实际高度设置容器高度
// 图片宽度为屏幕宽度,高度按比例计算
const systemInfo = wx.getSystemInfoSync()
const screenWidth = systemInfo.screenWidth // 单位px
// 图片的实际像素尺寸
const imageWidth = e.detail.width
const imageHeight = e.detail.height
// 计算在小程序中显示的高度(保持比例)
// 图片在小程序中宽度为100%屏幕宽度,高度按比例缩放
const displayHeight = (imageHeight / imageWidth) * screenWidth
//console.log('计算后显示高度:', displayHeight, 'px')
// 设置容器高度为图片高度
this.setData({
containerHeight: displayHeight
})
},
// 图片加载失败
onImageError() {
console.error('图片加载失败')
wx.showToast({
title: '图片加载失败',
icon: 'none',
duration: 2000
})
},
// 下拉刷新
onPullDownRefresh() {
// 重新构建图片URL带新时间戳
this.buildImageUrl()
// 停止下拉刷新
wx.stopPullDownRefresh()
}
})