list.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. const app = getApp()
  2. Page({
  3. data: {
  4. frameStyle: { useTop: true, name: '学员信息', leftArrow: true, useBar: false },
  5. list: [],
  6. total: 0,
  7. page: 0,
  8. skip: 0,
  9. limit: 5,
  10. },
  11. // 返回
  12. back: function () {
  13. wx.navigateBack({ delta: 1 })
  14. },
  15. // 审核
  16. toEdit: function (e) {
  17. const that = this;
  18. let { item } = e.currentTarget.dataset;
  19. that.setData({ skip: 0, page: 0, list: [] })
  20. wx.navigateTo({ url: `/pages/schAdmin/courseexam/info?id=${item._id}` })
  21. },
  22. // 分页
  23. toPage: function () {
  24. const that = this;
  25. let list = that.data.list;
  26. let limit = that.data.limit;
  27. if (that.data.total > list.length) {
  28. wx.showLoading({ title: '加载中', mask: true })
  29. let page = that.data.page + 1;
  30. that.setData({ page: page })
  31. let skip = page * limit;
  32. that.setData({ skip: skip })
  33. that.watchLogin();
  34. wx.hideLoading()
  35. } else { wx.showToast({ title: '没有更多数据了', icon: 'none', duration: 2000 }) }
  36. },
  37. // 返回
  38. back(e) {
  39. wx.navigateBack({ delta: 1 })
  40. },
  41. /**
  42. * 生命周期函数--监听页面加载
  43. */
  44. onLoad: function (options) { },
  45. // 监听用户是否登录
  46. watchLogin: async function () {
  47. const that = this;
  48. wx.getStorage({
  49. key: 'user',
  50. success: async res => {
  51. let info = { skip: that.data.skip, limit: that.data.limit, school_id: res.data.info.id };
  52. const arr = await app.$get(`/tempLessonApply`, { ...info });
  53. if (arr.errcode == '0') {
  54. that.setData({ list: [...that.data.list, ...arr.data] });
  55. that.setData({ total: arr.total });
  56. }
  57. else { wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 }) }
  58. },
  59. fail: async res => {
  60. wx.redirectTo({ url: '/pages/index/index' })
  61. }
  62. })
  63. },
  64. /**
  65. * 生命周期函数--监听页面初次渲染完成
  66. */
  67. onReady: function () { },
  68. /**
  69. * 生命周期函数--监听页面显示
  70. */
  71. onShow: function () {
  72. const that = this;
  73. // 监听用户是否登录
  74. that.watchLogin();
  75. },
  76. /**
  77. * 页面上拉触底事件的处理函数
  78. */
  79. /**
  80. * 生命周期函数--监听页面隐藏
  81. */
  82. onHide: function () {
  83. },
  84. /**
  85. * 生命周期函数--监听页面卸载
  86. */
  87. onUnload: function () {
  88. },
  89. /**
  90. * 页面相关事件处理函数--监听用户下拉动作
  91. */
  92. onPullDownRefresh: function () {
  93. },
  94. /**
  95. * 用户点击右上角分享
  96. */
  97. onShareAppMessage: function () {
  98. }
  99. })