1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- var util = require('../../../util/util.js')
- 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}]
- },
- 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
- });
- //处理时间完成
- },
- 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]);
- },
- });
|