taskreminder.js 5.0 KB

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