This commit is contained in:
@@ -154,22 +154,38 @@ import toast from '../../../uview-ui/libs/function/toast';
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
async getImageUrl() {
|
async getImageUrl() {
|
||||||
// 处理hotList中的图片链接
|
// 收集所有需要获取链接的图片ID
|
||||||
|
const imgIds = [];
|
||||||
|
const imgIdToIndexMap = []; // 保存图片ID对应的hotList索引
|
||||||
|
|
||||||
for (let i = 0; i < this.hotList.length; i++) {
|
for (let i = 0; i < this.hotList.length; i++) {
|
||||||
const item = this.hotList[i];
|
const item = this.hotList[i];
|
||||||
if (item.activityImgUrl) {
|
if (item.activityImgUrl) {
|
||||||
try {
|
imgIds.push(item.activityImgUrl);
|
||||||
const imgRes = await this.$u.api.getImageUrl({}, item.activityImgUrl);
|
imgIdToIndexMap.push({
|
||||||
if (imgRes.code == 200 && imgRes.data && imgRes.data.length > 0) {
|
id: item.activityImgUrl,
|
||||||
// 将图片ID替换为实际的图片URL
|
index: i
|
||||||
this.$set(this.hotList[i], 'activityImgUrl', imgRes.data[0].url);
|
});
|
||||||
}
|
}
|
||||||
} catch (error) {
|
}
|
||||||
console.error('获取图片链接失败:', error);
|
|
||||||
}
|
// 如果有图片ID需要处理,则调用API一次获取所有图片链接
|
||||||
|
if (imgIds.length > 0) {
|
||||||
|
try {
|
||||||
|
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){
|
goNoticeDetail(item){
|
||||||
let params = {}
|
let params = {}
|
||||||
|
Reference in New Issue
Block a user