schedule.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. // pages/schedule/schedule.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. curStu: null,
  11. aheadTime: 0,
  12. eventList: [],
  13. holidayList: [],
  14. dateList: [],
  15. date: null,
  16. week: 0,
  17. weekMap: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']
  18. },
  19. /**
  20. * 生命周期函数--监听页面加载
  21. */
  22. onLoad: function (options) {
  23. const urls = urlDef.urls;
  24. let stu = wx.getStorageSync('student');
  25. if (stu) {
  26. this.setData('curStu', stu);
  27. util.apiPost(urls.get_sys_params, { 'q.orgId': stu.orgId, 'q.id': 'f8158acabeeb44ec9ff651aade6b295f' }).then((rs) => {
  28. if (rs && rs.length > 0) {
  29. // 将分钟转为毫秒
  30. this.setData({ 'aheadTime': parseInt(rs[0].sysVal, 10) * 60 * 1000 })
  31. }
  32. });
  33. util.apiPost(urls.get_schedule_month, { 'q.studentId': stu.studentId }).then((rs) => {
  34. if (rs && rs.length > 0) {
  35. this.setData({ 'eventList': rs })
  36. }
  37. });
  38. util.apiPost(urls.get_holidays, { 'q.companyId': stu.orgId }).then((rs) => {
  39. if (rs && rs.length > 0) {
  40. this.setData({ 'holidayList': rs })
  41. }
  42. });
  43. }
  44. },
  45. /**
  46. * 生命周期函数--监听页面初次渲染完成
  47. */
  48. onReady: function () {
  49. },
  50. /**
  51. * 生命周期函数--监听页面显示
  52. */
  53. onShow: function () {
  54. },
  55. /**
  56. * 生命周期函数--监听页面隐藏
  57. */
  58. onHide: function () {
  59. },
  60. /**
  61. * 生命周期函数--监听页面卸载
  62. */
  63. onUnload: function () {
  64. },
  65. /**
  66. * 页面相关事件处理函数--监听用户下拉动作
  67. */
  68. onPullDownRefresh: function () {
  69. },
  70. /**
  71. * 页面上拉触底事件的处理函数
  72. */
  73. onReachBottom: function () {
  74. },
  75. /**
  76. * 用户点击右上角分享
  77. */
  78. onShareAppMessage: function () {
  79. },
  80. selectDate: function (v) {
  81. let vd = new Date(v);
  82. let week = this.data.weekMap[vd.getDay()];
  83. let list = this.data.eventList.filter(o => {
  84. return o.attenceDate == v;
  85. });
  86. list.map(o => {
  87. o.bt = o.beginTime.substring(11, 16);
  88. o.et = o.endTime.substring(11, 16);
  89. })
  90. this.setData({ 'date': v, 'week': week, 'dateList': list });
  91. },
  92. callSelectDate: function (d) {
  93. let v = d.detail.dateString;
  94. this.selectDate(v);
  95. }
  96. })