|
@@ -87,41 +87,61 @@ Page({
|
|
|
icon: "none"
|
|
icon: "none"
|
|
|
})
|
|
})
|
|
|
} else {
|
|
} else {
|
|
|
- const db = wx.cloud.database()
|
|
|
|
|
- db.collection("qaData").where({
|
|
|
|
|
- _openid: app.globalData.openId,
|
|
|
|
|
- activityId: this.data.activityInfo._id
|
|
|
|
|
- }).get({
|
|
|
|
|
- success: function (res) {
|
|
|
|
|
- console.log(res)
|
|
|
|
|
- if (res.data.length >= 10) {
|
|
|
|
|
- wx.showToast({
|
|
|
|
|
- title: "为防止刷屏,每人每消息至多提问10条",
|
|
|
|
|
- icon: "none"
|
|
|
|
|
- })
|
|
|
|
|
- } else {
|
|
|
|
|
- db.collection("qaData").add({
|
|
|
|
|
- data: {
|
|
|
|
|
- activityId: this.data.activityInfo._id,
|
|
|
|
|
- publisherId: this.data.activityInfo.publisherId,
|
|
|
|
|
- answer: "",
|
|
|
|
|
- answerTime: "",
|
|
|
|
|
- question: this.data.commentText,
|
|
|
|
|
- questionTime: new Date(),
|
|
|
|
|
- rank: ""
|
|
|
|
|
- },
|
|
|
|
|
- success: function () {
|
|
|
|
|
- this.setData({
|
|
|
|
|
- commentText: ""
|
|
|
|
|
- })
|
|
|
|
|
- wx.showToast({
|
|
|
|
|
- title: "提问成功"
|
|
|
|
|
- })
|
|
|
|
|
- }.bind(this)
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
- }.bind(this)
|
|
|
|
|
|
|
+ wx.showLoading({
|
|
|
|
|
+ title: '发送中',
|
|
|
})
|
|
})
|
|
|
|
|
+ wx.cloud.callFunction({
|
|
|
|
|
+ name: 'createQuestion',
|
|
|
|
|
+ data: {
|
|
|
|
|
+ msg_id: this.data.activityInfo._id,
|
|
|
|
|
+ question: this.data.commentText
|
|
|
|
|
+ }
|
|
|
|
|
+ }).then(res => {
|
|
|
|
|
+ wx.hideLoading()
|
|
|
|
|
+ wx.showToast({
|
|
|
|
|
+ title: '发送成功,请等待回复',
|
|
|
|
|
+ icon: 'none'
|
|
|
|
|
+ })
|
|
|
|
|
+ this.setData({
|
|
|
|
|
+ commentText: ''
|
|
|
|
|
+ })
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ // const db = wx.cloud.database()
|
|
|
|
|
+ // db.collection("qaData").where({
|
|
|
|
|
+ // _openid: app.globalData.openId,
|
|
|
|
|
+ // activityId: this.data.activityInfo._id
|
|
|
|
|
+ // }).get({
|
|
|
|
|
+ // success: function (res) {
|
|
|
|
|
+ // console.log(res)
|
|
|
|
|
+ // if (res.data.length >= 10) {
|
|
|
|
|
+ // wx.showToast({
|
|
|
|
|
+ // title: "为防止刷屏,每人每消息至多提问10条",
|
|
|
|
|
+ // icon: "none"
|
|
|
|
|
+ // })
|
|
|
|
|
+ // } else {
|
|
|
|
|
+ // db.collection("qaData").add({
|
|
|
|
|
+ // data: {
|
|
|
|
|
+ // activityId: this.data.activityInfo._id,
|
|
|
|
|
+ // publisherId: this.data.activityInfo.publisherId,
|
|
|
|
|
+ // answer: "",
|
|
|
|
|
+ // answerTime: "",
|
|
|
|
|
+ // question: this.data.commentText,
|
|
|
|
|
+ // questionTime: new Date(),
|
|
|
|
|
+ // rank: ""
|
|
|
|
|
+ // },
|
|
|
|
|
+ // success: function () {
|
|
|
|
|
+ // this.setData({
|
|
|
|
|
+ // commentText: ""
|
|
|
|
|
+ // })
|
|
|
|
|
+ // wx.showToast({
|
|
|
|
|
+ // title: "提问成功"
|
|
|
|
|
+ // })
|
|
|
|
|
+ // }.bind(this)
|
|
|
|
|
+ // })
|
|
|
|
|
+ // }
|
|
|
|
|
+ // }.bind(this)
|
|
|
|
|
+ // })
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
|
|
|