Browse Source

fix: 修复分享图片逻辑,过滤视频使用第一张图片

pull/7/head
Trae AI 2 months ago
parent
commit
cbf553686c
  1. 13
      pages/goods-detail/goods-detail.js

13
pages/goods-detail/goods-detail.js

@ -86,8 +86,17 @@ function getShareImageUrl(goodsDetail) {
const imageUrls = goodsDetail.imageUrls || []; const imageUrls = goodsDetail.imageUrls || [];
if (imageUrls.length > 0) { if (imageUrls.length > 0) {
// 返回第一张图片作为分享图片 // 过滤出图片类型
return imageUrls[0]; const imageOnly = imageUrls.filter(url => !isVideoUrl(url));
if (imageOnly.length > 0) {
// 情况1: 有图片 → 使用第一张图片
return imageOnly[0];
}
// 情况2: 全是视频 → 使用第一帧(暂无封面字段,返回默认图片)
// 注: 当前数据结构无poster字段,如需视频封面需后端添加
return '/images/你有好蛋.png';
} }
return '/images/你有好蛋.png'; return '/images/你有好蛋.png';

Loading…
Cancel
Save