var util = require('../../../util/util.js') import apiUrl1 from '../../../util/apiUrl1' import request from '../../../util/http' var app = getApp(); Page({ data: { showchangetime:false, nowselectTime:util.formatDate(new Date()), datelist:[{title:"周一",date:0,cssName:'',id:1,day:0},{title:"周二",date:0,cssName:'',id:2,day:0},{title:"周三",date:0,cssName:'',id:3,day:0},{title:"周四",date:0,cssName:'',id:4,day:0},{title:"周五",date:0,cssName:'',id:5,day:0},{title:"周六",date:0,cssName:'',id:6,day:0},{title:"周天",date:0,cssName:'',id:7,day:0}], isreminds:true, showcancelbox:false, cancellist:[{value:'1', label:'任务太多', checked:true},{value:'2', label:'我不会', checked:false},{value:'3', label:'任务不详细', checked:false}], servantName: '',//保姆姓名 weekday: '',//日前 servantTypeValue: '',//保姆工种, taskList: [], }, onLoad() { //加载选中的时间 console.log(this.data.nowselectTime); let that=this; that.getWeekStartDate(this.data.nowselectTime); let data = this.data.datelist; for(let i=0;i<7;i++){ if(this.data.weekdateday[i]==this.data.nowDay){ data[i].date=this.data.weekdate[i]; data[i].day=this.data.weekdateday[i]; data[i].cssName='tik-week-item-select' } else{ data[i].date=this.data.weekdate[i]; data[i].day=this.data.weekdateday[i]; } } this.setData({ datelist: data, servantName: app.globalData.relationInfo.servantName, weekday: app.globalData.relationInfo.servantTaskPeriod.workDay, servantTypeValue: app.globalData.relationInfo.servantType }); //处理时间完成 this.selectDayTaskItem() }, showcancel(){ this.setData({ showcancelbox: true }); }, hidecnacelbox(){ this.setData({ showcancelbox: false }); }, dateAdd:function(startDate,days) { startDate = new Date(startDate); startDate = +startDate + days * 1000 * 60 * 60 * 24; startDate = new Date(startDate); //var nextStartDate = startDate.getFullYear() + "-" + (startDate.getMonth() + 1) + "-" + startDate.getDate(); return startDate.getDate(); }, datedayAdd:function(startDate,days) { startDate = new Date(startDate); startDate = +startDate + days * 1000 * 60 * 60 * 24; startDate = new Date(startDate); var nextStartDate = startDate.getFullYear() + "-" + (startDate.getMonth() + 1) + "-" + startDate.getDate(); return nextStartDate; }, //获取本周的开始日期 getWeekStartDate(nowday) { let that = this; this.now = new Date(nowday); this.nowYear = this.now.getFullYear(); //当前年 this.nowMonth = this.now.getMonth(); //当前月 this.nowDay = this.now.getDate(); //当前日 this.setData({ nowDay:this.nowDay });//保存当前日 this.nowDayOfWeek = this.now.getDay(); //今天是本周的第几天 let dateStart = util.formatDate(new Date(this.nowYear, this.nowMonth, this.nowDay - this.nowDayOfWeek + 1)); let weekdateday=[this.dateAdd(dateStart,0),this.dateAdd(dateStart,1),this.dateAdd(dateStart,2),this.dateAdd(dateStart,3),this.dateAdd(dateStart,4),this.dateAdd(dateStart,5),this.dateAdd(dateStart,6)]; let weekdate=[this.datedayAdd(dateStart,0),this.datedayAdd(dateStart,1),this.datedayAdd(dateStart,2),this.datedayAdd(dateStart,3),this.datedayAdd(dateStart,4),this.datedayAdd(dateStart,5),this.datedayAdd(dateStart,6)]; this.setData({ weekdate: weekdate, weekdateday:weekdateday }) }, changeWeekTime(e){ console.log(e.target.id); let changetime=e.target; }, showtime(){ this.setData({ showchangetime: true, }); }, handleSelect(e) { console.log(e[0]); }, // 查询保姆每日任务 selectDayTaskItem() { let params = { "employRelationNo": app.globalData.employRelationNo, "date": this.data.nowselectTime } request.httpServiceGet(apiUrl1.selectDayTaskItemPath, params).then(data => { console.log("今日任务=" + data); // 未设置任务 if (data.length == 0) { this.setData({ isreminds: false, }); } else { // 今天有任务 this.setData({ taskList: data, }); } } ).catch(e => { console.log(e); }) }, });