From cd3107a5c6b1fa941b6a56952271ea55c3060a9b Mon Sep 17 00:00:00 2001 From: Default User Date: Thu, 15 Jan 2026 14:48:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=81=8A=E5=A4=A9=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E9=A1=B5=E9=9D=A2=E8=A7=86=E9=A2=91=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E5=92=8C=E5=92=A8=E8=AF=A2=E6=8C=89=E9=92=AE?= =?UTF-8?q?=E5=95=86=E5=93=81=E5=8D=A1=E7=89=87=E5=8F=91=E9=80=81=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/goods-card/goods-card.js | 21 ++++++++++++++++++++- components/goods-card/goods-card.wxml | 15 ++++++++++++++- pages/goods-detail/goods-detail.js | 5 ++++- 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/components/goods-card/goods-card.js b/components/goods-card/goods-card.js index 1ad8696..307e067 100644 --- a/components/goods-card/goods-card.js +++ b/components/goods-card/goods-card.js @@ -19,7 +19,8 @@ Component({ }, data: { - isSoldOut: false + isSoldOut: false, + isVideo: false }, observers: { @@ -27,10 +28,28 @@ Component({ this.setData({ isSoldOut: status === 'sold_out' }); + }, + 'imageUrl': function(imageUrl) { + this.setData({ + isVideo: this.isVideoUrl(imageUrl) + }); } }, methods: { + // 判断是否为视频URL + isVideoUrl: function(url) { + if (!url) return false; + const videoExtensions = ['.mp4', '.mov', '.avi', '.wmv', '.flv', '.webm']; + const lowerUrl = url.toLowerCase(); + for (let ext of videoExtensions) { + if (lowerUrl.indexOf(ext) > -1) { + return true; + } + } + return false; + }, + onTap: function() { const goodsId = this.properties.id; if (goodsId) { diff --git a/components/goods-card/goods-card.wxml b/components/goods-card/goods-card.wxml index 26db4ae..60ca01b 100644 --- a/components/goods-card/goods-card.wxml +++ b/components/goods-card/goods-card.wxml @@ -1,12 +1,25 @@ + + + + 暂无图片 diff --git a/pages/goods-detail/goods-detail.js b/pages/goods-detail/goods-detail.js index 2858639..1e84ed8 100644 --- a/pages/goods-detail/goods-detail.js +++ b/pages/goods-detail/goods-detail.js @@ -1891,7 +1891,10 @@ Page({ id: goodsDetail.id || '', name: goodsDetail.name || '', imageUrl: (goodsDetail.imageUrls && goodsDetail.imageUrls.length > 0) ? - (goodsDetail.imageUrls.find(url => !isVideoUrl(url)) || '') : '', + (goodsDetail.imageUrls.find(url => !isVideoUrl(url)) || + goodsDetail.imageUrls.find(url => isVideoUrl(url)) || + goodsDetail.videoCoverUrl || '') : + (goodsDetail.videoCoverUrl || ''), price: goodsDetail.price || '', region: goodsDetail.region || '', displaySpecification: goodsDetail.displaySpecification || goodsDetail.specification || goodsDetail.spec || goodsDetail.specs || '',