taskreminder.js 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. var util = require('../../../util/util.js')
  2. Page({
  3. data: {
  4. showchangetime:false,
  5. nowselectTime:util.formatDate(new Date()),
  6. 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}],
  7. isreminds:true,
  8. showcancelbox:false,
  9. cancellist:[{value:'1', label:'任务太多', checked:true},{value:'2', label:'我不会', checked:false},{value:'3', label:'任务不详细', checked:false}]
  10. },
  11. onLoad() {
  12. //加载选中的时间
  13. console.log(this.data.nowselectTime);
  14. let that=this;
  15. that.getWeekStartDate(this.data.nowselectTime);
  16. let data = this.data.datelist;
  17. for(let i=0;i<7;i++){
  18. if(this.data.weekdateday[i]==this.data.nowDay){
  19. data[i].date=this.data.weekdate[i];
  20. data[i].day=this.data.weekdateday[i];
  21. data[i].cssName='tik-week-item-select'
  22. }
  23. else{
  24. data[i].date=this.data.weekdate[i];
  25. data[i].day=this.data.weekdateday[i];
  26. }
  27. }
  28. this.setData({
  29. datelist: data
  30. });
  31. //处理时间完成
  32. },
  33. showcancel(){
  34. this.setData({
  35. showcancelbox: true
  36. });
  37. },
  38. hidecnacelbox(){
  39. this.setData({
  40. showcancelbox: false
  41. });
  42. },
  43. dateAdd:function(startDate,days) {
  44. startDate = new Date(startDate);
  45. startDate = +startDate + days * 1000 * 60 * 60 * 24;
  46. startDate = new Date(startDate);
  47. //var nextStartDate = startDate.getFullYear() + "-" + (startDate.getMonth() + 1) + "-" + startDate.getDate();
  48. return startDate.getDate();
  49. },
  50. datedayAdd:function(startDate,days) {
  51. startDate = new Date(startDate);
  52. startDate = +startDate + days * 1000 * 60 * 60 * 24;
  53. startDate = new Date(startDate);
  54. var nextStartDate = startDate.getFullYear() + "-" + (startDate.getMonth() + 1) + "-" + startDate.getDate();
  55. return nextStartDate;
  56. },
  57. //获取本周的开始日期
  58. getWeekStartDate(nowday) {
  59. let that = this;
  60. this.now = new Date(nowday);
  61. this.nowYear = this.now.getFullYear(); //当前年
  62. this.nowMonth = this.now.getMonth(); //当前月
  63. this.nowDay = this.now.getDate(); //当前日
  64. this.setData({
  65. nowDay:this.nowDay
  66. });//保存当前日
  67. this.nowDayOfWeek = this.now.getDay(); //今天是本周的第几天
  68. let dateStart = util.formatDate(new Date(this.nowYear, this.nowMonth, this.nowDay - this.nowDayOfWeek + 1));
  69. 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)];
  70. 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)];
  71. this.setData({
  72. weekdate: weekdate,
  73. weekdateday:weekdateday
  74. })
  75. },
  76. changeWeekTime(e){
  77. console.log(e.target.id);
  78. let changetime=e.target;
  79. },
  80. showtime(){
  81. this.setData({
  82. showchangetime: true,
  83. });
  84. },
  85. handleSelect(e) {
  86. console.log(e[0]);
  87. },
  88. });