Files
zhuomi-hui/miniprogram/components/activity-board/index.js
T

42 lines
754 B
JavaScript
Raw Normal View History

const media = require('../../utils/media')
Component({
properties: {
activity: {
type: Object,
value: null
},
showPast: {
type: Boolean,
value: false
}
},
data: {
poster: '',
video: '',
ended: false
},
observers: {
activity(activity) {
const item = activity || {}
this.setData({
poster: media.absUrl(item.cover || item.poster),
video: media.absUrl(item.video),
ended: item.status === 'past'
})
}
},
methods: {
onMap() {
this.triggerEvent('map')
},
onSignup() {
if (!this.data.activity || this.data.ended) return
this.triggerEvent('signup')
},
onPast() {
this.triggerEvent('past')
}
}
})