piano.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. // pages/piano/piano.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. beginDate: null,
  11. endDate: null,
  12. list: [
  13. ],
  14. loading: '上拉加载',
  15. flag: 0,
  16. pageNum: 0,
  17. hasNextPage: true,
  18. },
  19. getPiano: function () {
  20. wx.navigateTo({
  21. url: '/pages/makePiano/makePiano',
  22. })
  23. },
  24. /**
  25. * 生命周期函数--监听页面加载
  26. */
  27. onLoad: function (options) {
  28. },
  29. /**
  30. * 生命周期函数--监听页面初次渲染完成
  31. */
  32. onReady: function () {
  33. },
  34. /**
  35. * 生命周期函数--监听页面显示
  36. */
  37. onShow: function () {
  38. let now = new Date();
  39. // 显示近7天的预约记录
  40. let bd = util.formatTime(now).substring(0, 10).replace(/\//g, '-')
  41. let edd = new Date(now.setDate(now.getDate() + 7));
  42. let ed = util.formatTime(edd).substring(0, 10).replace(/\//g, '-')
  43. this.setData({ beginDate: bd, endDate: ed, list: [] });
  44. this.queryList();
  45. },
  46. /**
  47. * 生命周期函数--监听页面隐藏
  48. */
  49. onHide: function () {
  50. },
  51. /**
  52. * 生命周期函数--监听页面卸载
  53. */
  54. onUnload: function () {
  55. },
  56. /**
  57. * 页面相关事件处理函数--监听用户下拉动作
  58. */
  59. onPullDownRefresh: function () {
  60. },
  61. /**
  62. * 页面上拉触底事件的处理函数
  63. */
  64. onReachBottom: function () {
  65. if (this.data.hasNextPage) {
  66. let pn = this.data.pageNum
  67. this.setData({ loading: '加载中', 'pageNum': ++pn })
  68. this.queryList()
  69. }
  70. },
  71. /**
  72. * 用户点击右上角分享
  73. */
  74. onShareAppMessage: function () {
  75. },
  76. getDates: function (e) {
  77. this.setData({
  78. list: [],
  79. pageNum: 0,
  80. beginDate: e.detail[0],
  81. endDate: e.detail[1],
  82. loading: '加载中'
  83. })
  84. this.queryList()
  85. },
  86. queryList: function () {
  87. const urls = urlDef.urls;
  88. let stu = wx.getStorageSync('student');
  89. if (stu) {
  90. let params = { 'q.beginDate': this.data.beginDate, 'q.endDate': this.data.endDate, 'q.studentId': stu.studentId, 'q.orgId': stu.orgId }
  91. params.pageNum = this.data.pageNum
  92. util.apiPost(urls.query_appointment_list, params).then(rs => {
  93. let list = rs.list
  94. list.map(o => {
  95. o.visitDate = o.visitDate.substring(0, 10)
  96. })
  97. this.setData({
  98. 'hasNextPage': rs.hasNextPage,
  99. 'loading': rs.hasNextPage ? '下拉刷新' : '没有更多数据',
  100. 'list': this.data.list.concat(list)
  101. })
  102. })
  103. }
  104. }
  105. })