|
@@ -10,6 +10,7 @@ Page({
|
|
|
messageId: '',
|
|
messageId: '',
|
|
|
activityInfo: {},
|
|
activityInfo: {},
|
|
|
like: false,
|
|
like: false,
|
|
|
|
|
+ likeDisabled: true,
|
|
|
showEdit: false,
|
|
showEdit: false,
|
|
|
pageToken: 0,
|
|
pageToken: 0,
|
|
|
activityComment: [],
|
|
activityComment: [],
|
|
@@ -18,7 +19,11 @@ Page({
|
|
|
|
|
|
|
|
getPublisherInfo: function () {
|
|
getPublisherInfo: function () {
|
|
|
wx.navigateTo({
|
|
wx.navigateTo({
|
|
|
- url: '/pages/publisher/publisher?id=' + this.data.activityInfo.pub_id
|
|
|
|
|
|
|
+ url: '/pages/publisher/publisher',
|
|
|
|
|
+ }).then(res => {
|
|
|
|
|
+ res.eventChannel.emit('loadCommonData', {
|
|
|
|
|
+ data: this.data.item.publisher
|
|
|
|
|
+ })
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
|
|
|
|
@@ -52,10 +57,13 @@ Page({
|
|
|
})
|
|
})
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
+ wx.navigateBack()
|
|
|
|
|
+ const eventChannel = this.getOpenerEventChannel()
|
|
|
|
|
+ eventChannel.emit('deleteMessage')
|
|
|
wx.showToast({
|
|
wx.showToast({
|
|
|
title: "删除成功",
|
|
title: "删除成功",
|
|
|
|
|
+ icon: 'none'
|
|
|
})
|
|
})
|
|
|
- wx.navigateBack()
|
|
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
}.bind(this)
|
|
}.bind(this)
|
|
@@ -63,6 +71,9 @@ Page({
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
toggleLike: function () {
|
|
toggleLike: function () {
|
|
|
|
|
+ if (this.data.likeDisabled) {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
wx.showLoading({
|
|
wx.showLoading({
|
|
|
title: this.data.like ? '取消收藏' : '收藏中'
|
|
title: this.data.like ? '取消收藏' : '收藏中'
|
|
|
})
|
|
})
|
|
@@ -90,30 +101,55 @@ Page({
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
- loadQuestionData: function () {
|
|
|
|
|
- wx.showNavigationBarLoading()
|
|
|
|
|
- wx.cloud.callFunction({
|
|
|
|
|
|
|
+ processCommonData: function (data) {
|
|
|
|
|
+ let edit = false
|
|
|
|
|
+ for (let i = 0; i < app.globalData.pubInfo.length; i++) {
|
|
|
|
|
+ if (data.pub_id === app.globalData.pubInfo[i].pub_id) {
|
|
|
|
|
+ edit = true
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ this.setData({
|
|
|
|
|
+ activityInfo: data,
|
|
|
|
|
+ showEdit: edit
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ loadExtraData: function () {
|
|
|
|
|
+ wx.showLoading({
|
|
|
|
|
+ title: '加载中'
|
|
|
|
|
+ })
|
|
|
|
|
+ const arr = []
|
|
|
|
|
+ arr.push(wx.cloud.callFunction({
|
|
|
name: 'listQuestions',
|
|
name: 'listQuestions',
|
|
|
data: {
|
|
data: {
|
|
|
msg_id: this.data.messageId,
|
|
msg_id: this.data.messageId,
|
|
|
page_token: this.data.pageToken,
|
|
page_token: this.data.pageToken,
|
|
|
page_size: 25
|
|
page_size: 25
|
|
|
}
|
|
}
|
|
|
- }).then(res => {
|
|
|
|
|
- wx.hideNavigationBarLoading()
|
|
|
|
|
- if (res.result.status !== 'OK') {
|
|
|
|
|
|
|
+ }))
|
|
|
|
|
+ arr.push(wx.cloud.callFunction({
|
|
|
|
|
+ name: 'getFavorite',
|
|
|
|
|
+ data: {
|
|
|
|
|
+ msg_id: this.data.messageId
|
|
|
|
|
+ }
|
|
|
|
|
+ }))
|
|
|
|
|
+ Promise.all(arr).then(res => {
|
|
|
|
|
+ wx.hideLoading()
|
|
|
|
|
+ if (res[0].result.status !== 'OK' || res[1].result.status !== 'OK') {
|
|
|
wx.showToast({
|
|
wx.showToast({
|
|
|
- title: res.result.errMsg,
|
|
|
|
|
|
|
+ title: res[0].result.errMsg || res[1].result.errMsg,
|
|
|
icon: 'none'
|
|
icon: 'none'
|
|
|
})
|
|
})
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
- for (let i = 0; i < res.result.list.length; i++) {
|
|
|
|
|
- res.result.list[i].a_time = util.handleDate(res.result.list[i].a_time)
|
|
|
|
|
|
|
+ for (let i = 0; i < res[0].result.list.length; i++) {
|
|
|
|
|
+ res[0].result.list[i].a_time = util.handleDate(res[0].result.list[i].a_time)
|
|
|
}
|
|
}
|
|
|
this.setData({
|
|
this.setData({
|
|
|
- activityComment: this.data.activityComment.concat(res.result.list),
|
|
|
|
|
- pageToken: res.result.next_page_token
|
|
|
|
|
|
|
+ activityComment: this.data.activityComment.concat(res[0].result.list),
|
|
|
|
|
+ pageToken: res[0].result.next_page_token,
|
|
|
|
|
+ like: res[1].result.total === 1,
|
|
|
|
|
+ likeDisabled: false
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
@@ -158,41 +194,41 @@ Page({
|
|
|
* 生命周期函数--监听页面加载
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
*/
|
|
|
onLoad: function (options) {
|
|
onLoad: function (options) {
|
|
|
- this.setData({
|
|
|
|
|
- messageId: options.id
|
|
|
|
|
- })
|
|
|
|
|
-
|
|
|
|
|
- wx.showLoading({
|
|
|
|
|
- title: '加载中'
|
|
|
|
|
- })
|
|
|
|
|
- wx.cloud.callFunction({
|
|
|
|
|
- name: 'getMessage',
|
|
|
|
|
- data: {
|
|
|
|
|
- msg_id: this.data.messageId
|
|
|
|
|
- }
|
|
|
|
|
- }).then(res => {
|
|
|
|
|
- wx.hideLoading()
|
|
|
|
|
- if (res.result.status !== 'OK') {
|
|
|
|
|
- wx.showToast({
|
|
|
|
|
- title: res.result.errMsg,
|
|
|
|
|
- icon: 'none'
|
|
|
|
|
- })
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
- res.result.data = util.dbToMsg(res.result.data)
|
|
|
|
|
- let edit = false
|
|
|
|
|
- for (let i = 0; i < app.globalData.pubInfo.length; i++) {
|
|
|
|
|
- if (res.result.data.pub_id === app.globalData.pubInfo[i].pub_id) {
|
|
|
|
|
- edit = true
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if (options.id) {
|
|
|
this.setData({
|
|
this.setData({
|
|
|
- activityInfo: res.result.data,
|
|
|
|
|
- like: res.result.data.favorite,
|
|
|
|
|
- showEdit: edit
|
|
|
|
|
|
|
+ messageId: options.id
|
|
|
})
|
|
})
|
|
|
- this.loadQuestionData()
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ wx.showLoading({
|
|
|
|
|
+ title: '加载中'
|
|
|
|
|
+ })
|
|
|
|
|
+ wx.cloud.callFunction({
|
|
|
|
|
+ name: 'getMessage',
|
|
|
|
|
+ data: {
|
|
|
|
|
+ msg_id: this.data.messageId
|
|
|
|
|
+ }
|
|
|
|
|
+ }).then(res => {
|
|
|
|
|
+ wx.hideLoading()
|
|
|
|
|
+ if (res.result.status !== 'OK') {
|
|
|
|
|
+ wx.showToast({
|
|
|
|
|
+ title: res.result.errMsg,
|
|
|
|
|
+ icon: 'none'
|
|
|
|
|
+ })
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ res.result.data = util.dbToMsg(res.result.data)
|
|
|
|
|
+ this.processCommonData(res.result.data)
|
|
|
|
|
+ this.loadExtraData()
|
|
|
|
|
+ })
|
|
|
|
|
+ } else {
|
|
|
|
|
+ const eventChannel = this.getOpenerEventChannel()
|
|
|
|
|
+ eventChannel.on('loadCommonData', res => {
|
|
|
|
|
+ this.setData({
|
|
|
|
|
+ messageId: res.data._id,
|
|
|
|
|
+ })
|
|
|
|
|
+ this.processCommonData(res.data)
|
|
|
|
|
+ this.loadExtraData()
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
/**
|