| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- Component({
- options: {
- styleIsolation: "apply-shared"
- },
- properties: {
- item: Object
- },
- data: {
- show: true,
- like: 1
- },
- methods: {
- getMessageInfo: function () {
- wx.navigateTo({
- url: '/pages/message/message',
- 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.loading) {
- 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
- })
- })
- }
- }
- })
|