classTotalList.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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({
  56. loading: '加载中',
  57. 'pageNum': ++pn
  58. })
  59. this.queryList()
  60. }
  61. },
  62. /**
  63. * 用户点击右上角分享
  64. */
  65. onShareAppMessage: function () {
  66. },
  67. queryList: function () {
  68. const urls = urlDef.urls;
  69. let stu = wx.getStorageSync('student')
  70. let params = {
  71. 'q.studentId': stu.studentId,
  72. 'q.orgId': stu.orgId
  73. }
  74. params.pageNum = this.data.pageNum
  75. util.apiPost(urls.get_course_report, params).then(rs => {
  76. let list = rs.list
  77. list.map(it => {
  78. let item = Object.assign({}, it);
  79. if (item.endDate) {
  80. item.endDate = item.endDate.substring(0, 10)
  81. }
  82. if (it.billingMethod === 'T' || it.billingMethod === 'P') {
  83. this.data.courseItems.push(item);
  84. } else if (it.billingMethod === 'M') {
  85. this.data.moneyItems.push(item);
  86. }
  87. })
  88. if (this.data.courseItems.length <= 0) {
  89. wx.showModal({
  90. title: '提示',
  91. content: '暂无数据',
  92. showCancel: false, //是否显示取消按钮
  93. cancelText: "否", //默认是“取消”
  94. cancelColor: '#999999', //取消文字的颜色
  95. confirmText: "确定", //默认是“确定”
  96. confirmColor: 'skyblue', //确定文字的颜色
  97. success(res){
  98. if(res.confirm){
  99. wx.navigateBack({
  100. delta: -1,
  101. })
  102. }
  103. }
  104. })
  105. }
  106. this.setData({
  107. 'hasNextPage': rs.hasNextPage,
  108. 'loading': rs.hasNextPage ? '下拉刷新' : '没有更多数据',
  109. 'courseItems': this.data.courseItems,
  110. 'moneyItems': this.data.moneyItems
  111. })
  112. })
  113. },
  114. })