lessons.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. // pages/lessons/lessons.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. switchTitle: ['待补课', '待上课'],
  11. beginDate: null,
  12. endDate: null,
  13. status: '0',
  14. list: [
  15. ],
  16. loading: '上拉加载',
  17. flag: 0,
  18. pageNum: 0,
  19. hasNextPage: true,
  20. },
  21. changeIndex: function (e) {
  22. if (e.detail == 0) {
  23. this.setData({ status: '0' })
  24. } else {
  25. this.setData({ status: '1' })
  26. }
  27. this.setData({
  28. list: [],
  29. loading: '上拉加载',
  30. pageNum: 0
  31. })
  32. this.queryList()
  33. },
  34. getTip: function () {
  35. wx.showModal({
  36. title: '补课说明',
  37. content: '1.针对请假的课程进行补课',
  38. showCancel: false,//是否显示取消按钮
  39. cancelText: "否",//默认是“取消”
  40. cancelColor: '#999999',//取消文字的颜色
  41. confirmText: "我知道了",//默认是“确定”
  42. // confirmColor: 'skyblue',//确定文字的颜色
  43. })
  44. },
  45. /**
  46. * 生命周期函数--监听页面加载
  47. */
  48. onLoad: function (options) {
  49. let now = new Date();
  50. let ed = util.formatTime(now).substring(0, 10).replace(/\//g, '-')
  51. let bd = ed.substring(0, 5) + '01-01'
  52. this.setData({ beginDate: bd, endDate: ed });
  53. },
  54. /**
  55. * 生命周期函数--监听页面初次渲染完成
  56. */
  57. onReady: function () {
  58. },
  59. /**
  60. * 生命周期函数--监听页面显示
  61. */
  62. onShow: function () {
  63. this.setData({ list: [], pageNum: 0 })
  64. this.queryList()
  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. if (this.data.hasNextPage) {
  86. let pn = this.data.pageNum
  87. this.setData({ loading: '加载中', 'pageNum': ++pn })
  88. this.queryList()
  89. }
  90. },
  91. /**
  92. * 用户点击右上角分享
  93. */
  94. onShareAppMessage: function () {
  95. },
  96. queryList: function () {
  97. const urls = urlDef.urls;
  98. let stu = wx.getStorageSync('student')
  99. let params = { 'q.studentId': stu.studentId, 'q.orgId': stu.orgId, 'q.status': this.data.status }
  100. params.pageNum = this.data.pageNum
  101. util.apiPost(urls.makeup_list, params).then(rs => {
  102. let list = rs.list
  103. list.map(o => {
  104. if (o.beginTime) {
  105. o.beginTime = o.beginTime.replace('T', ' ').substring(0, 16)
  106. }
  107. if (o.createdDate) {
  108. o.createdDate = o.createdDate.replace('T', ' ').substring(0, 16)
  109. }
  110. })
  111. this.setData({
  112. 'hasNextPage': rs.hasNextPage,
  113. 'loading': rs.hasNextPage ? '下拉刷新' : '没有更多数据',
  114. 'list': this.data.list.concat(list)
  115. })
  116. })
  117. }
  118. })