// Pages/yishi/identity/index.js import { API } from './../../../utils/network/api' import { FileUtil } from './../../../utils/fileutil' const api = new API() const app = getApp() Page({ data: { navbarData: { showCapsule: 1, //是否显示左上角图标 1表示显示 0表示不显示 title: '医师身份认证', //导航栏 中间的标题 }, navHeight: 0, stateHeight: 0, height: app.globalData.height, //选项卡 stickyProps: { zIndex: 999999, offsetTop: (app.globalData.height * 2) }, selected_tab: 0, panel_2_disabled: true, next_btn_disabled: false, next_btn_txt: "下一步", realname: "", idcard: "" }, getMenuButtonBound() { let stateHeight = 0; // 接收状态栏高度 const navHeight = wx.getMenuButtonBoundingClientRect().height; // 获取胶囊高度 let top = 0; wx.getSystemInfo({ success(res) { stateHeight = res.statusBarHeight; }, }); top = wx.getMenuButtonBoundingClientRect().top - stateHeight; // 获取top值 console.log('navHeight', navHeight); console.log('top', top); this.setData({ // navHeight: navHeight + top * 2, // 导航栏高度 navHeight, // 导航栏高度 stateHeight: stateHeight + top, // 状态栏高度 }); this.setData({ "stickyProps.offsetTop": this.data.stateHeight + this.data.navHeight + 10 }) }, onLoad(){ let _this = this; //获取实名认证信息 api.getDoctorAuthReal().then(response => { console.log(response); if(response.data.length == 0){ return; } this.setData({ realname:response.data.card_name, idcard:response.data.card_num, next_btn_txt: "已认证,不可修改", next_btn_disabled: true, panel_2_disabled: false, }); }).catch(errors => { console.error(errors); }) //获得医师身份认证 // api.getDoctorAuthIden().then(response => { // console.log("getDoctorAuthIden: ",response); // this.setData({ // is_avatar: true, // doctorauthiden_data_ready: true, // textarea_jianjie: response.data.brief_introduction, // textarea_shanchang: response.data.be_good_at, // custom_keshi: response.data.department_custom_name, // office_phone: response.data.department_custom_mobile, // select_keshi_id: response.data.department_custom_id, // select_zhicheng_id: response.data.doctor_title, // select_province_id: response.data.hospital.province_id, // select_city_id: response.data.hospital.city_id, // select_county_id: response.data.hospital.county_id, // select_yiyuan_id: response.data.hospital.hospital_id, // hospital: response.data.hospital, // iden_auth_status: response.data.iden_auth_status, // }); // let iden_auth_status = response.data.iden_auth_status; // let iden_auth_status_txt = iden_auth_status == 0?'请完善资料后提交':iden_auth_status == 1?'认证通过': iden_auth_status==2?'资料已提交,审核中':iden_auth_status==3?'认证失败':'未认证'; // let iden_auth_disabled = iden_auth_status == 0?false:iden_auth_status == 1?false: iden_auth_status==2?true:iden_auth_status==3?false:true; // this.setData({ // iden_auth_status_txt: iden_auth_status_txt, // iden_auth_disabled: iden_auth_disabled // }) // if(response.data.license_cert){ // let img_list = response.data.license_cert.map(item => { // let img = {}; // img.url = item; // img.isImg = true; // return img; // }) // this.setData({ // zhiye_file_list: img_list // }) // } // if(response.data.qualification_cert){ // let img_list = response.data.qualification_cert.map(item => { // let img = {}; // img.url = item; // img.isImg = true; // return img; // }) // this.setData({ // zige_file_list: img_list // }) // } // if(response.data.work_cert){ // let img_list = response.data.work_cert.map(item => { // let img = {}; // img.url = item; // img.isImg = true; // return img; // }) // this.setData({ // zhicheng_file_list: img_list // }) // } // let avatar = response.data.avatar; // if(avatar && (avatar.indexOf("http") == -1)){ // avatar = api.getStaticHost() + avatar; // } // this.setData({ // "avatar": avatar // }) // }).catch(errors => {console.error(errors);}) // //加载省份列表 // api.getAreaProvince().then(response => { // console.log(response); // const list = _this.formatArea(response, -1, true); // _this.setData({ // areaprovince_data_ready: true, // areaList: list // }) // }).catch(errors => {console.error(errors); }) // //加载科室列表 // api.getBasicDepartment().then(response => { // console.log(response); // const list = _this.formatKeShi(response); // _this.setData({ // basicdepartment_data_ready: true, // keshi_columns: list // }) // }).catch(errors => {console.error(errors); }) // //加载专长列表 // api.getDoctorExpertise().then(response => { // console.log(response); // _this.setData({ // zhuanchang_columns: response.data // }) // }).catch(errors => {console.error(errors); }) // let keshi_huixian = false; // let zhicheng_huixian = false; // let area_huixian = false; // //执行回显 // let data_replay = setInterval(() => { // console.log("执行回显。。。") // //回显科室 // if(_this.data.doctorauthiden_data_ready && _this.data.basicdepartment_data_ready){ // let index = _this.data.keshi_columns.findIndex(item => { // return item.value == _this.data.select_keshi_id // }) // _this.setData({ // select_keshi_index: index, // keshi_note: _this.data.keshi_columns[index].text // }) // keshi_huixian = true; // } // //回显职称 // if(_this.data.doctorauthiden_data_ready){ // let index = _this.data.zhicheng_columns.findIndex(item => { // return item.value == _this.data.select_zhicheng_id // }) // _this.setData({ // select_zhicheng_index: index, // zhicheng_note: _this.data.zhicheng_columns[index].text // }) // zhicheng_huixian = true; // } // //回显省市区 // if(_this.data.doctorauthiden_data_ready && _this.data.areaprovince_data_ready){ // let select_province_id = _this.data.select_province_id; // let select_city_id = _this.data.select_city_id; // let select_county_id = _this.data.select_county_id; // let select_yiyuan_id = _this.data.select_yiyuan_id; // api.getAreaCity({area_id: select_province_id}).then(response => {// 请求市区列表 // let _index = _this.data.areaList.findIndex(item => item.value == select_province_id); // const list = _this.formatArea(response, _index, true); // const _city = "areaList[" + _index + "].children"; // console.log("_city: ", _city); // _this.setData({ // [_city]: list, // }) // }).then(e =>{ // api.getAreaCounty({area_id: select_city_id}).then(response => {// 请求市区列表 // let _index = _this.data.areaList.findIndex(item => item.value == select_province_id); // console.log("getAreaCounty: ", _index) // let c_index = _this.data.areaList[_index].children.findIndex(item => item.value == select_city_id); // console.log("children: ", _index) // let p_index = _this.data.areaList[_index].children[c_index].index; // const list = _this.formatArea(response, _index, false); // const _county = "areaList[" + _index + "].children[" +p_index+ "].children"; // _this.setData({ // [_county]: list, // }) // }).then(e => { // let params = { // province_id: _this.data.select_province_id, // city_id: _this.data.select_city_id, // county_id: _this.data.select_county_id, // } // api.getBasicHospital(params).then(response => {// 请求医院列表 // _this.setData({ // yiyuan_columns: _this.formatYiYuan(response), // city_note: _this.data.hospital.province + "/" + _this.data.hospital.city + "/" + _this.data.hospital.county // }) // setTimeout(() => { // let index = _this.data.yiyuan_columns.findIndex(item => { // return item.value == _this.data.select_yiyuan_id // }) // _this.setData({ // select_yiyuan_index: index, // yiyuan_note: _this.data.yiyuan_columns[index].text // }) // }, 100); // }).catch(errors => {console.error(errors); }) // }).catch(errors => {console.error(errors); }) // }).catch(errors => {console.error(errors); }) // area_huixian = true; // } // //都回显成功后,清除计时器 // if(keshi_huixian && zhicheng_huixian && area_huixian){ // clearInterval(data_replay); // } // console.log("计时器") // }, 100); }, onShow(){ console.log("onshow()...."); this.getMenuButtonBound(); }, doUploadFile(event) { console.log("index douploadFIle: ", event); const scene = event.currentTarget.dataset.scene; const field_name = event.currentTarget.dataset.field_name; const file_multiple = event.currentTarget.dataset.file_multiple;//是否为多张图 console.log("scene: ", scene); console.log("field_name: ", field_name); console.log("file_multiple: ", file_multiple); let _this = this; api.getOssSign({user_type:2,scene:scene}).then(response => { console.log(response); const { file } = event.detail; console.log("file: ", file); const filename = FileUtil.getFileName(file); const host = response.data.host; const signature = response.data.signature; const ossAccessKeyId = response.data.accessid; const policy = response.data.policy; const key = response.data.dir+filename; const filePath = file.url; // 待上传文件的文件路径。 wx.uploadFile({ url: host, // 开发者服务器的URL。 filePath: filePath, name: 'file', // 必须填file。 formData: { key, policy, OSSAccessKeyId: ossAccessKeyId, signature, }, success: (res) => { console.log("upload: ", res); if (res.statusCode === 204) { if(scene == 1){ this.setData({ is_avatar: true }) } wx.showToast({title: '上传成功'}) if(file_multiple == "true"){//多张图 let img = {} img.url = host+"/"+key; img.isImg = true; let img_list = _this.data[field_name]; console.log("img_list: ", img_list); img_list.push(img); console.log("img_list: ", img_list); this.setData({ [field_name]: img_list }); }else{ this.setData({[field_name]: host+"/"+key}); } } }, fail: err => { console.log(err); } }); }).catch(errors => { console.error(errors); }) }, doDeleteFile(event){ console.log(event); let url = event.detail.file.url; let file_name = event.currentTarget.dataset.field_name; let img_list = this.data[file_name].filter(item => item.url != url); this.setData({ [file_name]: img_list }) }, //新增实名认证信息 postDoctorAuthReal(){ let _this = this; const realname = this.data.realname.trim(); const idcard = this.data.idcard.trim(); console.log("realname: ",realname); console.log("idcard: ", idcard); var realname_reg= /^(([a-zA-Z+\.?\·?a-zA-Z+]{2,30}$)|([\u4e00-\u9fa5+\·?\u4e00-\u9fa5+]{2,30}$))/; var idcard_reg=/^(^[1-9]\d{5}[1-9]\d{3}(((0[2])([0|1|2][0-8])|(([0-1][1|4|6|9])([0|1|2][0-9]|[3][0]))|(((0[1|3|5|7|8])|(1[0|2]))(([0|1|2]\d)|3[0-1]))))((\d{4})|\d{3}[Xx])$)$/; //判断用户输入的真实姓名是否为空 if(realname.length == 0){ wx.showToast({title: '姓名不能为空', icon:'error'}) return false; }else if(!realname_reg.test(realname)){//检测姓名的格式是否匹配 wx.showToast({title: '姓名输入有误', icon:'error'}) return false; } //判断用户输入的身份证号是否为空 if(idcard.length == 0){ wx.showToast({title: '身份证不能为空', icon:'error'}) return false; }else if(!idcard_reg.test(idcard)){//检测姓名的格式是否匹配 wx.showToast({title: '身份证输入有误', icon:'error'}) return false; } var params = { card_name: realname, card_num: idcard, } api.postDoctorAuthReal(params).then(response => { console.log(response); _this.setData({ panel_2_disabled: false, selected_tab: 1 }) }).catch(errors => { console.error(errors); }) }, onTabsChange(event) { console.log(`Change tab, tab-panel value is ${event.detail.value}.`); this.setData({ selected_tab: event.detail.value }) }, onTabsClick(event) { console.log(`Click tab, tab-panel value is ${event.detail.value}.`); }, onStickyScroll(event) { // console.log(`Click tab, tab-panel value is ${event.detail.value}.`); }, // onCityShow(e) { // console.log("onCityShow"); // this.setData({ city_show: true }); // }, // onChangeCity(e) { // this.setData({ // select_county_id: "", // select_yiyuan_id: "" // }) // console.log("onChangeCity"); // const { selectedOptions } = e.detail; // console.log(e.detail) // let area = selectedOptions[selectedOptions.length-1]; // if(!area){ // area = selectedOptions[selectedOptions.length-2]; // } // const type = area.type; // const value = area.value; // const index = area.index; // const p_index = area.p_index; // if(type == 2){//省份 // api.getAreaCity({area_id: value}).then(response => {// 请求市区列表 // const list = this.formatArea(response, index, true); // const _city = "areaList[" + index + "].children"; // this.setData({ // [_city]: list, // select_province_id: value // }) // }).catch(errors => {console.error(errors); }) // } // if(type == 3){//市区 // api.getAreaCounty({area_id: value}).then(response => {// 请求市区列表 // const list = this.formatArea(response, index, false); // const _county = "areaList[" + p_index + "].children[" +index+ "].children"; // this.setData({ // [_county]: list, // select_city_id: value // }) // }).catch(errors => {console.error(errors); }) // } // console.log("type: " + type); // if(type == 4){//区县 // this.setData({ // select_county_id: value, // }); // let params = { // province_id: this.data.select_province_id, // city_id: this.data.select_city_id, // county_id: this.data.select_county_id, // } // api.getBasicHospital(params).then(response => {// 请求医院列表】 // this.setData({ // yiyuan_columns: this.formatYiYuan(response), // city_show: false, // city_note: this.getCityNote(selectedOptions), // yiyuan_show: true // }) // }).catch(errors => {console.error(errors); }) // }else{ // this.setData({ // city_show: true // }) // } // }, // getCityNote(selectedOptions){ // let txt = []; // selectedOptions.forEach(item => { // if(item){ // txt.push(item.label); // } // }) // return txt.join("/"); // }, // formatArea(response, p_index, has_children){ // var list = [] // let index = 0; // response.data.forEach(data => { // let area = {}; // area.index = index++; // area.p_index = p_index; // area.type = data.area_type; // area.label = data.area_name; // area.value = data.area_id; // if(has_children){ // area.children = []; // } // list.push(area) // }); // return list; // }, // formatYiYuan(response){ // let list = []; // response.data.forEach(data => { // let hospital = {}; // hospital.text = data.hospital_name; // hospital.value = data.hospital_id; // list.push(hospital) // }); // return list; // }, // formatKeShi(response){ // let list = []; // response.data.forEach(item => { // let data = {}; // data.text = item.department_custom_name; // data.value = item.department_custom_id; // list.push(data) // }); // return list; // }, // formatZhuanChang(response){ // let list = []; // response.data.forEach(item => { // let data = {}; // data.text = item.expertise_name; // data.value = item.expertise_id; // list.push(data) // }); // return list; // }, // onYiYuanShow(e) { // console.log("onYiYuanShow"); // this.setData({ yiyuan_show: true }); // }, // onYiYuanClose(e) { // console.log("onYiYuanClose"); // this.setData({ yiyuan_show: false }); // }, // onYiYuanCancel(event) { // console.log("onYiYuanCancel"); // const { picker, value, index } = event.detail; // Toast(`当前值:${value}, 当前索引:${index}`); // this.setData({ // yiyuan_show: false // }); // }, // onYiYuanConfirm(event) { // console.log("onYiYuanConfirm"); // const { picker, value, index } = event.detail; // console.log(event.detail); // this.setData({ // yiyuan_show: false, // select_yiyuan_id: `${value.value}`, // yiyuan_note: `${value.text}` // }); // }, // onYiYuanChange(event) { // console.log("onYiYuanChange"); // const { picker, value, index } = event.detail; // Toast(`当前值:${value}, 当前索引:${index}`); // }, // onKeshiShow(e) { // console.log("onKeshiShow"); // this.setData({ keshi_show: true }); // }, // onKeshiCancel(event) { // console.log("onKeshiCancel"); // const { picker, value, index } = event.detail; // Toast(`当前值:${value}, 当前索引:${index}`); // this.setData({ keshi_show: false }); // }, // onKeshiConfirm(event) { // console.log("onKeshiConfirm"); // const { picker, value, index } = event.detail; // Toast(`当前值:${value}, 当前索引:${index}`); // this.setData({ // keshi_show: false, // select_keshi_id: `${value.value}`, // keshi_note: `${value.text}`, // }); // }, // onKeshiChange(event) { // console.log("onKeshiChange"); // }, // onKeshiClose(e) { // console.log("onKeshiClose"); // this.setData({ keshi_show: false }); // }, // onZhiChengShow(e) { // console.log("onKeshiShow"); // this.setData({ zhicheng_show: true }); // }, // onZhiChengCancel(event) { // console.log("onKeshiCancel"); // const { picker, value, index } = event.detail; // Toast(`当前值:${value}, 当前索引:${index}`); // this.setData({ zhicheng_show: false }); // }, // onZhiChengConfirm(event) { // console.log("onZhiChengConfirm"); // const { picker, value, index } = event.detail; // Toast(`当前值:${value}, 当前索引:${index}`); // this.setData({ // zhicheng_show: false, // select_zhicheng_id: `${value.value}`, // zhicheng_note: `${value.text}`, // }); // }, // onZhiChengChange(event) { // console.log("onZhiChengChange"); // }, // onZhiChengClose(e) { // console.log("onZhiChengClose"); // this.setData({ zhicheng_show: false }); // }, // onZhuanChangShow(){ // this.setData({ zhuanchang_show: true }); // }, // onZhuanChangVisibleChange(e) { // this.setData({ // zhuanchang_show: e.detail.visible, // }); // }, // onshowJianJieNote(e){ // e.detail // 自定义组件触发事件时提供的 detail 对象 // console.log("onshowJianJieNote"); // }, // onshowShanChangNote(e){ // e.detail // 自定义组件触发事件时提供的 detail 对象 // console.log("onshowShanChangNote"); // }, // onshowZhiYeNote(e){ // e.detail // 自定义组件触发事件时提供的 detail 对象 // console.log("onshowZhiYeNote"); // this.setData({ zhiye_show: true }); // }, // onZhiYeClose(){ // console.log("onZhiYeClose"); // this.setData({ zhiye_show: false }); // }, // onshowZiGeNote(e){ // e.detail // 自定义组件触发事件时提供的 detail 对象 // console.log("onshowZiGeNote"); // this.setData({ zige_show: true }); // }, // onZiGeClose(){ // console.log("onZhiYeClose"); // this.setData({ zige_show: false }); // }, // onshowZhiChengImgNote(e){ // e.detail // 自定义组件触发事件时提供的 detail 对象 // console.log("onshowZhiChengNote"); // this.setData({ zhicheng_img_show: true }); // }, // onZhiChengImgClose(){ // console.log("onZhiChengClose"); // this.setData({ zhicheng_img_show: false }); // }, // getTextAreaVal(e){ // console.log("myindex: ", e); // let textarea_name = e.currentTarget.dataset.textarea_name; // this.setData({ // [textarea_name]: e.detail.value // }) // }, // select_zhuanchang(e){ // console.log(e); // let expertise_name = e.currentTarget.dataset.expertise_name; // let expertise_id = e.currentTarget.dataset.expertise_id; // let is_selected = e.currentTarget.dataset.is_selected; // let index = e.currentTarget.dataset.index; // let data = "zhuanchang_columns["+index+"].is_selected"; // this.setData({[data]: is_selected==1?0:1}) // }, // zhuanchangConfirm(e){ // this.setData({ zhuanchang_show: false }); // }, // zhuanchangConcle(e){ // this.setData({ zhuanchang_show: false }); // }, // addDoctorAuthIden(){ // let params = {}; // if(!this.data.is_avatar){wx.showToast({title: '请上传头像',icon: "error"});return} // params.avatar = this.data.avatar; // if(!this.data.select_county_id){wx.showToast({title: '请选择城市',icon: "error"});return} // if(!this.data.select_yiyuan_id){wx.showToast({title: '请选择医院',icon: "error"});return} // params.hospital_id = this.data.select_yiyuan_id;//医院id // if(!this.data.select_keshi_id){wx.showToast({title: '请选择科室',icon: "error"});return} // params.department_custom_id = this.data.select_keshi_id;//科室id // if(!this.data.custom_keshi){wx.showToast({title: '请输入科室',icon: "error"});return} // params.department_custom_name = this.data.custom_keshi;//自定义科室名称 // if(!this.data.office_phone){wx.showToast({title: '请输入科室电话',icon: "error"});return} // params.department_custom_mobile = this.data.office_phone;//科室电话 // params.doctor_expertise = this.data.zhuanchang_columns.filter(e => e.is_selected == 1 ).map(e => e.expertise_id);//专长 // if(params.doctor_expertise.length == 0){wx.showToast({title: '请选择专长',icon: "error"});return} // if(!this.data.select_zhicheng_id){wx.showToast({title: '请选择职称',icon: "error"});return} // params.doctor_title = this.data.select_zhicheng_id;//职称id // if(!this.data.textarea_jianjie){wx.showToast({title: '请输入简介',icon: "error"});return} // params.brief_introduction = this.data.textarea_jianjie;//简介 // if(!this.data.textarea_shanchang){wx.showToast({title: '请输入擅长',icon: "error"});return} // params.be_good_at = this.data.textarea_shanchang;//擅长 // if(this.data.zhiye_file_list.length == 0){wx.showToast({title: '请上传医师执业证',icon: "error"});return} // params.license_cert = this.data.zhiye_file_list.map(e => e.url);//医师执业证 // if(this.data.zige_file_list.length == 0){wx.showToast({title: '请上传医师资格证',icon: "error"});return} // params.qualification_cert = this.data.zige_file_list.map(e => e.url);//医生资格证 // if(this.data.zhicheng_file_list.length == 0){wx.showToast({title: '请上传职称证',icon: "error"});return} // params.work_cert = this.data.zhicheng_file_list.map(e => e.url);//工作证,职称证 // console.log(params); // api.postDoctorAuthIden(params).then(response => { // console.log(response); // wx.showToast({ // title: '提交成功', // icon: "success" // }) // this.setData({ // iden_auth_status_txt: "审核中", // iden_auth_disabled: true // }) // }).catch(errors => {console.error(errors);}) // } })