evaluation.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. // pages/evaluation/evaluation.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. flag: 0,
  13. list: [
  14. ],
  15. loading: '上拉加载',
  16. flag: 0,
  17. pageNum: 0,
  18. hasNextPage: true,
  19. },
  20. getMore: function (e) {
  21. let id = e.currentTarget.dataset.id;
  22. let item = this.data.list.filter(o => o.id == id)[0]
  23. wx.navigateTo({
  24. url: '/pages/evaluationDetail/evaluationDetail?item=' + JSON.stringify(item)
  25. })
  26. },
  27. /**
  28. * 生命周期函数--监听页面加载
  29. */
  30. onLoad: function (options) {
  31. let now = new Date();
  32. // 显示近7天的预约记录
  33. let ed = util.formatTime(now).substring(0, 10).replace(/\//g, '-')
  34. let bd = ed.substring(0, 5) + '01-01'
  35. this.setData({ beginDate: bd, endDate: ed, list: [] });
  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. getDates: function (e) {
  79. this.setData({
  80. list: [],
  81. pageNum: 0,
  82. beginDate: e.detail[0],
  83. endDate: e.detail[1],
  84. loading: '加载中'
  85. })
  86. this.queryList()
  87. },
  88. queryList: function () {
  89. const urls = urlDef.urls;
  90. let stu = wx.getStorageSync('student')
  91. let params = { 'q.beginDate': this.data.beginDate, 'q.endDate': this.data.endDate, 'q.studentId': stu.studentId, 'q.orgId': stu.orgId }
  92. params.pageNum = this.data.pageNum
  93. util.apiPost(urls.get_student_comment, params).then(rs => {
  94. let list = rs.list
  95. list.map(o => {
  96. if (o.attendTime) {
  97. o.attendTime = o.attendTime.substring(0, 10)
  98. }
  99. if (o.beginTime) {
  100. o.beginTime = o.beginTime.substring(11, 17)
  101. }
  102. if (o.endTime) {
  103. o.endTime = o.endTime.substring(11, 17)
  104. }
  105. })
  106. this.setData({
  107. 'hasNextPage': rs.hasNextPage,
  108. 'loading': rs.hasNextPage ? '下拉刷新' : '没有更多数据',
  109. 'list': this.data.list.concat(list)
  110. })
  111. })
  112. }
  113. })