classOrder.js 2.2 KB

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