// index.js // 获取应用实例 const app = getApp(); const util = require('../../../utils/jmsUtil.js'); const api = require('../../../api/jms.js'); import moment from 'moment' Page({ data: { isAgree:false, clueId:'', cityId:'', dateTimeVisible:false, startTimeVisible:false, endTimeVisible:false, currentDate:moment(new Date()).format('YYYY-MM-DD HH:mm'), currentTime:moment(new Date()).format('HH:mm'), region:['','',''], clueInfo:{ name:'', tel:'', idCard:'', fraName:'', // company:{ // label:'请选择(必填)', // value:'', // }, area:'请选择(必填)', province:'', city:'', district:'', address:'', remark:'', }, selectValue:'', selectVisible:false, selectKey:'', post:'', fraId:'', fraDisable:false }, // 事件处理函数 onLoad(options) { // this.getCompanyList(); console.log(options); if(options&&options.farId){ this.setData({ fraId:options.fraId, 'clueInfo.fraName':options.fraName, fraDisable:true }) } }, checkProBtn: function (e) { console.log(e.detail.value) this.setData({ isAgree: true, }) wx.navigateTo({ url: '/pages/temp/jzxhAppletsUserPro/jzxhAppletsUserPro' }) }, getCompanyList(){ util.request(api.WxservantGetAllList, { }, 'GET').then(res=>{ if (res.errno == 0) { let data=res.data; let list=[]; data.forEach(item=>{ let obj={ label:item.userName, value:item.userId }; list.push(obj); }); this.setData({ list:list }); }else{ wx.showToast({ title: res.errmsg, icon:'none' }) } }); }, selectDateTime(){ this.setData({ dateTimeVisible:true }); }, selectStartTime(){ this.setData({ startTimeVisible:true }); }, selectEndTime(){ this.setData({ endTimeVisible:true }); }, hidePicker(){ this.setData({ dateTimeVisible:false }); }, hideStartPicker(){ this.setData({ startTimeVisible:false }); }, hideEndPicker(){ this.setData({ endTimeVisible:false }); }, onDateTimeConfirm(e){ this.setData({ currentDate:e.detail.value, 'clueInfo.date':e.detail.value, dateTimeVisible:false }); }, onStartTimeConfirm(e){ this.setData({ currentTime:e.detail.value, 'clueInfo.startTime':e.detail.value, startTimeVisible:false }); }, onEndTimeConfirm(e){ this.setData({ currentTime:e.detail.value, 'clueInfo.endTime':e.detail.value, endTimeVisible:false }); }, inputClue(e){ let obj=e.currentTarget.dataset.obj; let item=`clueInfo.${obj}`; this.setData({ [item]:e.detail.value }); // console.log(this.data.clueInfo); }, selectClue(e){ let obj=e.currentTarget.dataset.obj; this.setData({ selectKey:obj, selectVisible:true }); console.log(this.data.selectKey); }, postSelect(){ this.setData({ postVisible:true }); }, onPickerConfirm(e){ console.log(e); let obj={ label:e.detail.value.text, value:e.detail.value.value } this.setData({ 'clueInfo.company':obj, selectVisible:false }); }, onPickerCancel(){ this.setData({ selectVisible:false }); }, bindRegionChange: function (e) { console.log('picker发送选择改变,携带值为', e.detail.value) this.setData({ 'clueInfo.area': e.detail.value, 'clueInfo.province': e.detail.value[0], 'clueInfo.city': e.detail.value[1], 'clueInfo.district': e.detail.value[2], }) }, submitInterview(){ if(this.data.clueInfo.name==''){ wx.showToast({ title: '请输入姓名', icon:'none' }); }else if(this.data.clueInfo.tel==''){ wx.showToast({ title: '请输入手机号', icon:'none' }); }else if (!/^1\d{10}$/.test(this.data.clueInfo.tel)) { wx.showToast({ title: '请输入正确的手机号码', icon:'none' }); return false; }else if(this.data.clueInfo.idCard==''){ wx.showToast({ title: '请输入身份证号', icon:'none' }); } else if(!util.validIdCard(this.data.clueInfo.idCard)){ wx.showToast({ title: '身份证号格式不正确', icon:'none' }); }else if(this.data.clueInfo.fraName==''){ wx.showToast({ title: '请输入所属公司', icon:'none' }); }else if(this.data.clueInfo.area=='请选择(必填)'){ wx.showToast({ title: '请选择地址(省市区)', icon:'none' }); }else if(this.data.clueInfo.address==''){ wx.showToast({ title: '请输入详细地址', icon:'none' }); }else{ wx.showLoading({ title: '保存中', }) let params={ name:this.data.clueInfo.name, tel:this.data.clueInfo.tel, idCard:this.data.clueInfo.idCard, fraName:this.data.clueInfo.fraName, province:this.data.clueInfo.province, city:this.data.clueInfo.city, district:this.data.clueInfo.district, address:this.data.clueInfo.address, remark:this.data.clueInfo.remark, fraId:this.data.fraId } util.request(api.WxservantAdd, params , 'POST').then(res=>{ wx.hideLoading(); if (res.errno == 0) { // wx.showToast({ // title: '提交成功', // }) wx.showModal({ title: '提示', content: '提交成功', showCancel:false, complete: (res) => { if (res.cancel) { } if (res.confirm) { // wx.navigateBack({ // delta:1 // }); // wx.navigateTo({ // url: '/pages/temp/login/login', // }) wx.redirectTo({ url: '/pages/index/index' }); } } }) }else{ wx.showToast({ title: res.errmsg, icon:'none' }) } }).catch(err=>{ wx.hideLoading(); }); } }, })