123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 |
- var util = require('../../../util/util.js')
- import apiUrl1 from '../../../util/apiUrl1'
- import apiUrl from '../../../util/apiUrl'
- import request from '../../../util/http'
- var app = getApp();
- Page({
- data: {
- showchangetime:false,
- nowselectTime:util.formatDate(new Date()),
- 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 }],
- isreminds:true,
- showcancelbox:false,
- cancellist:[{value:'1', label:'任务太多', checked:true},{value:'2', label:'我不会', checked:false},{value:'3', label:'任务不详细', checked:false}],
- servantName: '',//保姆姓名
- weekday: '',//日前
- servantTypeValue: '',//保姆工种,
- taskList: [],
- selectDailyCost:0 //今日花销
- },
- onLoad() {
- //加载选中的时间
- let that=this;
- that.getWeekStartDate(this.data.nowselectTime);
- that.setnowweek();
- this.selectDayTaskItem();
- this.selectDayTaskCost();
- this.servantcountlist();
- },
- setnowweek(){
- let data = this.data.datelist;
- for(let i=0;i<7;i++){
- if(this.data.weekdateday[i]==this.data.nowDay){
- data[i].date=this.data.weekdate[i];
- data[i].day=this.data.weekdateday[i];
- data[i].cssName='tik-week-item-select'
- }
- else{
- data[i].date=this.data.weekdate[i];
- data[i].day=this.data.weekdateday[i];
- data[i].cssName=''
- }
- }
- this.setData({
- datelist: data,
- servantName: app.globalData.relationInfo.servantName,
- weekday: app.globalData.relationInfo.servantTaskPeriod.workDay,
- servantTypeValue: app.globalData.relationInfo.servantType
- });
- },
- showcancel(){
- this.setData({
- showcancelbox: true
- });
- },
- switchEditTask(){
- my.navigateTo({
- url: '../editDailyTask/editDailyTask'
- });
- },
- hidecnacelbox(){
- this.setData({
- showcancelbox: false
- });
- },
- dateAdd:function(startDate,days) {
- startDate = new Date(startDate);
- startDate = +startDate + days * 1000 * 60 * 60 * 24;
- startDate = new Date(startDate);
- //var nextStartDate = startDate.getFullYear() + "-" + (startDate.getMonth() + 1) + "-" + startDate.getDate();
- return startDate.getDate();
- },
- datedayAdd:function(startDate,days) {
- startDate = new Date(startDate);
- startDate = +startDate + days * 1000 * 60 * 60 * 24;
- startDate = new Date(startDate);
- var nextStartDate = startDate.getFullYear() + "-" + (startDate.getMonth() + 1) + "-" + startDate.getDate();
-
- return nextStartDate;
- },
- //获取本周的开始日期
- getWeekStartDate(nowday) {
- let that = this;
- this.now = new Date(nowday);
- this.nowYear = this.now.getFullYear(); //当前年
- this.nowMonth = this.now.getMonth(); //当前月
- this.nowDay = this.now.getDate(); //当前日
- this.setData({
- nowDay:this.nowDay
- });//保存当前日
- this.nowDayOfWeek = this.now.getDay(); //今天是本周的第几天
- let dateStart = util.formatDate(new Date(this.nowYear, this.nowMonth, this.nowDay - this.nowDayOfWeek));
-
- 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)];
- 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)];
- this.setData({
- weekdate: weekdate,
- weekdateday:weekdateday
- })
- },
- changeWeekTime(e){
- //切换选中的样式
- let weeklist=this.data.datelist;
- let selectedtabid=e.target.dataset.id;
- for(let i=0;i<weeklist.length;i++){
- if(weeklist[i].id==selectedtabid){
- weeklist[i].cssName="tik-week-item-select";
- }else{
- weeklist[i].cssName="";
- }
- }
- //设置当前选中的时间
- this.setData({
- nowselectTime:e.target.dataset.value,
- datelist:weeklist
- });
- this.selectDayTaskItem();
- this.selectDayTaskCost();
- },
-
- showtime(){
- this.setData({
- showchangetime: true,
- });
- },
- //日历选中
- handleSelect(e) {
- this.setData({
- nowselectTime:util.formatDate(e[0]),
- showchangetime:false,
- nowDay:new Date(util.formatDate(e[0])).getDay()
- });
- this.getWeekStartDate(util.formatDate(e[0]));
- this.setnowweek();
- this.selectDayTaskItem();
- this.selectDayTaskCost();
- },
- // 查询保姆每日任务
- selectDayTaskItem() {
- let params = {
- "employRelationNo": app.globalData.employRelationNo,
- "date": this.data.nowselectTime
- }
- request.httpServiceGet(apiUrl1.selectDayTaskItemPath, params).then(data => {
- // 未设置任务
- if (data.length == 0) {
- this.setData({
- isreminds: false,
- });
- } else {
- // 今天有任务
- this.setData({
- taskList: data,
- isreminds: true
- });
- }
- }
- ).catch(e => {
- console.log(e);
- })
- },
- //查询今天花销
- selectDayTaskCost() {
- let params = {
- "employRelationNo": app.globalData.employRelationNo,
- "date": this.data.nowselectTime
- }
- request.httpServiceGet(apiUrl.getEmployerCost, params).then(data => {
- this.setData({
- selectDailyCost:data
- });
- }
- ).catch(e => {
- console.log(e);
- })
- },
- //切换到其他家庭
- changeotherhome(){
- my.navigateTo({
- url: '../myServantList/myServantList'
- });
- },
- //计算家庭数量
- servantcountlist(){
- let params={
- "employerId":app.globalData.userInfo.id,
- "pageNo": 1,
- "pageSize": 100,
- }
- request.httpServicePost(apiUrl.findByEmployerIdListPath,params).then(data=>{
- console.log(data);
- if(data.dataList.length>1){
- this.setData({
- homecssname:true
- });
- }else{
- this.setData({
- homecssname:false
- });
- }
- }).catch(e=>{
- console.log(e);
- })
- },
- });
|