<template>
	<view class="cnt_wrapper">
		<view class="wrap">
			<view class="p_title">
				<view style="margin-left: 30rpx;">
					<view class="p_name">{{name}}</view>
					<view class="p_number">透析号：{{dialysis_no}}</view>
				</view>

			</view>

			<view class="p_cnt">
				<view class="p_cnt_list">
					<view>性别</view>
					<view>{{form.sex==1 ?'男' : '女'}}</view>
				</view>
				<view class="p_cnt_list">
					<view>身份证号</view>
					<view>{{form.ID}}</view>
				</view>
				<view class="p_cnt_list">
					<view>出生日期</view>
					<view>{{form.birthday}}</view>
				</view>
				<view class="p_cnt_list">
					<view>手机号</view>
					<view>{{form.Mobile}}</view>
				</view>
				<view class="p_cnt_list">
					<view>地址</view>
					<view>{{form.address}}</view>
				</view>
				<!-- <view class="p_cnt_list">
					<view>绑定医院</view>
					<view>{{form.hospital}}</view>
				</view> -->

			</view>

			<!-- <view class="delete_btn" @click="deleteP">
				<button>删除就诊人</button>
			</view> -->
		</view>

	</view>
</template>

<script>
	import { getRecord,getOrg } from '@/api/api.js';
	export default {
		data() {
			return {
				form:{
					sex:'',
					birthday:'',
					ID:'',
					Mobile:'',
					address:'',
					hospital:''
				},
				dialysis_no:'',
				name:'',
				
			}
		},
		onLoad(){
			this.name = this.$store.state.data.userInfo.name
			this.dialysis_no = this.$store.state.data.userInfo.dialysis_no
			this.form={
				sex: this.$store.state.data.userInfo.gender,
				ID: this.$store.state.data.userInfo.id_card_no,
				Mobile: this.$store.state.data.userInfo.phone,
				address: this.$store.state.data.userInfo.home_address,
			}
			let hospital = this.$store.state.data.userInfo.id
			this.getOrg(hospital)
			this.getIdInfo(this.form.ID)
		},
		methods: {
			// 删除就诊人
			// deleteP() {
			// },
			async getOrg(patient_id){
				let params = {
					patient_id:patient_id
				}
				let res = await getOrg(params)
				console.log('zzzzz',res);
				this.form.hospital = res.data.data.orgInfo.org_name
				console.log(this.form);
				// return this.form.hospital
			},
			getIdInfo(cardNo) {
			    var reg = /(^\d{15}$)|(^\d{17}([0-9]|X)$)/; //验证身份证号码的正则
			    if(reg.test(cardNo)){ // 身份证号码是否合法
			        var birthday = "";
			        var gender = "";
			        if (cardNo.length == 15) {
			            var org_birthday = cardNo.substring(6, 12);
			            var org_gender = cardNo.substring(14, 15);
			            birthday = "19" + org_birthday.substring(0, 2) + "-"
			                + org_birthday.substring(2, 4) + "-"
			                + org_birthday.substring(4, 6);
			        } else if (cardNo.length == 18) {
			            var org_birthday = cardNo.substring(6, 14);
			            var org_gender = cardNo.substring(16, 17);
			            birthday = org_birthday.substring(0, 4) + "-"
			                + org_birthday.substring(4, 6) + "-"
			                + org_birthday.substring(6, 8);
			        }
			        this.form.birthday=birthday
			    }else{
			        return false;
			    }
			},

		}
	}
</script>

<style>
	page {
		height: 100%;
		background-color: #f3f3f9;
	}

	.cnt_wrapper {
		margin: 0;
		padding: 0;
	}

	.p_title {
		width: 93vw;
		height: 140rpx;
		display: flex;
		align-items: center;
		margin: 20rpx auto;
		margin-top: 30rpx;
		border-radius: 10rpx;
		background: #fff;
	}

	.p_title .p_name {
		font-weight: bold;
	}

	.p_title .p_number {
		font-size: 24rpx;
		line-height: 50rpx;
		color: #999999;
	}

	.p_cnt {
		width: 93vw;
		margin: 20rpx auto;
		border-radius: 10rpx;
		background: #fff;
	}

	.p_cnt_list {
		height: 60rpx;
		padding: 10rpx 40rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		font-size: 30rpx;
		font-weight: bold;
	}

	.delete_btn {
		width: 93vw;
		margin: 0 auto;

	}

	.delete_btn button {
		background: #fff;
		color: #ff3d71;
		box-shadow: 0px 2px 11px 0px rgba(211, 211, 234, 0.43);
		font-size: 30rpx;
		height: 88rpx;
		line-height: 88rpx;
	}
</style>
