You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.6 KiB

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}`
});
}
}
}
});