theClasses.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. // pages/theClasses/theClasses.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. tipList:[
  19. '1.每月仅有2次调课机会。如撤销,默认是为使用一次调整机会\r\n\r\n',
  20. '2.允许调课至原课程前后一周内。例如:今天11-30日,可调整到11.23到12.07之间的课程\r\n\r\n',
  21. '3.可提前7天进行调课\r\n\r\n',
  22. '4.调入后的课程,不可再调及请假'
  23. ]
  24. },
  25. getTip:function(){
  26. var str = ''
  27. for(var i in this.data.tipList){
  28. str+= this.data.tipList[i]
  29. }
  30. wx.showModal({
  31. title: '调课说明',
  32. content: str,
  33. showCancel: false,//是否显示取消按钮
  34. cancelText:"否",//默认是“取消”
  35. cancelColor:'#999999',//取消文字的颜色
  36. confirmText:"我知道了",//默认是“确定”
  37. confirmColor: 'skyblue',//确定文字的颜色
  38. })
  39. },
  40. /**
  41. * 生命周期函数--监听页面加载
  42. */
  43. onLoad: function (options) {
  44. const urls = urlDef.urls;
  45. let stu = wx.getStorageSync('student');
  46. if (stu) {
  47. this.setData('curStu', stu);
  48. util.apiPost(urls.get_sys_params, { 'q.orgId': stu.orgId, 'q.id': 'f8158acabeeb44ec9ff651aade6b295f' }).then((rs) => {
  49. if (rs && rs.length > 0) {
  50. // 将分钟转为毫秒
  51. this.setData({ 'aheadTime': parseInt(rs[0].sysVal, 10) * 60 * 1000 })
  52. }
  53. });
  54. util.apiPost(urls.get_schedule_month, { 'q.studentId': stu.studentId }).then((rs) => {
  55. if (rs && rs.length > 0) {
  56. this.setData({ 'eventList': rs })
  57. }
  58. });
  59. util.apiPost(urls.get_holidays, { 'q.companyId': stu.orgId }).then((rs) => {
  60. if (rs && rs.length > 0) {
  61. this.setData({ 'holidayList': rs })
  62. }
  63. });
  64. }
  65. },
  66. /**
  67. * 生命周期函数--监听页面初次渲染完成
  68. */
  69. onReady: function () {
  70. },
  71. /**
  72. * 生命周期函数--监听页面显示
  73. */
  74. onShow: function () {
  75. },
  76. /**
  77. * 生命周期函数--监听页面隐藏
  78. */
  79. onHide: function () {
  80. },
  81. /**
  82. * 生命周期函数--监听页面卸载
  83. */
  84. onUnload: function () {
  85. },
  86. /**
  87. * 页面相关事件处理函数--监听用户下拉动作
  88. */
  89. onPullDownRefresh: function () {
  90. },
  91. /**
  92. * 页面上拉触底事件的处理函数
  93. */
  94. onReachBottom: function () {
  95. },
  96. /**
  97. * 用户点击右上角分享
  98. */
  99. onShareAppMessage: function () {
  100. },
  101. selectDate: function (d) {
  102. console.log('selectDate ' + d)
  103. },
  104. callSelectDate: function (d) {
  105. let v = d.detail.dateString;
  106. let vd = new Date(v);
  107. let week = this.data.weekMap[vd.getDay()];
  108. let list = this.data.eventList.filter(o => {
  109. return o.attenceDate == v;
  110. });
  111. list.map(o => {
  112. o.bt = o.beginTime.substring(11, 16);
  113. o.et = o.endTime.substring(11, 16);
  114. })
  115. this.setData({ 'date': v, 'week': week, 'dateList': list });
  116. }
  117. })