123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496 |
- 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);
-
- })
- },
-
- });
|