import request from '../../../util/http' import apiUrl from '../../../util/apiUrl' var app = getApp(); Page({ data: { servantName:'',//保姆姓名 workDay:'',//工作日 isBind:false,// 是否关联 0 未关联 1关联 isOnlyOne:false,//切换列表是否只有一个 noAddTaskShow:false,//未添加任务 noTaskShow:false,//今天无任务 taskListShow:false,//任务列表 bindCode:'',//关联码 taskList:[], bmybgxShow:false,//通知栏展示 rwwfwcShow:false, phszShow:false, phgxShow:false, unSetServiceModal:false,//未设置服务标准 unSetTaskModal:false,//未设置任务提醒 finishSetModal:false,//完成设置指引 noSetSerStan:false,//未设置服务标准 unSetBtn: [ { text: '现在设置', extClass: 'buttonBold' }, { text: '暂不' }, ], finishSetBtn: [ { text: '开启体验', extClass: 'buttonBold' }, {text:''} ], finishTitle:'', finishTips:'', finishModalCase1:['完成指引','记得设置服务标准哦'], finishModalCase2:['完成指引','记得设置任务提醒哦'], finishModalCase3:['恭喜您已完成所有设置','分享关联码关联保姆'] }, onLoad(query) { // 从存储中获取是否完成首次设置,如果完成则不弹框提示 // 如果是首次未设置,首先弹框提示服务标准设置,然后提示任务设置,首次从设置任务跳转过来展示完成指引 console.log(query); // this.setData({ // finishTitle:this.data.finishModalCase1[0], // finishTips:this.data.finishModalCase1[1], // }); let emReNo=query.emReNo; // 存储此次进入任务中心的关联码 app.globalData.employRelationNo=emReNo; my.setStorageSync({ key: 'employRelationNo', data: emReNo }); // this.initCustomerInfo(); // 如果携带创建任务完成时参数,弹框提示完成指引 }, onShow(query){ console.log(query); this.initCustomerInfo(); this.getEmployerNotice(); }, // 获取雇佣关系详情 initCustomerInfo(){ let params={ "employRelationNo":app.globalData.employRelationNo } request.httpServiceGet(apiUrl.getRelationInfoPath,params).then(data=>{ console.log(data); app.globalData.relationInfo=data; let employSetState=data.employSetState; let isOnlyOne=(data.isMoreServant<=1); let isInvalid=(data.isInvalid=='1'); this.setData({ servantName:data.servantName, workDay:data.servantTaskPeriod.workDay, serviceType:data.servantType, isOnlyOne:isOnlyOne, isBind:isInvalid, bindCode:data.employIdentifier }); // 完成初次设置的 if(employSetState=='1'){ this.setData({ unSetServiceModal:false, }); // 获取任务设置和服务标准设置 this.isChooseSerStanSubject(); this.selectTodayTaskItem(); }else{ this.setData({ // unSetServiceModal:true, // noSetSerStan:true, noAddTaskShow:true, }); // 获取服务标准和任务设置的具体情况 this.isSetServiceAndTask(); } }).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); }) }, // 是否设置服务标准和任务 isSetServiceAndTask(){ let params={ "employRelationNo":app.globalData.employRelationNo } request.httpServiceGet(apiUrl.isSetServiceAndTaskPath,params).then(data=>{ console.log(data); let service=data.service; let task=data.task; if(!service && !task){ // 任务和服务标准都未设置 this.setData({ finishTitle:this.data.finishModalCase1[0], finishTips:this.data.finishModalCase1[1], }); this.setData({ unSetServiceModal:true, noSetSerStan:true, }); }else if(service &&!task){ // 服务标准设置,任务未设置 this.setData({ finishTitle:this.data.finishModalCase2[0], finishTips:this.data.finishModalCase2[1], }); this.setData({ unSetServiceModal:false, noSetSerStan:false, unSetTaskModal:true }); }else if(service &&task){ // 服务标准完成,任务完成 this.setData({ finishTitle:this.data.finishModalCase3[0], finishTips:this.data.finishModalCase3[1], }); this.setData({ unSetServiceModal:false, noSetSerStan:false, unSetTaskModal:false, finishSetModal:true, }); this.selectTodayTaskItem();//获取任务前三条 } }).catch(e=>{ console.log(e); }) }, switchAddTask(){ // 跳转到添加任务页面 my.navigateTo({ url: '../dailytasks/dailytasks' }); }, switchTaskRemind(){ // 跳转到任务提醒器页面 my.navigateTo({ url: '../taskreminder/taskreminder' }); }, switchList(){ my.navigateTo({ url: '../myServantList/myServantList' }); }, editServant(){ my.navigateTo({ url: '../editServant/editServant' }); }, copyCode(){ my.setClipboard({ text: this.data.bindCode, success:()=>{ my.showToast({ content: '复制成功', }); }, fail:()=>{ my.showToast({ content: '复制失败', }); } }); }, // 点击设置服务标准按钮 onSetServiceButtonClick(e){ console.log(e.target); if(e.target.dataset.index==0){ this.setData({ unSetServiceModal: false, }); // 跳转到服务标准页面 }else{ // 提醒设置任务 this.setData({ unSetServiceModal: false, unSetTaskModal:true }); } }, // 点击设置任务提醒按钮 onSetTaskButtonClick(e){ console.log(e.target); if(e.target.dataset.index==0){ this.setData({ unSetTaskModal: false, }); // 跳转到任务设置页面,传首次设置任务的参数 my.navigateTo({ url: '../dailytasks/dailytasks?firstSetTask=1' }); }else{ // 提醒完成设置 if(this.data.noSetSerStan&&this.data.noAddTaskShow){ this.setData({ finishTitle:this.data.finishModalCase1[0], finishTips:this.data.finishModalCase1[1], }); }else if(!this.data.noSetSerStan&&this.data.noAddTaskShow){ this.setData({ finishTitle:this.data.finishModalCase2[0], finishTips:this.data.finishModalCase2[1], }); } this.setData({ unSetTaskModal: false, finishSetModal:true }); // 首次设置完成标示缓存下来 } }, // 跳转到服务标准页面 switchSerStandard(){ // if(this.data.noSetSerStan){ // my.navigateTo({ // url: '../servantsettings/servantsettings' // }); // }else{ // my.navigateTo({ // url: '../servantlist/servantlist' // }); // } }, switchSerHobby(){ // 跳转到服务偏好页面 my.navigateTo({ url: '../servantdetail/servantdetail' }); }, // 点击开启体验按钮 onFinishButtonClick(e){ console.log(e.target); if(e.target.dataset.index==0){ this.setData({ finishSetModal: false, }); // 首次设置完成提交后台完成引导设置 // this.finishAllSet(); }else{ } }, finishAllSet(){ let params={ employRelationNo:app.globalData.employRelationNo, employSetState:'1' } request.httpServicePost(apiUrl.updateEmploySetStatePath,params).then(data=>{ console.log(data); }).catch(e=>{ console.log(e); }) }, // 获取通知 getEmployerNotice(){ let params={ employRelationNo:app.globalData.employRelationNo, userId:app.globalData.userInfo.id } request.httpServicePost(apiUrl.getEmployerNoticePath,params).then(data=>{ console.log('雇主通知'); console.log(data); let bmybgx=(data.bmybgx.size>=1); let rwwfwc=(data.rwwfwc.size>=1); let phsz=(data.phsz.size>=1); let phgx=(data.phgx.size>=1); this.setData({ bmybgxShow:bmybgx, rwwfwcShow:rwwfwc, phszShow:phsz, phgxShow:phgx, }); }).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: '../monthReport/monthReport' // }); } }catch(e){ console.log(e); } }, // 查看偏好 async viewSerHobby(e){ console.log(e); try{ let data=await this.readNotice(e); if(data!=undefined){ // my.navigateTo({ // url: '../monthReport/monthReport' // }); } }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); } // request.httpServicePost(apiUrl.userReadNoticePath,params).then(data=>{ // console.log(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=='bmybgx'){ this.setData({ bmybgxShow:false }) }else if(type=='rwwfwc'){ this.setData({ rwwfwcShow:false }) }else if(type=='phsz'){ this.setData({ phszShow:false }) }else if(type=='phgx'){ this.setData({ phgxShow:false }) } } }catch(e){ console.log(e); } } });