123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- // pages/schedule/schedule.js
- const app = getApp()
- const util = require("../../utils/util")
- const urlDef = require("../../utils/urls")
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- curStu: null,
- aheadTime: 0,
- eventList: [],
- holidayList: [],
- dateList: [],
- date: null,
- week: 0,
- weekMap: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
- bd: null
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- let date = options.endDate;
- if (date) {
- this.setData({ bd: date })
- }
- const urls = urlDef.urls;
- let stu = wx.getStorageSync('student');
- if (stu) {
- this.setData({ 'curStu': stu });
- util.apiPost(urls.get_sys_params, { 'q.orgId': stu.orgId, 'q.id': 'f8158acabeeb44ec9ff651aade6b295f' }).then((rs) => {
- if (rs && rs.length > 0) {
- // 将分钟转为毫秒
- this.setData({ 'aheadTime': parseInt(rs[0].sysVal, 10) * 60 * 1000 })
- }
- });
- util.apiPost(urls.get_schedule_month, { 'q.studentId': stu.studentId }).then((rs) => {
- if (rs && rs.length > 0) {
- this.setData({ 'eventList': rs })
- }
- this.initList()
- });
- util.apiPost(urls.get_holidays, { 'q.companyId': stu.orgId }).then((rs) => {
- if (rs && rs.length > 0) {
- this.setData({ 'holidayList': rs })
- }
- });
- }
- },
- initList:function(){
- let date = this.data.bd
- if (date) {
- let t = this;
- t.selectDate(date)
- }
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
-
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- let date = this.data.bd
- if (date) {
- let t = this;
- t.selectDate(date)
- }
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- },
- selectDate: function (v) {
- let vd = new Date(v);
- let week = this.data.weekMap[vd.getDay()];
- let list = this.data.eventList.filter(o => {
- return o.attenceDate == v;
- });
- list.map(o => {
- o.bt = o.beginTime.substring(11, 16);
- o.et = o.endTime.substring(11, 16);
- })
-
- this.setData({ 'date': v, 'week': week, 'dateList': [{ items: list, date: v, week: week }] });
- },
- callSelectDate: function (d) {
- let v = d.detail.dateString;
- this.selectDate(v);
- }
- })
|