<template>
		<view class="content">
			<view class="info-item">
				<view class="label">姓名</view>
				<view class="right">
					{{user.doctorName||'-'}}
				</view>
			</view>
			<view class="info-item">
			     <view class="label">账号身份</view>
			     <view class="right">
			       <template v-if="user.accountType">
			         {{ user.accountType === '1' ? '医生' : user.accountType === '2' ? '药剂师' : '-' }}
			       </template>
			       <template v-else>-</template>
			     </view>
			   </view>
			<view class="info-item">
				<view class="label">是否认证</view>
				<view class="right">{{user.status==1?'是':'否'}}</view>
			</view>
			<view class="info-item">
				<view class="label">手机号</view>
				<view class="right" v-if="user.mobile!=null">{{user.mobile}}</view>
			</view>
			    <view class="info-item">
			      <view class="label">职称</view>
			      <view class="right">{{ user.jobTitle || '-' }}</view>
			    </view>
			    <view class="info-item">
			      <view class="label">科室</view>
			      <view class="right">{{ user.department || '-' }}</view>
			    </view>
			    <view class="info-item">
			      <view class="label">机构</view>
			      <view class="right">{{ user.institution || '-' }}</view>
			    </view>
				<view class="info-item">
				  <view class="label">公司名称</view>
				  <view class="right">{{ user.companyName || '-' }}</view>
				</view>
			    <view class="info-item">
			      <view class="label">开户银行</view>
			      <view class="right">{{ user.bankName || '-' }}</view>
			    </view>
				<view class="info-item">
				  <view class="label">银行卡号</view>
				  <view class="right">{{ user.idCard ? formatBankCard(user.idCard) : '-' }}</view>
				</view>
				<view class="info-item">
				  <view class="label">执业证</view>
				  <view class="right">
					  <image class="w300 h150" :src="user.licenseImage" mode="aspectFill"></image>
				  </view>
				</view>
				<view class="info-item">
				  <view class="label">职称证/工牌</view>
				  <view class="right">
					  <image class="w300 h150" :src="user.titleCertImage" mode="aspectFill"></image>
				  </view>
				</view>
		</view>
</template>

<script>
	import {getUserInfo,editUser} from '@/api/user'
	export default {
		data() {
			return {
				user: null 
			}
		},
		onLoad() {
			this.getUserInfo()
		},
		methods: {
			 formatBankCard(cardNo) {
			      if (!cardNo || cardNo.length < 8) return cardNo;
			      const prefix = cardNo.substring(0, 4);
			      const suffix = cardNo.substring(cardNo.length - 4);
			      return `${prefix}****${suffix}`;
			    },
			bindblur(e) {
				this.user.nickname = e.detail.value; // 获取微信昵称
			},
			bindinput(e){
				this.user.nickname = e.detail.value; //这里要注意如果只用blur方法的话用户在输入玩昵称后直接点击保存按钮，会出现修改不成功的情况。
			},
			onChooseAvatar(e){
				let {
					avatarUrl
				} = e.detail;
				uni.uploadFile({
					url: uni.getStorageSync('requestPath')+'/app/common/uploadOSS', //仅为示例，非真实的接口地址
					filePath: avatarUrl,
					name: 'file',
					formData: {
						'user': 'test'  // 上传附带参数
					},
					success: (uploadFileRes) => {
						this.user.avatar =JSON.parse(uploadFileRes.data).url
					}
				});
			},
			getUserInfo(){
				getUserInfo().then(
					res => {
						if(res.code==200){
							this.user=res.data;
						}else{
							uni.showToast({
								icon:'none',
								title: "请求失败",
							});
						}
					},
					rej => {}
				);
			}
			 
		}
	}
</script>

<style lang="scss" scoped>
	.content{
		// padding-top: 20rpx;
	}
	.info-item{
		min-height: 104upx;
		background: #FFFFFF;
		padding: 0 30upx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		border-bottom: 1px solid #F5F6FA;
		&:last-child{
			border-bottom: none;
		}
		.label{
			font-size: 30upx;
			font-family: PingFang SC;
			font-weight: 400;
			color: #0F1826;
		}
		.right{
			display: flex;
			align-items: center;
			justify-content: center;
			position: relative;
			.wx-head{
				position: absolute;
				width: 80upx;
				height: 80upx;
				opacity: 0;
			}
			.text{
				font-size: 30upx;
				font-family: PingFang SC;
				font-weight: 400;
				color: #0F1826;
			}
			.head{
				border-radius: 50%;
				width: 80upx;
				height: 80upx;
			}
			.input{
				text-align: right;
				font-size: 30upx;
				font-family: PingFang SC;
				font-weight: 400;
				color: #0F1826;
			}
			image{
				padding: 20rpx 0;
			}
		}
		 
	}
	.btn-box{
		margin-top: 20rpx;
		height: 120upx;
		padding: 0 30upx;
		display: flex;
		align-items: center;
		justify-content: center;
		.sub-btn{
			width: 100%;
			height: 88upx;
			line-height: 88upx;
			text-align: center;
			font-size: 30upx;
			font-family: PingFang SC;
			font-weight: bold;
			color: #FFFFFF;
			background: #0bb3f2;
			border-radius: 44upx;
		}
	}
</style>
