index.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. // pages/problemPage/index.js
  2. const app = getApp();
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. Page: 1,
  8. Size: 10,
  9. data: {
  10. question: [],
  11. showEnd: false
  12. },
  13. tonext(e) {
  14. if (!app.globalData.userInfo || !app.globalData.userInfo.phone) wx.navigateTo({
  15. url: '/pages/index/index',
  16. })
  17. else {
  18. app.globalData.selectQuestion = this.data.question[e.currentTarget.dataset.i] || { list: [] };
  19. wx.navigateTo({
  20. url: '/pages/answerInfo/index',
  21. })
  22. }
  23. },
  24. /**
  25. * 生命周期函数--监听页面加载
  26. */
  27. onLoad: function (options) {
  28. const that = this;
  29. wx.cloud.callFunction({
  30. name: "quickstartFunctions",
  31. data: {
  32. type: "questionBankList",
  33. data: {
  34. Page: that.Page,
  35. Size: that.Size
  36. }
  37. }
  38. }).then(res => {
  39. wx.hideLoading();
  40. if (res.result.code !== 0) return;
  41. that.setData({
  42. question: res.result.data.list || [],
  43. showEnd: res.result.data.total <= that.Page * that.Size
  44. })
  45. }).catch(err => {
  46. wx.hideLoading({
  47. success: (res) => {
  48. wx.showToast({
  49. title: '服务走丢了~',
  50. icon: "none"
  51. })
  52. },
  53. })
  54. })
  55. },
  56. /**
  57. * 生命周期函数--监听页面初次渲染完成
  58. */
  59. onReady: function () {
  60. },
  61. /**
  62. * 生命周期函数--监听页面显示
  63. */
  64. onShow: function () {
  65. },
  66. /**
  67. * 生命周期函数--监听页面隐藏
  68. */
  69. onHide: function () {
  70. },
  71. /**
  72. * 生命周期函数--监听页面卸载
  73. */
  74. onUnload: function () {
  75. },
  76. /**
  77. * 页面相关事件处理函数--监听用户下拉动作
  78. */
  79. onPullDownRefresh: function () {
  80. },
  81. /**
  82. * 页面上拉触底事件的处理函数
  83. */
  84. onReachBottom: function () {
  85. // 添加数据
  86. },
  87. /**
  88. * 用户点击右上角分享
  89. */
  90. onShareAppMessage: function () {
  91. }
  92. })