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' }, ], finishSetModal:false,//完成设置指引 finishSetBtn: [ { text: '开启体验', extClass: 'buttonBold' }, {text:''}], customerName:'',//客户姓名 editCustomerName:'',//编辑客户姓名 workDay:'',//工作日 serviceType:'',//保姆工种 completeTaskCount:'', totalTaskCount:'', noReportShow:false,//没有月报 servantSetState:'', }, onLoad(query) { console.log(query); let emReNo=query.emReNo; // 存储此次进入任务中心的关联码 app.globalData.employRelationNo=emReNo; my.setStorageSync({ key: 'userRelationNo', data: { employRelationNo:emReNo, userId:app.globalData.userInfo.id } }); // 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(); this.selectMonthlyReport(); }, // 获取雇佣关系详情 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, servantSetState:data.servantSetState }); this.isChooseSerHobSubject(); }).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, }); // 未完成首次设置并且未设置的 if(this.data.servantSetState=='0'&&noSetSerHobby){ this.setData({ unSetModal:true, }); }else{ this.setData({ unSetModal:false, }); } }).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('每日任务返回'); console.log(data); // 未设置任务 if(!data.isSet){ this.setData({ noAddTaskShow:true, noTaskShow:false, taskListShow:false, }); }else{ if(data.workDay==false){ // 今天是休息日 this.setData({ noAddTaskShow:false, noTaskShow:true, taskTipText:'今天是休息日', taskListShow:false, taskList:data.servantTasks }); }else if(data.servantTasks.length==0){ // 今天无任务 this.setData({ noAddTaskShow:false, noTaskShow:true, taskTipText:'今天无任务', 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(){ if(this.data.noAddTaskShow==false){ // 跳转到任务提醒器页面 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, finishSetModal:true }); } }, 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: '../reportList/reportList' }); } }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); } }, // 获取月报 selectMonthlyReport(){ let params={ "employRelationNo":app.globalData.employRelationNo, "reportType": '2', } request.httpServicePost(apiUrl.selectMonthlyReportPath,params).then(data=>{ console.log('月报信息response'); console.log(data); let noReport=(data.length==0) this.setData({ noReportShow: noReport, }); if(!noReport){ app.globalData.reportList=data; } }).catch(e=>{ console.log(e); }) }, switchReportList(){ if(!this.data.noReportShow){ my.navigateTo({ url: '../reportList/reportList' }); } }, // 点击开启体验按钮 onFinishButtonClick(e){ console.log(e.target); // if(this.data.finishTitle==this.data.finishModalCase3[0]){ // // 复制关联码 // this.copyCode(); // } if(e.target.dataset.index==0){ this.setData({ finishSetModal: false, }); // 首次设置完成提交后台完成引导设置 this.finishAllSet(); }else{ } }, finishAllSet(){ let params={ employRelationNo:app.globalData.employRelationNo, servantSetState:'1' } request.httpServicePost(apiUrl.updateServantSetStatePath,params).then(data=>{ console.log(data); }).catch(e=>{ console.log(e); }) }, });