111
This commit is contained in:
@@ -0,0 +1,520 @@
|
||||
// case/pages/improveInfo/improveInfo.js
|
||||
// case/pages/register/register.js
|
||||
import {throttle} from "../../../utils/util"
|
||||
import {hostConfig} from "../../../utils/config"
|
||||
import {getArea,getHospital,getOfficeList,getPosition,needInfo,modifyInfo} from "../../../api/api"
|
||||
import {base64src} from "../../../utils/base64ToImg"
|
||||
const host=hostConfig().host;
|
||||
const app=getApp();
|
||||
Page({
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
showSuccess:false,
|
||||
img_host:app.hostConfig().imghost,
|
||||
showArea:false,
|
||||
areaColumns:[
|
||||
{
|
||||
values: [1,2],
|
||||
className: 'column1',
|
||||
},
|
||||
{
|
||||
values: [3,4],
|
||||
className: 'column2',
|
||||
defaultIndex: 0
|
||||
},
|
||||
],
|
||||
hospitalColumns:[],
|
||||
officeColumns:[],
|
||||
positionColumns:[],
|
||||
showHospital:false,
|
||||
showOffice:false,
|
||||
showPosition:false,
|
||||
fileList:[],
|
||||
disabled:false,
|
||||
county_id:'',
|
||||
hospital_name:'',
|
||||
hospital_uuid:'',
|
||||
mobile:'',
|
||||
name:'',
|
||||
uuid:'',
|
||||
office_name:'',
|
||||
office_uuid:'',
|
||||
password:'',
|
||||
position_uuid:'',
|
||||
certificate:'',
|
||||
certificate_img:'',
|
||||
codeActive:true,
|
||||
msg:'获取验证码',
|
||||
captchaUuid:'',
|
||||
captchaCode:'',
|
||||
loginDevice:5,
|
||||
imgCode:'',
|
||||
sms:'',
|
||||
timer:null,
|
||||
time:59,
|
||||
smsType:1,
|
||||
showCrop:false,
|
||||
width: 250, //宽度
|
||||
height: 250, //高度
|
||||
max_width: 300,
|
||||
max_height: 300,
|
||||
disable_rotate: true, //是否禁用旋转
|
||||
disable_ratio: false, //锁定比例
|
||||
limit_move: true, //是否限制移动
|
||||
},
|
||||
closeCrop(){
|
||||
this.setData({
|
||||
showCrop:false
|
||||
})
|
||||
},
|
||||
submit() {
|
||||
this.setData({
|
||||
showCrop:false
|
||||
})
|
||||
this.cropper.getImg((obj) => {
|
||||
this.uploadImg(obj)
|
||||
});
|
||||
},
|
||||
cropperload(e) {
|
||||
console.log('cropper加载完成');
|
||||
},
|
||||
initCrop(options){
|
||||
|
||||
this.cropper = this.selectComponent("#image-cropper");
|
||||
|
||||
|
||||
|
||||
if(options.imgSrc){
|
||||
this.setData({
|
||||
src: options.imgSrc
|
||||
});
|
||||
}
|
||||
|
||||
// if(!options.imgSrc){
|
||||
// this.cropper.upload(); //上传图片
|
||||
// }
|
||||
},
|
||||
loadimage(e) {
|
||||
this.cropper.imgReset();
|
||||
},
|
||||
onConfirmSuccess(){
|
||||
this.setData({
|
||||
showSuccess:false
|
||||
})
|
||||
app.method.navigateTo({
|
||||
url:"/case/pages/mobileLogin/mobileLogin"
|
||||
})
|
||||
},
|
||||
opeArea(){
|
||||
this.setData({
|
||||
showArea:true
|
||||
})
|
||||
},
|
||||
openOffice(){
|
||||
this.setData({
|
||||
showOffice:true,
|
||||
})
|
||||
},
|
||||
openPosition(){
|
||||
this.setData({
|
||||
showPosition:true,
|
||||
})
|
||||
},
|
||||
onChange(e){
|
||||
const {value} = e.detail;
|
||||
|
||||
const {id}=e.currentTarget.dataset;
|
||||
// console.log(value,id)
|
||||
this.setData({
|
||||
[id]: value
|
||||
});
|
||||
},
|
||||
onChangeArea(event){
|
||||
const { picker, value, index } = event.detail;
|
||||
const provinceId=value[0].id;
|
||||
this.handleGetArea(provinceId)
|
||||
},
|
||||
confirmArea(event){
|
||||
const {value} = event.detail;
|
||||
const countyId=value[1].id;
|
||||
this.setData({
|
||||
county_id:countyId,
|
||||
showArea:false
|
||||
});
|
||||
this.handleGetHospital(countyId)
|
||||
},
|
||||
cancelArea(){
|
||||
this.setData({
|
||||
showArea:false
|
||||
})
|
||||
},
|
||||
confirmHospital(event){
|
||||
let {value}=event.detail;
|
||||
this.setData({
|
||||
showHospital:false,
|
||||
hospital_uuid:value.uuid,
|
||||
hospital_name:value.name
|
||||
})
|
||||
},
|
||||
cancelHospital(){
|
||||
this.setData({
|
||||
showHospital:false
|
||||
})
|
||||
},
|
||||
confirmOffice(event){
|
||||
let {value}=event.detail;
|
||||
|
||||
this.setData({
|
||||
office_name:value.officeName,
|
||||
office_uuid:value.officeUuid,
|
||||
showOffice:false
|
||||
})
|
||||
},
|
||||
cancelOffice(){
|
||||
this.setData({
|
||||
showOffice:false
|
||||
})
|
||||
},
|
||||
confirmPosition(event){
|
||||
let {value}=event.detail;
|
||||
this.setData({
|
||||
position_uuid:value.uuid,
|
||||
position_name:value.name,
|
||||
showPosition:false
|
||||
})
|
||||
},
|
||||
cancelPosition(){
|
||||
this.setData({
|
||||
showPosition:false
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
handleNeedInfo(){
|
||||
let {mobile,positionColumns}=this.data;
|
||||
needInfo(mobile).then(res=>{
|
||||
let {certificate,certificate_img,county_id,hospital_name,hospital_uuid,name,office_name,office_uuid,position_uuid,uuid}=res;
|
||||
let arr= positionColumns.filter((item)=>item.uuid==position_uuid);
|
||||
console.log(arr);
|
||||
this.setData({
|
||||
certificate,
|
||||
county_id,
|
||||
certificate_img,
|
||||
hospital_name,
|
||||
hospital_uuid,
|
||||
name,
|
||||
position_name:arr.length>0?arr[0].name:'',
|
||||
office_name,
|
||||
office_uuid,
|
||||
position_uuid,
|
||||
uuid
|
||||
})
|
||||
})
|
||||
},
|
||||
handleModifyInfo:throttle(function(){
|
||||
let {certificate,certificate_img,county_id,hospital_name,hospital_uuid,name,office_name,office_uuid,position_uuid,uuid}=this.data;
|
||||
if(!(/^[\u4E00-\u9FA5·]{2,20}$/.test(name))){
|
||||
wx.showToast({
|
||||
title: `请输入您的真实姓名`,
|
||||
icon: 'none',
|
||||
});
|
||||
return false;
|
||||
};
|
||||
if(!hospital_uuid){
|
||||
wx.showToast({
|
||||
title: `请选择医院`,
|
||||
icon: 'none',
|
||||
});
|
||||
return false;
|
||||
}
|
||||
if(!office_uuid){
|
||||
wx.showToast({
|
||||
title: `请选择科室`,
|
||||
icon: 'none',
|
||||
});
|
||||
return false;
|
||||
}
|
||||
if(!position_uuid){
|
||||
wx.showToast({
|
||||
title: `请选择职称`,
|
||||
icon: 'none',
|
||||
});
|
||||
return false;
|
||||
}
|
||||
if(!certificate_img){
|
||||
wx.showToast({
|
||||
title: `请上传执业医师资格证或工作胸牌`,
|
||||
icon: 'none',
|
||||
});
|
||||
return false;
|
||||
}
|
||||
modifyInfo({
|
||||
certificate,
|
||||
certificate_img,
|
||||
county_id,
|
||||
hospital_name,
|
||||
hospital_uuid,
|
||||
name,
|
||||
office_name,
|
||||
office_uuid,
|
||||
position_uuid,
|
||||
uuid
|
||||
}).then(res=>{
|
||||
this.setData({
|
||||
showSuccess:true,
|
||||
})
|
||||
})
|
||||
}),
|
||||
handleGetArea(id){
|
||||
getArea({
|
||||
parent:id
|
||||
}).then(res=>{
|
||||
if(id){
|
||||
let obj='areaColumns[1].values';
|
||||
this.setData({
|
||||
[obj]:res
|
||||
})
|
||||
}else{
|
||||
let obj='areaColumns[0].values';
|
||||
this.setData({
|
||||
[obj]:res
|
||||
})
|
||||
this.handleGetArea(res[0].id)
|
||||
}
|
||||
|
||||
}).catch(error=>{
|
||||
console.log(error)
|
||||
})
|
||||
},
|
||||
handleGetHospital(countyId){
|
||||
getHospital(countyId).then(res=>{
|
||||
this.setData({
|
||||
showHospital:true,
|
||||
hospitalColumns:res.concat({uuid:1,name:'其他医院'})
|
||||
})
|
||||
})
|
||||
},
|
||||
handleGetOffice(){
|
||||
getOfficeList({}).then(res=>{
|
||||
this.setData({
|
||||
officeColumns:res
|
||||
})
|
||||
}).catch(error=>{
|
||||
console.log(error)
|
||||
})
|
||||
},
|
||||
handleGetPosition(){
|
||||
getPosition().then(res=>{
|
||||
this.setData({
|
||||
positionColumns:res
|
||||
})
|
||||
this.handleNeedInfo();
|
||||
})
|
||||
},
|
||||
handleSmsRegister:throttle(function(){
|
||||
let {name,password,hospital_uuid,hospital_name,office_name,office_uuid,position_uuid,certificate,certificate_img,county_id}=this.data;
|
||||
if(!(/^[\u4E00-\u9FA5·]{2,20}$/.test(name))){
|
||||
wx.showToast({
|
||||
title: `请输入您的真实姓名`,
|
||||
icon: 'none',
|
||||
});
|
||||
return false;
|
||||
}
|
||||
smsRegister({
|
||||
|
||||
name,
|
||||
hospital_uuid,
|
||||
hospital_name,
|
||||
office_name,
|
||||
office_uuid,
|
||||
county_id,
|
||||
position_uuid,
|
||||
certificate,
|
||||
certificate_img
|
||||
}).then(res=>{
|
||||
this.setData({
|
||||
showSuccess:true,
|
||||
})
|
||||
})
|
||||
}),
|
||||
handleThrottle:throttle(function(){
|
||||
this.getCode()
|
||||
}),
|
||||
handleGetCaptcha(){
|
||||
getCaptcha().then(res=>{
|
||||
base64src(res.captchaBase64Image,(img)=>{
|
||||
this.setData({
|
||||
imgCode:img,
|
||||
captchaUuid:res.captchaUuid
|
||||
})
|
||||
})
|
||||
})
|
||||
},
|
||||
getCode(){
|
||||
if(this.data.disabled)return;
|
||||
let {mobile,captchaCode,captchaUuid,loginDevice,smsType}=this.data;
|
||||
if(!/^1[3456789]\d{9}$/.test(mobile)){
|
||||
wx.showToast({
|
||||
title: `请输入有效的手机号码!`,
|
||||
icon: 'none',
|
||||
});
|
||||
return false;
|
||||
};
|
||||
if(!captchaCode){
|
||||
wx.showToast({
|
||||
title: `图形验证码不能为空`,
|
||||
icon: 'none',
|
||||
});
|
||||
return false;
|
||||
}
|
||||
sendSms({
|
||||
mobile,
|
||||
captchaCode,
|
||||
captchaUuid,
|
||||
smsType,
|
||||
loginDevice
|
||||
}).then((res)=>{
|
||||
let timer=setInterval(() => {
|
||||
if (this.data.time == 0) {
|
||||
clearInterval(this.data.timer);
|
||||
this.setData({
|
||||
time:59,
|
||||
msg:'重新获取验证码',
|
||||
disabled:false,
|
||||
codeActive:true,
|
||||
})
|
||||
} else {
|
||||
let msg= this.data.time + " s 后重新发送";
|
||||
this.setData({
|
||||
disabled:true,
|
||||
msg:msg,
|
||||
codeActive:false,
|
||||
})
|
||||
let time=this.data.time--;
|
||||
this.setData({
|
||||
msg:time + " s 后重新发送"
|
||||
})
|
||||
}
|
||||
}, 1000);
|
||||
|
||||
this.setData({
|
||||
timer:timer
|
||||
})
|
||||
}).catch(()=>{
|
||||
this.handleGetCaptcha();
|
||||
});
|
||||
|
||||
},
|
||||
uploadImg(file){
|
||||
let THIS=this;
|
||||
wx.showLoading({
|
||||
title: '图片上传中',
|
||||
mask: true
|
||||
})
|
||||
|
||||
// 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
|
||||
wx.uploadFile({
|
||||
url: host+'/user/uoloadImg', // 仅为示例,非真实的接口地址
|
||||
filePath: file.url,
|
||||
name: 'file',
|
||||
formData: file,
|
||||
success(res) {
|
||||
let result=JSON.parse(res.data);
|
||||
|
||||
if(result.code==200){
|
||||
wx.hideLoading();
|
||||
THIS.setData({
|
||||
certificate_img:result.data
|
||||
});
|
||||
}else{
|
||||
wx.hideLoading();
|
||||
wx.showToast({
|
||||
title:result.msg,
|
||||
icon:'none'
|
||||
})
|
||||
}
|
||||
|
||||
},
|
||||
complete(res){
|
||||
console.log(res)
|
||||
}
|
||||
});
|
||||
},
|
||||
afterRead(event) {
|
||||
const {
|
||||
file
|
||||
} = event.detail;
|
||||
this.setData({
|
||||
showCrop:true,
|
||||
src:file.url
|
||||
})
|
||||
|
||||
},
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad(options) {
|
||||
if(options.mobile){
|
||||
this.setData({
|
||||
mobile:options.mobile
|
||||
})
|
||||
}
|
||||
//this.handleGetCaptcha();
|
||||
this.handleGetArea('');
|
||||
this.handleGetOffice();
|
||||
this.handleGetPosition();
|
||||
this.initCrop(options);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
// onShareAppMessage() {
|
||||
|
||||
// }
|
||||
})
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"van-overlay": "@vant/weapp/overlay/index",
|
||||
"image-cropper": "../../../components/image-cropper/image-cropper",
|
||||
"dialog":"../../../components/dialog/dialog",
|
||||
"van-popup": "@vant/weapp/popup/index",
|
||||
"van-picker": "@vant/weapp/picker/index",
|
||||
"van-field": "@vant/weapp/field/index",
|
||||
"van-cell": "@vant/weapp/cell/index",
|
||||
"van-button": "@vant/weapp/button/index",
|
||||
"van-image": "@vant/weapp/image/index",
|
||||
"van-uploader": "@vant/weapp/uploader/index",
|
||||
"van-cell-group": "@vant/weapp/cell-group/index"
|
||||
|
||||
},
|
||||
"navigationBarTitleText": "完善信息"
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<!--case/pages/improveInfo/improveInfo.wxml-->
|
||||
<!--case/pages/register/register.wxml-->
|
||||
<view class="page">
|
||||
|
||||
<view >
|
||||
<van-cell-group class="group" >
|
||||
<van-field value="{{ name }}" label="姓名" placeholder="请输入您的真实姓名" input-align="right" placeholder-style="color:#999;font-size:15px" bind:change="onChange" data-id="name" extra-event-params/>
|
||||
<van-field value="{{ hospital_name }}" label="医院" placeholder="请选择医院" right-icon="arrow" placeholder-style="color:#999;font-size:15px"
|
||||
input-align="right" bind:tap="opeArea" readonly/>
|
||||
<van-field value="{{ office_name }}"
|
||||
placeholder-style="color:#999;font-size:15px"bind:tap="openOffice" label="科室" placeholder="请选择科室" right-icon="arrow" input-align="right" readonly />
|
||||
<van-field value="{{ position_name }}"
|
||||
placeholder-style="color:#999;font-size:15px" bind:tap="openPosition" label="职称" placeholder="请选择职称" right-icon="arrow" input-align="right" readonly />
|
||||
<van-field value="{{ certificate }}" placeholder-style="color:#999;font-size:15px" label="执业证号(选填)" placeholder="请输入执业证号" class="myclass" input-align="right" />
|
||||
<!-- <van-field value="{{ value }}" label="执业医师资格证或工作胸牌" placeholder="请输入您的真实姓名" right-icon="arrow" input-align="right" bind:change="onChange" input-align="right" >
|
||||
<view class="right" slot="input">
|
||||
<van-image width="120rpx" height="80rpx" fit="contain" src="https://dev-wx.igandan.com/public/hcpEducation/images/default.png" />
|
||||
</view>
|
||||
</van-field> -->
|
||||
<van-cell title="执业医师资格证或工作胸牌" is-link class="cert">
|
||||
<van-uploader file-list="{{ fileList }}" bind:after-read="afterRead" class="upload"/>
|
||||
<van-image width="120rpx" height="80rpx" fit="contain" src="{{certificate_img?certificate_img:img_host+'/default_register.png'}}" class="cert"/>
|
||||
</van-cell>
|
||||
<view class="next">
|
||||
<van-button type="primary" block bind:tap="handleModifyInfo">提交</van-button>
|
||||
</view>
|
||||
</van-cell-group>
|
||||
</view>
|
||||
</view>
|
||||
<van-popup
|
||||
show="{{ showArea }}"
|
||||
round
|
||||
position="bottom"
|
||||
custom-style="height: 50%"
|
||||
>
|
||||
<van-picker columns="{{ areaColumns }}" value-key="name" bind:change="onChangeArea" title="请选择地区" show-toolbar bind:confirm="confirmArea" bind:cancel="cancelArea"/>
|
||||
</van-popup>
|
||||
<van-popup
|
||||
show="{{ showHospital }}"
|
||||
round
|
||||
position="bottom"
|
||||
custom-style="height: 50%"
|
||||
>
|
||||
<van-picker columns="{{ hospitalColumns }}" value-key="name" title="请选择医院" show-toolbar bind:confirm="confirmHospital" bind:cancel="cancelHospital"/>
|
||||
</van-popup>
|
||||
<van-popup
|
||||
show="{{ showOffice }}"
|
||||
round
|
||||
position="bottom"
|
||||
custom-style="height: 50%"
|
||||
>
|
||||
<van-picker columns="{{ officeColumns }}" value-key="officeName" title="请选择科室" show-toolbar bind:confirm="confirmOffice" bind:cancel="cancelOffice"/>
|
||||
</van-popup>
|
||||
<van-popup
|
||||
show="{{ showPosition }}"
|
||||
round
|
||||
position="bottom"
|
||||
custom-style="height: 50%"
|
||||
>
|
||||
<van-picker columns="{{ positionColumns }}" value-key="name" title="请选择职称" show-toolbar bind:confirm="confirmPosition" bind:cancel="cancelPosition"/>
|
||||
</van-popup>
|
||||
<dialog showDialog="{{showSuccess}}" showCancel="{{false}}" bind:confirm="onConfirmSuccess" title="提示" confirmText="确定" message="完善成功,请等待审核"></dialog>
|
||||
<van-overlay show="{{showCrop}}" >
|
||||
<image-cropper id="image-cropper" bindload="cropperload" bindimageload="loadimage" bindtapcut="clickcut" limit_move="{{limit_move}}" disable_rotate="{{disable_rotate}}" width="{{width}}" height="{{height}}" imgSrc="{{src}}" angle="{{angle}}" disable_width="{{disable_width}}" max_width="{{max_width}}" max_height="{{max_height}}" disable_height="{{disable_height}}" disable_ratio="{{disable_ratio}}"></image-cropper>
|
||||
<view class="buttonbox">
|
||||
<button bindtap='closeCrop' type="default" class="button" size="mini">返回</button>
|
||||
<button bindtap='submit' type="primary" class="button" size="mini">确定</button>
|
||||
</view>
|
||||
</van-overlay>
|
||||
@@ -0,0 +1,84 @@
|
||||
/* case/pages/improveInfo/improveInfo.wxss */
|
||||
/* case/pages/register/register.wxss */
|
||||
.next{
|
||||
margin: 40rpx 20rpx!important;
|
||||
}
|
||||
.prev{
|
||||
margin:-20rpx 20rpx 0!important ;
|
||||
}
|
||||
.van-field__label{
|
||||
white-space: nowrap;
|
||||
}
|
||||
.custom-class .van-cell:last-child{
|
||||
background-color: red;
|
||||
}
|
||||
.van-cell__title{
|
||||
white-space: nowrap;
|
||||
display: flex;
|
||||
color: #646566;
|
||||
align-items: center;
|
||||
}
|
||||
.van-image{
|
||||
margin-top: 10rpx;
|
||||
}
|
||||
.van-cell{
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
.van-field__label,.van-cell__title{
|
||||
position: relative;
|
||||
}
|
||||
.van-field__label::after,.cert .van-cell__title::after{
|
||||
content: "*";
|
||||
color:red;
|
||||
position: absolute;
|
||||
top:12rpx;
|
||||
right:-14rpx;
|
||||
}
|
||||
.cert .van-cell__title::after{
|
||||
top:4rpx;
|
||||
}
|
||||
.myclass .van-field__label::after{
|
||||
content: "";
|
||||
}
|
||||
.upload{
|
||||
opacity:0;
|
||||
position: absolute;
|
||||
z-index:99;
|
||||
}
|
||||
.cert .van-cell{
|
||||
overflow: hidden;
|
||||
}
|
||||
.van-button{
|
||||
border-radius: 10rpx!important;
|
||||
}
|
||||
.imgCode{
|
||||
width:200rpx;
|
||||
height:75.6rpx;
|
||||
}
|
||||
.custom-class{
|
||||
min-height:43.5px !important;
|
||||
}
|
||||
.van-field__label{
|
||||
color:#333!important;
|
||||
padding:12rpx 0;
|
||||
font-size: 15px!important;
|
||||
}
|
||||
.van-cell__title{
|
||||
color:#333!important;
|
||||
font-size: 15px!important;
|
||||
}
|
||||
.buttonbox{
|
||||
position: absolute;
|
||||
z-index:99;
|
||||
display: flex;
|
||||
width:600rpx;
|
||||
left:50%;
|
||||
transform: translateX(-50%);
|
||||
justify-content: space-between;
|
||||
bottom:50rpx;
|
||||
}
|
||||
.van-button--primary{
|
||||
background: linear-gradient(90deg, #377FF7 0%, #51AAFF 100%)!important;
|
||||
border-color:#377FF7!important
|
||||
}
|
||||
Reference in New Issue
Block a user