123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259 |
- 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:[],
- noticeShow:true,//通知栏展示
- 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();
- },
- onShow(query){
- console.log(query);
- },
- // 获取雇佣关系详情
- initCustomerInfo(){
- let params={
- "employRelationNo":app.globalData.employRelationNo
- }
- request.httpServiceGet(apiUrl.getRelationInfoPath,params).then(data=>{
- console.log(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,
- });
-
- },
- closeNotice(){
- this.setData({
- noticeShow:false
- });
- },
- 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'
- });
- }
-
- }
-
- });
|