|
|
@@ -56,22 +56,41 @@ Page({
|
|
|
removeQuestion: function (e) {
|
|
|
wx.showModal({
|
|
|
content: "确认删除提问?",
|
|
|
- confirmColor: "#009195",
|
|
|
- success: function (res) {
|
|
|
- if (res.confirm) {
|
|
|
- const db = wx.cloud.database()
|
|
|
- db.collection("qaData").doc(e.target.dataset.id).remove({
|
|
|
- success: function () {
|
|
|
- this.onLoad({
|
|
|
- id: this.data.publisherId
|
|
|
- })
|
|
|
- wx.showToast({
|
|
|
- title: "删除成功",
|
|
|
- })
|
|
|
- }.bind(this)
|
|
|
+ confirmColor: "#009195"
|
|
|
+ }).then(res => {
|
|
|
+ if (res.confirm) {
|
|
|
+ wx.showLoading({
|
|
|
+ title: '删除中'
|
|
|
+ })
|
|
|
+ wx.cloud.callFunction({
|
|
|
+ name: 'deleteQuestion',
|
|
|
+ data: {
|
|
|
+ que_id: e.currentTarget.dataset.id
|
|
|
+ }
|
|
|
+ }).then(res => {
|
|
|
+ wx.hideLoading()
|
|
|
+ if (res.result.status !== 'OK') {
|
|
|
+ wx.showToast({
|
|
|
+ title: res.result.errMsg,
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for (let i = 0; i < this.data.questions.length; i++) {
|
|
|
+ if (this.data.questions[i]._id === e.currentTarget.dataset.id) {
|
|
|
+ this.data.questions.splice(i, 1)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.setData({
|
|
|
+ questions: this.data.questions
|
|
|
+ })
|
|
|
+ wx.showToast({
|
|
|
+ title: "删除成功",
|
|
|
+ icon: 'none'
|
|
|
})
|
|
|
- }
|
|
|
- }.bind(this)
|
|
|
+ })
|
|
|
+ }
|
|
|
})
|
|
|
},
|
|
|
|
|
|
@@ -103,33 +122,6 @@ Page({
|
|
|
questions: res.result.list
|
|
|
})
|
|
|
})
|
|
|
-
|
|
|
- // this.setData({
|
|
|
- // publisherId: options.id,
|
|
|
- // questions: [{
|
|
|
- // title: "我是标题",
|
|
|
- // question: "我是问题?",
|
|
|
- // answer: "我是回答"
|
|
|
- // }]
|
|
|
- // })
|
|
|
- // const db = wx.cloud.database()
|
|
|
- // db.collection("qaData").where({
|
|
|
- // publisherId: this.data.publisherId,
|
|
|
- // }).orderBy("questionTime", "desc").get({
|
|
|
- // success: async function (res) {
|
|
|
- // let arr = []
|
|
|
- // for (let i = 0; i < res.data.length; i++) {
|
|
|
- // arr.push(db.collection("mainData").doc(res.data[i].activityId).get())
|
|
|
- // }
|
|
|
- // arr = await Promise.all(arr)
|
|
|
- // for (let i = 0; i < res.data.length; i++) {
|
|
|
- // res.data[i].title = arr[i].data.title
|
|
|
- // }
|
|
|
- // this.setData({
|
|
|
- // questions: res.data
|
|
|
- // })
|
|
|
- // }.bind(this)
|
|
|
- // })
|
|
|
},
|
|
|
|
|
|
/**
|