首页修改
Some checks failed
Uniapp 自动化打包 CI/CD / 打包 Uniapp 项目 (push) Has been cancelled

This commit is contained in:
2025-09-10 13:42:07 +08:00
parent a0e9c96897
commit 3b097ae838

View File

@@ -154,22 +154,38 @@ import toast from '../../../uview-ui/libs/function/toast';
}
},
async getImageUrl() {
// 处理hotList中的图片链接
// 收集所有需要获取链接的图片ID
const imgIds = [];
const imgIdToIndexMap = []; // 保存图片ID对应的hotList索引
for (let i = 0; i < this.hotList.length; i++) {
const item = this.hotList[i];
if (item.activityImgUrl) {
imgIds.push(item.activityImgUrl);
imgIdToIndexMap.push({
id: item.activityImgUrl,
index: i
});
}
}
// 如果有图片ID需要处理则调用API一次获取所有图片链接
if (imgIds.length > 0) {
try {
const imgRes = await this.$u.api.getImageUrl({}, item.activityImgUrl);
if (imgRes.code == 200 && imgRes.data && imgRes.data.length > 0) {
// 将图片ID替换为实际的图片URL
this.$set(this.hotList[i], 'activityImgUrl', imgRes.data[0].url);
const imgRes = await this.$u.api.getImageUrl({}, imgIds.join(','));
if (imgRes.code == 200 && imgRes.data) {
// 将返回的图片URL映射回对应的hotList项
imgRes.data.forEach(imgItem => {
const mapping = imgIdToIndexMap.find(m => m.id === imgItem.ossId);
if (mapping) {
this.$set(this.hotList[mapping.index], 'activityImgUrl', imgItem.url);
}
});
}
} catch (error) {
console.error('获取图片链接失败:', error);
}
}
}
console.log('t1',this.hotList)
},
goNoticeDetail(item){
let params = {}