123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553 |
- 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,//未设置服务标准
- noReportShow:false,//没有月报
- taskTipText:'',
- 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: 'userRelationNo',
- data: {
- employRelationNo:emReNo,
- userId:app.globalData.userInfo.id
- }
- });
-
- // this.initCustomerInfo();
- // 如果携带创建任务完成时参数,弹框提示完成指引
- },
- onShow(query){
- console.log(query);
- this.initCustomerInfo();
- this.selectTodayTaskItem();
- this.getEmployerNotice();
- this.selectMonthlyReport();
- },
- // 获取雇佣关系详情
- 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('每日任务返回');
- console.log(data);
- // 未设置任务
- if(data.isSet==false){
- console.log('isSet:false');
- 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);
-
- })
- },
- // 是否设置服务标准和任务
- 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,
- });
- // 跳转到服务标准页面
- my.navigateTo({
- url: '../servantsettings/servantsettings'
- });
-
- }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(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,
- 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: '../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 viewSerHobby(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);
- }
- // 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);
- }
- },
- // 获取月报
- selectMonthlyReport(){
-
- let params={
- "employRelationNo":app.globalData.employRelationNo,
- "reportType": '1',
- }
- 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'
- });
- }
- }
- });
|