taskreminder.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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. cost: ""
  15. },
  16. onLoad() {
  17. //加载选中的时间
  18. console.log(this.data.nowselectTime);
  19. let that = this;
  20. that.getWeekStartDate(this.data.nowselectTime);
  21. let data = this.data.datelist;
  22. for (let i = 0; i < 7; i++) {
  23. if (this.data.weekdateday[i] == this.data.nowDay) {
  24. data[i].date = this.data.weekdate[i];
  25. data[i].day = this.data.weekdateday[i];
  26. data[i].cssName = 'tik-week-item-select'
  27. }
  28. else {
  29. data[i].date = this.data.weekdate[i];
  30. data[i].day = this.data.weekdateday[i];
  31. }
  32. }
  33. this.setData({
  34. datelist: data
  35. });
  36. //处理时间完成
  37. this.selectDayTaskItem();
  38. },
  39. showcancel() {
  40. this.setData({
  41. showcancelbox: true
  42. });
  43. },
  44. hidecnacelbox() {
  45. this.setData({
  46. showcancelbox: false
  47. });
  48. },
  49. dateAdd: function (startDate, days) {
  50. startDate = new Date(startDate);
  51. startDate = +startDate + days * 1000 * 60 * 60 * 24;
  52. startDate = new Date(startDate);
  53. //var nextStartDate = startDate.getFullYear() + "-" + (startDate.getMonth() + 1) + "-" + startDate.getDate();
  54. return startDate.getDate();
  55. },
  56. datedayAdd: function (startDate, days) {
  57. startDate = new Date(startDate);
  58. startDate = +startDate + days * 1000 * 60 * 60 * 24;
  59. startDate = new Date(startDate);
  60. var nextStartDate = startDate.getFullYear() + "-" + (startDate.getMonth() + 1) + "-" + startDate.getDate();
  61. return nextStartDate;
  62. },
  63. //获取本周的开始日期
  64. getWeekStartDate(nowday) {
  65. let that = this;
  66. this.now = new Date(nowday);
  67. this.nowYear = this.now.getFullYear(); //当前年
  68. this.nowMonth = this.now.getMonth(); //当前月
  69. this.nowDay = this.now.getDate(); //当前日
  70. this.setData({
  71. nowDay: this.nowDay
  72. });//保存当前日
  73. this.nowDayOfWeek = this.now.getDay(); //今天是本周的第几天
  74. let dateStart = util.formatDate(new Date(this.nowYear, this.nowMonth, this.nowDay - this.nowDayOfWeek + 1));
  75. 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)];
  76. 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)];
  77. this.setData({
  78. weekdate: weekdate,
  79. weekdateday: weekdateday
  80. })
  81. },
  82. changeWeekTime(e) {
  83. console.log(e.target.id);
  84. let changetime = e.target;
  85. },
  86. showtime() {
  87. this.setData({
  88. showchangetime: true,
  89. });
  90. },
  91. handleSelect(e) {
  92. console.log(e[0]);
  93. },
  94. // 查询保姆每日任务
  95. selectDayTaskItem() {
  96. let params = {
  97. "employRelationNo": app.globalData.employRelationNo,
  98. "date": this.data.nowselectTime
  99. }
  100. request.httpServiceGet(apiUrl1.selectDayTaskItemPath, params).then(data => {
  101. console.log(data);
  102. // 未设置任务
  103. if (data.length == 0) {
  104. this.setData({
  105. isreminds: false,
  106. });
  107. } else {
  108. // 今天有任务
  109. this.setData({
  110. taskList: data,
  111. });
  112. }
  113. }
  114. ).catch(e => {
  115. console.log(e);
  116. })
  117. },
  118. //今日花销合计
  119. bindKeyInput(e) {
  120. this.setData({
  121. cost: e.detail.value,
  122. });
  123. console.log(e);
  124. },
  125. //提交保姆今日花销
  126. createServant() {
  127. let employRelationNo = app.globalData.employRelationNo;
  128. let date = this.data.nowselectTime;
  129. let cost = this.data.cost;
  130. request.httpServicePost(apiUrl1.insertDailyCostPath, { employRelationNo: employRelationNo, spendDate: date, cost: cost }).then(data => {
  131. my.alert({
  132. title: '提示',
  133. content: '提交完成',
  134. buttonText: '确定',
  135. success: () => {
  136. my.navigateBack();
  137. }
  138. });
  139. });
  140. }
  141. });