Component({ properties: { id: { type: String, value: '' }, name: { type: String, value: '' }, imageUrl: { type: String, value: '' }, price: { type: [String, Number], value: '' }, priceUnit: { type: String, value: '/件' }, region: { type: String, value: '' }, specification: { type: String, value: '' }, spec: { type: String, value: '' }, specs: { type: String, value: '' }, displaySpecification: { type: String, value: '' }, displayYolk: { type: String, value: '' }, sourceType: { type: String, value: '' }, totalStock: { type: [String, Number], value: '' }, supplyStatus: { type: String, value: '' }, status: { type: String, value: '' }, reservedCount: { type: [String, Number], value: 0 } }, data: { isSoldOut: false, isVideo: false }, observers: { 'status': function(status) { 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) { wx.navigateTo({ url: `/pages/goods-detail/goods-detail?id=${goodsId}` }); } } } });