| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- 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.likeDisabled) {
- 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
- })
- })
- }
- }
- })
|