Component({ options: { styleIsolation: "apply-shared" }, properties: { item: Object }, data: { like: 1 }, methods: { getPublisherInfo: function () { wx.navigateTo({ url: '/pages/publisher/publisher', }).then(res => { res.eventChannel.emit('loadCommonData', { data: this.data.item }) }) }, toggleLike: function () { if (this.data.loading) { return } wx.showLoading({ title: this.data.like ? '取消关注' : '正在关注' }) wx.cloud.callFunction({ name: this.data.like ? 'deleteFollow' : 'createFollow', data: { pub_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 }) }) } } })