// miniprogram/pages/publisherQuestion/publisherQuestion.js Page({ /** * 页面的初始数据 */ data: { questions: [], }, removeQuestion: function (e) { wx.showModal({ content: "确认删除提问?", confirmColor: "#009195" }).then(res => { if (res.confirm) { wx.showLoading({ title: '正在删除' }) wx.cloud.callFunction({ name: 'deleteQuestion', data: { que_id: this.data.questions[e.currentTarget.dataset.index]._id } }).then(res => { wx.hideLoading() if (res.result.status !== 'OK') { wx.showToast({ title: res.result.errMsg, icon: 'none' }) return } wx.showToast({ title: "删除成功", icon: 'none' }) this.data.questions.splice(e.currentTarget.dataset.index, 1) this.setData({ questions: this.data.questions }) }) } }) }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { wx.showNavigationBarLoading() wx.cloud.callFunction({ name: 'listQuestions', data: { page_token: 0, page_size: 20 } }).then(res => { wx.hideNavigationBarLoading() if (res.result.status !== 'OK') { wx.showToast({ title: res.result.errMsg, icon: 'none' }) return } this.setData({ questions: res.result.list }) }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })