theClasses.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. console.log(str)
  30. }
  31. wx.showModal({
  32. title: '调课说明',
  33. content: str,
  34. showCancel: false,//是否显示取消按钮
  35. cancelText:"否",//默认是“取消”
  36. cancelColor:'#999999',//取消文字的颜色
  37. confirmText:"我知道了",//默认是“确定”
  38. confirmColor: 'skyblue',//确定文字的颜色
  39. })
  40. },
  41. /**
  42. * 生命周期函数--监听页面加载
  43. */
  44. onLoad: function (options) {
  45. const urls = urlDef.urls;
  46. let stu = wx.getStorageSync('student');
  47. if (stu) {
  48. this.setData('curStu', stu);
  49. util.apiPost(urls.get_sys_params, { 'q.orgId': stu.orgId, 'q.id': 'f8158acabeeb44ec9ff651aade6b295f' }).then((rs) => {
  50. if (rs && rs.length > 0) {
  51. // 将分钟转为毫秒
  52. this.setData({ 'aheadTime': parseInt(rs[0].sysVal, 10) * 60 * 1000 })
  53. }
  54. });
  55. util.apiPost(urls.get_schedule_month, { 'q.studentId': stu.studentId }).then((rs) => {
  56. if (rs && rs.length > 0) {
  57. this.setData({ 'eventList': rs })
  58. }
  59. });
  60. util.apiPost(urls.get_holidays, { 'q.companyId': stu.orgId }).then((rs) => {
  61. if (rs && rs.length > 0) {
  62. this.setData({ 'holidayList': rs })
  63. }
  64. });
  65. }
  66. },
  67. /**
  68. * 生命周期函数--监听页面初次渲染完成
  69. */
  70. onReady: function () {
  71. },
  72. /**
  73. * 生命周期函数--监听页面显示
  74. */
  75. onShow: function () {
  76. },
  77. /**
  78. * 生命周期函数--监听页面隐藏
  79. */
  80. onHide: function () {
  81. },
  82. /**
  83. * 生命周期函数--监听页面卸载
  84. */
  85. onUnload: function () {
  86. },
  87. /**
  88. * 页面相关事件处理函数--监听用户下拉动作
  89. */
  90. onPullDownRefresh: function () {
  91. },
  92. /**
  93. * 页面上拉触底事件的处理函数
  94. */
  95. onReachBottom: function () {
  96. },
  97. /**
  98. * 用户点击右上角分享
  99. */
  100. onShareAppMessage: function () {
  101. },
  102. selectDate: function (d) {
  103. console.log('selectDate ' + d)
  104. },
  105. callSelectDate: function (d) {
  106. let v = d.detail.dateString;
  107. let vd = new Date(v);
  108. let week = this.data.weekMap[vd.getDay()];
  109. let list = this.data.eventList.filter(o => {
  110. return o.attenceDate == v;
  111. });
  112. list.map(o => {
  113. o.bt = o.beginTime.substring(11, 16);
  114. o.et = o.endTime.substring(11, 16);
  115. })
  116. this.setData({ 'date': v, 'week': week, 'dateList': list });
  117. }
  118. })