myQuestion.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. // miniprogram/pages/publisherQuestion/publisherQuestion.js
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. questions: [],
  8. },
  9. removeQuestion: function (e) {
  10. wx.showModal({
  11. content: "确认删除?",
  12. confirmColor: "#009195",
  13. success: function (res) {
  14. if (res.confirm) {
  15. // const db = wx.cloud.database()
  16. // db.collection("qaData").doc(e.target.dataset.id).remove({
  17. // success: function () {
  18. // this.onLoad({
  19. // id: this.data.publisherId
  20. // })
  21. // wx.showToast({
  22. // title: "删除成功",
  23. // })
  24. // }.bind(this)
  25. // })
  26. }
  27. }.bind(this)
  28. })
  29. },
  30. /**
  31. * 生命周期函数--监听页面加载
  32. */
  33. onLoad: function (options) {
  34. wx.showNavigationBarLoading()
  35. wx.cloud.callFunction({
  36. name: 'listQuestions',
  37. data: {
  38. page_token: 0,
  39. page_size: 20
  40. }
  41. }).then(res => {
  42. wx.hideNavigationBarLoading()
  43. if (res.result.status !== 'OK') {
  44. wx.showToast({
  45. title: res.result.errMsg,
  46. icon: 'none'
  47. })
  48. return
  49. }
  50. this.setData({
  51. questions: res.result.list
  52. })
  53. })
  54. },
  55. /**
  56. * 生命周期函数--监听页面初次渲染完成
  57. */
  58. onReady: function () {
  59. },
  60. /**
  61. * 生命周期函数--监听页面显示
  62. */
  63. onShow: function () {
  64. },
  65. /**
  66. * 生命周期函数--监听页面隐藏
  67. */
  68. onHide: function () {
  69. },
  70. /**
  71. * 生命周期函数--监听页面卸载
  72. */
  73. onUnload: function () {
  74. },
  75. /**
  76. * 页面相关事件处理函数--监听用户下拉动作
  77. */
  78. onPullDownRefresh: function () {
  79. },
  80. /**
  81. * 页面上拉触底事件的处理函数
  82. */
  83. onReachBottom: function () {
  84. },
  85. /**
  86. * 用户点击右上角分享
  87. */
  88. onShareAppMessage: function () {
  89. }
  90. })