taskreminder.js 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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. selectDailyCost:0 //今日花销
  19. },
  20. onLoad() {
  21. //加载选中的时间
  22. let that=this;
  23. that.getWeekStartDate(this.data.nowselectTime);
  24. that.setnowweek();
  25. this.selectDayTaskItem();
  26. this.selectDayTaskCost();
  27. this.servantcountlist();
  28. },
  29. setnowweek(){
  30. let data = this.data.datelist;
  31. for(let i=0;i<7;i++){
  32. if(this.data.weekdateday[i]==this.data.nowDay){
  33. data[i].date=this.data.weekdate[i];
  34. data[i].day=this.data.weekdateday[i];
  35. data[i].cssName='tik-week-item-select'
  36. }
  37. else{
  38. data[i].date=this.data.weekdate[i];
  39. data[i].day=this.data.weekdateday[i];
  40. data[i].cssName=''
  41. }
  42. }
  43. this.setData({
  44. datelist: data,
  45. servantName: app.globalData.relationInfo.servantName,
  46. weekday: app.globalData.relationInfo.servantTaskPeriod.workDay,
  47. servantTypeValue: app.globalData.relationInfo.servantType
  48. });
  49. },
  50. showcancel(){
  51. this.setData({
  52. showcancelbox: true
  53. });
  54. },
  55. switchEditTask(){
  56. my.navigateTo({
  57. url: '../editDailyTask/editDailyTask'
  58. });
  59. },
  60. hidecnacelbox(){
  61. this.setData({
  62. showcancelbox: false
  63. });
  64. },
  65. dateAdd:function(startDate,days) {
  66. startDate = new Date(startDate);
  67. startDate = +startDate + days * 1000 * 60 * 60 * 24;
  68. startDate = new Date(startDate);
  69. //var nextStartDate = startDate.getFullYear() + "-" + (startDate.getMonth() + 1) + "-" + startDate.getDate();
  70. return startDate.getDate();
  71. },
  72. datedayAdd:function(startDate,days) {
  73. startDate = new Date(startDate);
  74. startDate = +startDate + days * 1000 * 60 * 60 * 24;
  75. startDate = new Date(startDate);
  76. var nextStartDate = startDate.getFullYear() + "-" + (startDate.getMonth() + 1) + "-" + startDate.getDate();
  77. return nextStartDate;
  78. },
  79. //获取本周的开始日期
  80. getWeekStartDate(nowday) {
  81. let that = this;
  82. this.now = new Date(nowday);
  83. this.nowYear = this.now.getFullYear(); //当前年
  84. this.nowMonth = this.now.getMonth(); //当前月
  85. this.nowDay = this.now.getDate(); //当前日
  86. this.setData({
  87. nowDay:this.nowDay
  88. });//保存当前日
  89. this.nowDayOfWeek = this.now.getDay(); //今天是本周的第几天
  90. let dateStart = util.formatDate(new Date(this.nowYear, this.nowMonth, this.nowDay - this.nowDayOfWeek));
  91. 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)];
  92. 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)];
  93. this.setData({
  94. weekdate: weekdate,
  95. weekdateday:weekdateday
  96. })
  97. },
  98. changeWeekTime(e){
  99. //切换选中的样式
  100. let weeklist=this.data.datelist;
  101. let selectedtabid=e.target.dataset.id;
  102. for(let i=0;i<weeklist.length;i++){
  103. if(weeklist[i].id==selectedtabid){
  104. weeklist[i].cssName="tik-week-item-select";
  105. }else{
  106. weeklist[i].cssName="";
  107. }
  108. }
  109. //设置当前选中的时间
  110. this.setData({
  111. nowselectTime:e.target.dataset.value,
  112. datelist:weeklist
  113. });
  114. this.selectDayTaskItem();
  115. this.selectDayTaskCost();
  116. },
  117. showtime(){
  118. this.setData({
  119. showchangetime: true,
  120. });
  121. },
  122. //日历选中
  123. handleSelect(e) {
  124. this.setData({
  125. nowselectTime:util.formatDate(e[0]),
  126. showchangetime:false,
  127. nowDay:new Date(util.formatDate(e[0])).getDay()
  128. });
  129. this.getWeekStartDate(util.formatDate(e[0]));
  130. this.setnowweek();
  131. this.selectDayTaskItem();
  132. this.selectDayTaskCost();
  133. },
  134. // 查询保姆每日任务
  135. selectDayTaskItem() {
  136. let params = {
  137. "employRelationNo": app.globalData.employRelationNo,
  138. "date": this.data.nowselectTime
  139. }
  140. request.httpServiceGet(apiUrl1.selectDayTaskItemPath, params).then(data => {
  141. // 未设置任务
  142. if (data.length == 0) {
  143. this.setData({
  144. isreminds: false,
  145. });
  146. } else {
  147. // 今天有任务
  148. this.setData({
  149. taskList: data,
  150. isreminds: true
  151. });
  152. }
  153. }
  154. ).catch(e => {
  155. console.log(e);
  156. })
  157. },
  158. //查询今天花销
  159. selectDayTaskCost() {
  160. let params = {
  161. "employRelationNo": app.globalData.employRelationNo,
  162. "date": this.data.nowselectTime
  163. }
  164. request.httpServiceGet(apiUrl.getEmployerCost, params).then(data => {
  165. this.setData({
  166. selectDailyCost:data
  167. });
  168. }
  169. ).catch(e => {
  170. console.log(e);
  171. })
  172. },
  173. //切换到其他家庭
  174. changeotherhome(){
  175. my.navigateTo({
  176. url: '../myServantList/myServantList'
  177. });
  178. },
  179. //计算家庭数量
  180. servantcountlist(){
  181. let params={
  182. "employerId":app.globalData.userInfo.id,
  183. "pageNo": 1,
  184. "pageSize": 100,
  185. }
  186. request.httpServicePost(apiUrl.findByEmployerIdListPath,params).then(data=>{
  187. console.log(data);
  188. if(data.dataList.length>1){
  189. this.setData({
  190. homecssname:true
  191. });
  192. }else{
  193. this.setData({
  194. homecssname:false
  195. });
  196. }
  197. }).catch(e=>{
  198. console.log(e);
  199. })
  200. },
  201. });