leaveRecord.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. // pages/leaveRecord/leaveRecord.js
  2. const app = getApp()
  3. const util = require("../../utils/util")
  4. const urlDef = require("../../utils/urls")
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. loading: '上拉加载',
  11. list: [],
  12. pageNum: 0,
  13. hasNextPage: true,
  14. },
  15. /**
  16. * 生命周期函数--监听页面加载
  17. */
  18. onLoad: function (options) {
  19. },
  20. /**
  21. * 生命周期函数--监听页面初次渲染完成
  22. */
  23. onReady: function () {
  24. },
  25. /**
  26. * 生命周期函数--监听页面显示
  27. */
  28. onShow: function () {
  29. this.setData({ list: [] })
  30. this.queryList()
  31. },
  32. /**
  33. * 生命周期函数--监听页面隐藏
  34. */
  35. onHide: function () {
  36. },
  37. /**
  38. * 生命周期函数--监听页面卸载
  39. */
  40. onUnload: function () {
  41. },
  42. /**
  43. * 页面相关事件处理函数--监听用户下拉动作
  44. */
  45. onPullDownRefresh: function () {
  46. },
  47. /**
  48. * 页面上拉触底事件的处理函数
  49. */
  50. onReachBottom: function () {
  51. if (this.data.hasNextPage) {
  52. let pn = this.data.pageNum
  53. this.setData({ loading: '加载中', 'pageNum': ++pn })
  54. this.queryList()
  55. }
  56. },
  57. /**
  58. * 用户点击右上角分享
  59. */
  60. onShareAppMessage: function () {
  61. },
  62. queryList: function () {
  63. const urls = urlDef.urls;
  64. let stu = wx.getStorageSync('student');
  65. if (stu) {
  66. this.setData({ 'curStu': stu });
  67. let params = { 'q.studentId': stu.studentId, 'q.orgId': stu.orgId }
  68. params.pageNum = this.data.pageNum
  69. util.apiPost(urls.makeup_list, params).then(rs => {
  70. let list = rs.list;
  71. list.map(o => {
  72. if (o.beginTime) {
  73. o.beginTime = o.beginTime.replace('T', ' ').substring(0, 16)
  74. }
  75. if (o.createdDate) {
  76. o.createdDate = o.createdDate.replace('T', ' ').substring(0, 16)
  77. }
  78. })
  79. this.setData({
  80. 'hasNextPage': rs.hasNextPage,
  81. 'loading': rs.hasNextPage ? '下拉刷新' : '没有更多数据',
  82. 'list': this.data.list.concat(list)
  83. })
  84. })
  85. }
  86. },
  87. })