classOrder.js 2.5 KB

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