taskreminder.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. var util = require('../../../util/util.js')
  2. import request from '../../../util/http'
  3. import apiUrl1 from '../../../util/apiUrl1'
  4. var app = getApp();
  5. Page({
  6. data: {
  7. showchangetime: false,
  8. nowselectTime: util.formatDate(new Date()),
  9. 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 }],
  10. isreminds: true,
  11. showcancelbox: false,
  12. cancellist: [{ value: '1', label: '任务太多', checked: true }, { value: '2', label: '我不会', checked: false }, { value: '3', label: '任务不详细', checked: false }],
  13. taskList: [],
  14. },
  15. onLoad() {
  16. //加载选中的时间
  17. console.log(this.data.nowselectTime);
  18. let that = this;
  19. that.getWeekStartDate(this.data.nowselectTime);
  20. let data = this.data.datelist;
  21. for (let i = 0; i < 7; i++) {
  22. if (this.data.weekdateday[i] == this.data.nowDay) {
  23. data[i].date = this.data.weekdate[i];
  24. data[i].day = this.data.weekdateday[i];
  25. data[i].cssName = 'tik-week-item-select'
  26. }
  27. else {
  28. data[i].date = this.data.weekdate[i];
  29. data[i].day = this.data.weekdateday[i];
  30. }
  31. }
  32. this.setData({
  33. datelist: data
  34. });
  35. //处理时间完成
  36. this.selectDayTaskItem();
  37. },
  38. showcancel() {
  39. this.setData({
  40. showcancelbox: true
  41. });
  42. },
  43. hidecnacelbox() {
  44. this.setData({
  45. showcancelbox: false
  46. });
  47. },
  48. dateAdd: function (startDate, days) {
  49. startDate = new Date(startDate);
  50. startDate = +startDate + days * 1000 * 60 * 60 * 24;
  51. startDate = new Date(startDate);
  52. //var nextStartDate = startDate.getFullYear() + "-" + (startDate.getMonth() + 1) + "-" + startDate.getDate();
  53. return startDate.getDate();
  54. },
  55. datedayAdd: function (startDate, days) {
  56. startDate = new Date(startDate);
  57. startDate = +startDate + days * 1000 * 60 * 60 * 24;
  58. startDate = new Date(startDate);
  59. var nextStartDate = startDate.getFullYear() + "-" + (startDate.getMonth() + 1) + "-" + startDate.getDate();
  60. return nextStartDate;
  61. },
  62. //获取本周的开始日期
  63. getWeekStartDate(nowday) {
  64. let that = this;
  65. this.now = new Date(nowday);
  66. this.nowYear = this.now.getFullYear(); //当前年
  67. this.nowMonth = this.now.getMonth(); //当前月
  68. this.nowDay = this.now.getDate(); //当前日
  69. this.setData({
  70. nowDay: this.nowDay
  71. });//保存当前日
  72. this.nowDayOfWeek = this.now.getDay(); //今天是本周的第几天
  73. let dateStart = util.formatDate(new Date(this.nowYear, this.nowMonth, this.nowDay - this.nowDayOfWeek + 1));
  74. 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)];
  75. 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)];
  76. this.setData({
  77. weekdate: weekdate,
  78. weekdateday: weekdateday
  79. })
  80. },
  81. changeWeekTime(e) {
  82. console.log(e.target.id);
  83. let changetime = e.target;
  84. },
  85. showtime() {
  86. this.setData({
  87. showchangetime: true,
  88. });
  89. },
  90. handleSelect(e) {
  91. console.log(e[0]);
  92. },
  93. // 查询保姆每日任务
  94. selectDayTaskItem() {
  95. let params = {
  96. "employRelationNo": app.globalData.employRelationNo,
  97. "date": this.data.nowselectTime
  98. }
  99. request.httpServiceGet(apiUrl1.selectDayTaskItemPath, params).then(data => {
  100. console.log(data);
  101. // 未设置任务
  102. if (data == null) {
  103. this.setData({
  104. isreminds: false,
  105. });
  106. } else {
  107. // 今天有任务
  108. this.setData({
  109. taskList: data,
  110. });
  111. }
  112. }
  113. ).catch(e => {
  114. console.log(e);
  115. })
  116. },
  117. });