classTotalList.js 2.1 KB

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