123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- import request from '../../../util/http'
- import apiUrl from '../../../util/apiUrl'
- var app = getApp();
- Page({
- data: {
- servantName:'',
- index:0,
- serviceModelList: [
- // {
- // type:'1',
- // text:'小时工'
- // },
- {
- type:'2',
- text:'钟点工'
- },
- {
- type:'3',
- text:'住家保姆'
- },
- {
- type:'4',
- text:'白班保姆'
- },
- {
- type:'5',
- text:'月嫂'
- }
-
- ],
- serviceModelName:'请选择',
- serviceModelType:'',
- workSelectedList:[],
- workSelectedClassList:[],
- workInitList:[
- {workDayZh:'周一',
- index:'1',
- },
- {workDayZh:'周二',
- index:'2',
- },
- {workDayZh:'周三',
- index:'3',
- },
- {workDayZh:'周四',
- index:'4',
- },
- {workDayZh:'周五',
- index:'5',
- },
- {workDayZh:'周六',
- index:'6',
- },
- {workDayZh:'周日',
- index:'0',
- }
- ]
- },
- onLoad(options) {
- console.log(options);
- },
- bindServantInput(e){
- this.setData({
- servantName: e.detail.value,
- });
- console.log(this.data.servantName);
- },
- bindPickerChange(e) {
- console.log('picker发送选择改变,携带值为', e.detail.value);
- let index=e.detail.value;
- let type=((this.data.serviceModelList)[index]).type;
- let value=((this.data.serviceModelList)[index]).text;
- this.setData({
- serviceModelName: value,
- serviceModelType:type
- });
-
- },
- toggleWorkTime(e){
- let id=e.target.dataset.id;
- let zh=e.target.dataset.zh;
- let isNew=this.data.workSelectedList.every(item=>{return id!=item.index});
- if(isNew){
- let newArr=this.data.workSelectedList;
- let obj={
- index:id,
- workDayZh:zh
- }
- newArr.push(obj);
- let newArrClass=this.data.workSelectedClassList;
- newArrClass.push(id);
- this.setData({
- workSelectedList:newArr,
- workSelectedClassList:newArrClass
- })
- }else{
- let spliceIndex='';
- this.data.workSelectedList.forEach((item,index)=> {
- if(item.index==id){
- console.log(item,index);
- spliceIndex=index;
- return;
- }
- })
- let newArr=this.data.workSelectedList;
- let newArrClass=this.data.workSelectedClassList;
- newArr.splice(spliceIndex,1);
- newArrClass.splice(newArrClass.indexOf(id),1);
- this.setData({
- workSelectedList:newArr,
- workSelectedClassList:newArrClass
- })
- }
-
-
- },
- createServant(){
- if(this.data.servantName==''){
- my.alert({
- content:'请输入服务者姓名'
- });
- }else if(this.data.serviceModelName=='请选择'){
- my.alert({
- content:'请选择该服务者的工种'
- });
- }else if(this.data.workSelectedList.length==0){
- my.alert({
- content:'请选择该服务者的工作时间'
- });
- }else{
- // 创建服务者,提交后台
- this.submitServant();
- }
- },
- submitServant(){
- let params={
- "employerId": app.globalData.userInfo.id,
- "servantName": this.data.servantName,
- "servantType": this.data.serviceModelType,
- "taskPeriods": this.data.workSelectedList,
- "userType": "1"
- }
- request.httpServicePost(apiUrl.createServantRelationPath,params).then(data=>{
- console.log(data);
- // 创建成功跳转到保姆工作站
- app.globalData.employRelationNo=data.employRelationNo;
- let emReNo=data.employRelationNo;
- my.navigateTo({
- url: '../customerCenter/customerCenter?emReNo='+emReNo
- });
-
- }).catch(e=>{
- console.log(e);
-
- })
- }
- });
|