|
|
@ -1,6 +1,21 @@ |
|
|
// pages/goods/index.js
|
|
|
// pages/goods/index.js
|
|
|
const API = require('../../utils/api.js') |
|
|
const API = require('../../utils/api.js') |
|
|
|
|
|
|
|
|
|
|
|
// 媒体类型判断函数
|
|
|
|
|
|
function isVideoUrl(url) { |
|
|
|
|
|
if (!url || typeof url !== 'string') { |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
const lowerUrl = url.toLowerCase(); |
|
|
|
|
|
const videoExtensions = ['.mp4', '.mov', '.avi', '.wmv', '.flv', '.webm', '.m4v', '.3gp']; |
|
|
|
|
|
for (const ext of videoExtensions) { |
|
|
|
|
|
if (lowerUrl.endsWith(ext)) { |
|
|
|
|
|
return true; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
Page({ |
|
|
Page({ |
|
|
// 分享给朋友/群聊
|
|
|
// 分享给朋友/群聊
|
|
|
onShareAppMessage() { |
|
|
onShareAppMessage() { |
|
|
@ -286,10 +301,20 @@ Page({ |
|
|
const creatorName = item.seller?.nickName || item.seller?.sellerNickName || '未知' |
|
|
const creatorName = item.seller?.nickName || item.seller?.sellerNickName || '未知' |
|
|
console.log('creatorName获取结果:', creatorName) |
|
|
console.log('creatorName获取结果:', creatorName) |
|
|
|
|
|
|
|
|
|
|
|
// 处理媒体URL,添加类型信息
|
|
|
|
|
|
const imageUrls = item.imageUrls || item.images || [] |
|
|
|
|
|
const formattedImageUrls = Array.isArray(imageUrls) ? imageUrls : [imageUrls] |
|
|
|
|
|
const mediaItems = formattedImageUrls.map(url => ({ |
|
|
|
|
|
url: url, |
|
|
|
|
|
type: isVideoUrl(url) ? 'video' : 'image' |
|
|
|
|
|
})) |
|
|
|
|
|
|
|
|
return { |
|
|
return { |
|
|
...item, |
|
|
...item, |
|
|
formattedCreatedAt: this.formatDateTime(item.created_at || item.createTime), |
|
|
formattedCreatedAt: this.formatDateTime(item.created_at || item.createTime), |
|
|
creatorName: creatorName |
|
|
creatorName: creatorName, |
|
|
|
|
|
imageUrls: formattedImageUrls, |
|
|
|
|
|
mediaItems: mediaItems |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
|