Component({ options: { styleIsolation: "apply-shared" }, properties: { item: Object }, data: { show: true, like: 1 }, methods: { getActivityInfo: function () { wx.navigateTo({ url: '/pages/activity/activity', events: { deleteMessage: () => { this.setData({ show: false }) } } }).then(res => { res.eventChannel.emit('loadCommonData', { data: this.data.item }) }) }, getPublisherInfo: function () { wx.navigateTo({ url: '/pages/publisher/publisher', }).then(res => { res.eventChannel.emit('loadCommonData', { data: this.data.item.publisher }) }) }, toggleLike: function () { if (this.data.likeDisabled) { return } wx.showLoading({ title: this.data.like ? '取消收藏' : '收藏中' }) wx.cloud.callFunction({ name: this.data.like ? 'deleteFavorite' : 'createFavorite', data: { msg_id: this.data.item._id } }).then(res => { wx.hideLoading() if (res.result.status !== 'OK') { wx.showToast({ title: res.result.errMsg, icon: 'none' }) return } wx.showToast({ title: this.data.like ? '取消收藏成功' : '收藏成功', icon: 'none' }) this.setData({ like: !this.data.like }) }) } } })