import moment from 'moment'; import request from '../../../util/http' import apiUrl from '../../../util/apiUrl' var app = getApp(); Page({ data: { isOnlyOne:true,//切换列表是否只有一个 noAddTaskShow:true,//未添加任务 noTaskShow:false,//今天无任务 taskListShow:false,//任务列表 taskList:[], gzybgxShow:false,//通知栏展示 rwszShow:false, rwgxShow:false, fwbzszShow:false, fwbzgxShow:false, editModalShow:false,//编辑弹框 unSetModal:false,//未设置偏好 noSetSerHobby:false,//展示未设置服务偏好 noSetSerStan:false,//展示未设置服务标准 unSetBtn: [ { text: '现在设置', extClass: 'buttonBold' }, { text: '暂不' }, ], buttonFooter:[ { text: '取消' }, { text: '确定', extClass: 'buttonBold' }, ], customerName:'',//客户姓名 editCustomerName:'',//编辑客户姓名 workDay:'',//工作日 serviceType:'',//保姆工种 completeTaskCount:'', totalTaskCount:'' }, onLoad(query) { console.log(query); let emReNo=query.emReNo; // 存储此次进入任务中心的关联码 app.globalData.employRelationNo=emReNo; my.setStorageSync({ key: 'employRelationNo', data: emReNo }); // this.initCustomerInfo(); // this.isChooseSerHobSubject(); // this.isChooseSerStanSubject(); // this.selectTodayTaskItem(); // this.getServantNotice(); }, onShow(query){ console.log(query); this.initCustomerInfo(); this.isChooseSerHobSubject(); this.isChooseSerStanSubject(); this.selectTodayTaskItem(); this.getServantNotice(); }, // 获取雇佣关系详情 initCustomerInfo(){ let params={ "employRelationNo":app.globalData.employRelationNo } request.httpServiceGet(apiUrl.getRelationInfoPath,params).then(data=>{ console.log(data); app.globalData.servantInfo=data; let isOnlyOne=(data.isMoreEmploy<=1); this.setData({ customerName:data.employerName, workDay:data.servantTaskPeriod.workDay, serviceType:data.servantType, isOnlyOne:isOnlyOne }); }).catch(e=>{ console.log(e); }) }, // 是否设置服务偏好 isChooseSerHobSubject(){ let params={ "employRelationNo":app.globalData.employRelationNo } request.httpServiceGet(apiUrl.isChooseSerHobSubjectPath,params).then(data=>{ console.log('是否设置服务偏好'+data); let noSetSerHobby=(data=='0'?true:false); this.setData({ noSetSerHobby:noSetSerHobby, unSetModal:noSetSerHobby, }); }).catch(e=>{ console.log(e); }) }, // 是否设置服务标准 isChooseSerStanSubject(){ let params={ "employRelationNo":app.globalData.employRelationNo } request.httpServiceGet(apiUrl.isChooseSerStanSubjectPath,params).then(data=>{ console.log('是否设置服务标准'+data); let noSetSerStan=(data=='0'?true:false); this.setData({ noSetSerStan:noSetSerStan, }); }).catch(e=>{ console.log(e); }) }, // 是否每日任务,每日任务前三条 selectTodayTaskItem(){ let params={ "employRelationNo":app.globalData.employRelationNo } request.httpServiceGet(apiUrl.selectTodayTaskItemPath,params).then(data=>{ console.log(data); // 未设置任务 if(!data.isSet){ this.setData({ noAddTaskShow:true, noTaskShow:false, taskListShow:false, }); }else{ // 今天是休息日 if(data.servantTasks.length==0){ this.setData({ noAddTaskShow:false, noTaskShow:true, taskListShow:false, taskList:data.servantTasks }); }else{ // 今天有任务 this.setData({ noAddTaskShow:false, noTaskShow:false, taskListShow:true, taskList:data.servantTasks, completeTaskCount:data.completeTaskCount, totalTaskCount:data.totalTaskCount }); } } }).catch(e=>{ console.log(e); }) }, switchList(){ my.navigateTo({ url: '../myCustomerList/myCustomerList' }); }, // 跳转到服务标准页面 switchSerStandard(){ my.navigateTo({ url: '../servantdetail/servantdetail' }); }, editCustomer(event){ console.log(event); this.setData({ editCustomerName:'', editModalShow:true, }); }, onModalClose(e){ console.log(e.target); if(e.target.dataset.index==0){ this.setData({ editModalShow: false, }); }else{ // 保存客户姓名 this.editEmployerSubmit(); } }, // 编辑雇主提交 editEmployerSubmit(){ let params={ "employerName":this.data.editCustomerName, "employRelationNo": app.globalData.employRelationNo, } request.httpServicePost(apiUrl.updateEmployerNamePath,params).then(data=>{ console.log(data); my.showToast({ content: '修改成功', }); this.setData({ editModalShow: false, }); // 修改成功后刷新页面 this.initCustomerInfo(); }).catch(e=>{ console.log(e); }) }, bindKeyInput(e) { this.setData({ editCustomerName: e.detail.value, }); }, switchTaskRemind(){ // 跳转到任务提醒器页面 my.navigateTo({ url: '../taskreminder/taskreminder' }); }, // 点击设置按钮 onSetButtonClick(e){ console.log(e.target); if(e.target.dataset.index==0){ this.setData({ unSetModal: false, }); // 跳转到服务偏好页面 my.navigateTo({ url: '../servantsettings/servantsettings' }); }else{ this.setData({ unSetModal: false, }); } }, switchSerHobby(){ // 跳转到服务偏好页面 if(this.data.noSetSerHobby){ my.navigateTo({ url: '../servantsettings/servantsettings' }); }else{ my.navigateTo({ url: '../servantlist/servantlist' }); } }, // 获取保姆通知 getServantNotice(){ let params={ employRelationNo:app.globalData.employRelationNo, userId:app.globalData.userInfo.id } request.httpServicePost(apiUrl.getServantNoticePath,params).then(data=>{ console.log('保姆通知'); console.log(data); let gzybgx=(data.gzybgx.size>=1); let rwsz=(data.rwsz.size>=1); let rwgx=(data.rwgx.size>=1); let fwbzsz=(data.fwbzsz.size>=1); let fwbzgx=(data.fwbzgx.size>=1); this.setData({ gzybgxShow:gzybgx, rwszShow:rwsz, rwgxShow:rwgx, fwbzszShow:fwbzsz, fwbzgxShow:fwbzgx, }); }).catch(e=>{ console.log(e); }) }, // 查看月报 async viewMonthReport(e){ try{ let data=await this.readNotice(e); if(data!=undefined){ // my.navigateTo({ // url: '../monthReport/monthReport' // }); } }catch(e){ console.log(e); } }, // 查看任务 async viewTaskReminder(e){ try{ let data=await this.readNotice(e); if(data!=undefined){ my.navigateTo({ url: '../taskreminder/taskreminder' }); } }catch(e){ console.log(e); } }, // 查看服务标准 async viewSerStan(e){ console.log(e); try{ let data=await this.readNotice(e); if(data!=undefined){ my.navigateTo({ url: '../servantdetail/servantdetail' }); } }catch(e){ console.log(e); } }, async readNotice(e){ let type=e.target.dataset.noticeType; console.log(type); let params={ "employRelationNo": app.globalData.employRelationNo, "noticeType": type, "userId": app.globalData.userInfo.id } try{ let data=await request.httpServicePost(apiUrl.userReadNoticePath,params); return data; }catch(e){ console.log(e); } }, async closeNotice(e){ console.log('关闭通知'); try{ let data=await this.readNotice(e); console.log(data); if(data!=undefined){ // 通知不展示 let type=e.target.dataset.noticeType; console.log(type); if(type=='gzybgx'){ this.setData({ gzybgxShow:false }) }else if(type=='rwsz'){ this.setData({ rwszShow:false }) }else if(type=='rwgx'){ this.setData({ rwgxShow:false }) }else if(type=='fwbzsz'){ this.setData({ fwbzszShow:false }) }else if(type=='fwbzgx'){ this.setData({ fwbzgxShow:false }) } } }catch(e){ console.log(e); } } });