<template>
	<view class="mb-5">
		<view class="p-3" v-if="userData.id">
			<view class="d-flex">
				<view class="w-100 font-bold">
					<view class="centerY  mb-3">
						<view class="bule_line" style="height: 26rpx;"></view>
						<text class="font-bold text-dark ml-2 fs-18 line-height1">基本信息</text>
					</view>
					<view class="centerY border-bottom mb-2 fs-14" style="color: #818181;">
						<view class="w-50 mb-2">
							<view class="mb-2">
								姓名：{{userData.username||''}}
							</view>
							<view class="">
								出生日期：{{userData.birthday||''}}
							</view>
						</view>
						<view class="w-50 mb-2">
							<view class="mb-2">
								年龄：{{$mf.getIDCardInfo(userData.idCard).age||'0'}}
							</view>
							<view class="">
								性别：{{userData.sex==1?'男':'女'}}
							</view>
						</view>
					</view>
					<view class="centerY mb-2 fs-14" style="color: #818181;">
						<view class="w-50 mb-2">
							<view class=" mb-2">
								文化程度：{{userData.culture ||''}}
							</view>
							<view class="">
								职业：{{userData.occupation||''}}
							</view>
						</view>
						<view class="w-50 mb-2">
							<view class="mb-2">
								民族：{{userData.nation||''}}
							</view>
							<view class="">
								婚姻状况：{{userData.marriage||'未婚'}}
							</view>
						</view>
					</view>
				</view>
				<view style="position: absolute;right: 20rpx;top: 20rpx;width: 100rpx;">
					<view class="picbox">
						<image v-if="userData.sex==1" src="@/static/img/defult/head1.png" mode="widthFix" class="picimg">
						</image>
						<image v-if="userData.sex==2" src="@/static/img/defult/head2.png" mode="widthFix" class="picimg">
						</image>
					</view>
				</view>
			</view>
			<view class="bg-white px-3 fs-14  font-bold" style="border-radius: 16rpx;color: #818181;">
				<view class="d-flex border-bottom py-2">
					<view class="centerY space-nowrap" style="align-items: flex-start;">
						<image src="@/static/img/userinfo/sb.png" mode="widthFix" style="width: 40rpx;"></image>
						<span class="ml-1"> 社保卡号：</span>
					</view>
					<view class="">
						{{userData.socialInsurance||''}}
					</view>
				</view>
				<view class="d-flex border-bottom py-2">
					<view class="centerY space-nowrap" style="align-items: flex-start;">
						<image src="@/static/img/userinfo/sfz.png" mode="widthFix" style="width: 40rpx;"></image>
						<span class="ml-1"> 身份证号：</span>
					</view>
					<view class="">{{userData.idCard||''}}
					</view>
				</view>
				<view class="d-flex border-bottom py-2">
					<view class="centerY space-nowrap" style="align-items: flex-start;">
						<image src="@/static/img/userinfo/dh.png" mode="widthFix" style="width: 40rpx;"></image>
						<span class="ml-1"> 手机号码：</span>
					</view>
					<view class="">
						{{userData.phone||''}}
					</view>
				</view>
				<view class="d-flex py-2">
					<view class="centerY space-nowrap" style="align-items: flex-start;">
						<image src="@/static/img/userinfo/jt.png" mode="widthFix" style="width: 40rpx;"></image>
						<span class="ml-1"> 家庭住址：</span>
					</view>
					<view class="">
						{{userData.city + userData.area + userData.town + userData.village +userData.addressDetail}}
					</view>
				</view>
			</view>
			<view class="d-flex mt-2  font-bold" style="color: #818181;">
				<view class="py-1 mt-1 fs-14 space-nowrap">
					医保类型：
				</view>
				<view class="fs-10 w-100">
					<span class="mr-1 text-center py-1 mt-2 d-inline-block w-20"
						:style="{borderRadius:'50rpx',background:userData.medicalInsuranceType==item.value?'#1890FF':'#EBEBEB',color:userData.medicalInsuranceType==item.value?'#fff':'#A4A4A4'}"
						v-for="(item,index) in MEDICAL_INSURANCE_TYPE">
						{{item.label}}
					</span>
				</view>
			</view>
			<view class="d-flex mt-2 font-bold" style="color: #818181;">
				<view class="mt-1 py-1 fs-14 space-nowrap font-bold">
					慢病类型：
				</view>
				<view class="fs-10 w-100">
					<span class="mr-1 text-center py-1 mt-2 d-inline-block w-20"
						:style="{borderRadius:'50rpx',background:userData.chronicDiseaseType==item.value?'#1890FF':'#EBEBEB',color:userData.chronicDiseaseType==item.value?'#fff':'#A4A4A4'}"
						v-for="(item,index) in CHRONIC_DISEASE_TYPE">
						{{item.label}}
					</span>
				</view>
			</view>
			<view class="centerY">
				<view class="d-flex mt-2 font-bold w-50" style="color: #818181;">
					<view class="mt-1 py-1 fs-14 space-nowrap font-bold">
						糖尿病病龄：
					</view>
					<view class="fs-10">
						<span class="mr-1 text-center py-1 mt-2 d-inline-block px-3"
							:style="{borderRadius:'50rpx',background:'#1890FF',color:'#fff'}">
							{{userData.tnbIllTime
						? (
						    (new Date().getTime() - new Date(userData.tnbIllTime).getTime()) /
						    31536000000
						  ).toFixed(0)
						: ''}}年
						</span>
					</view>
				</view>
				<view class="d-flex mt-2 font-bold w-50" style="color: #818181;" v-if="
				              userData.chronicDiseaseType == 1 ||
				              userData.chronicDiseaseType == 3
				            ">
					<view class="mt-1 py-1 fs-14 space-nowrap font-bold">
						高血压病龄：
					</view>
					<view class="fs-10">
						<span class="mr-1 text-center py-1 mt-2 d-inline-block px-3"
							:style="{borderRadius:'50rpx',background:'#1890FF',color:'#fff'}">
							{{userData.gxyIllTime
				    ? (
				        (new Date().getTime() - new Date(userData.gxyIllTime).getTime()) /
				        31536000000
				      ).toFixed(0)
				    : ''}}年
						</span>
					</view>
				</view>
			</view>
			<view class=" mt-3 bg-white p-3 fs-14  font-bold" style="border-radius: 16rpx;">
				<view class="centerY mb-2">
					<view class="bule_line" style="height: 26rpx;margin-top: -2rpx;"></view>
					<text class="font-bold text-dark ml-2 fs-16 line-height1">其他信息</text>
				</view>
				<view class=" border-bottom pt-2">
					<view class="w-50 d-inline-block mb-2">
						<view class="centerY">
							<view class="w-40">
								<view class="picbox">
									<image class="picimg" src="@/static/img/userinfo/jbs.png" mode=""></image>
								</view>
							</view>
							<view class="w-60 ml-1">
								<view class="fs-16">
									疾病史
								</view>
								<view class="fs-12" style="color: #818181;"
									v-if="!userData.diseaseHistory?true:userData.diseaseHistory&&JSON.parse(userData.diseaseHistory).length==0">
									无
								</view>
								<uni-tooltip :content="String(JSON.parse(userData.diseaseHistory))">
									<view class="text-view2 fs-12" style="color: #818181;">
										<span class=""
											v-for="(item,index) in JSON.parse(userData.diseaseHistory)">{{item}}；</span>
									</view>
								</uni-tooltip>
							</view>
						</view>
					</view>

					<view class="w-50 d-inline-block mb-2">
						<view class="centerY">
							<view class="w-40">
								<view class="picbox">
									<image class="picimg" src="@/static/img/userinfo/jzs.png" mode=""></image>
								</view>
							</view>
							<view class="w-60 ml-1">
								<view class="fs-16">
									家族史
								</view>
								<view class="fs-12" style="color: #818181;"
									v-if="!userData.familyHistory?true:userData.familyHistory&&JSON.parse(userData.familyHistory).length==0">
									无
								</view>
								<uni-tooltip
									:content="String(userData.familyHistory&&JSON.parse(userData.familyHistory))">
									<view class="text-view2 fs-12" style="color: #818181;">
										<span class=""
											v-for="(item,index) in userData.familyHistory&&JSON.parse(userData.familyHistory)">{{item}}；</span>
									</view>
								</uni-tooltip>
							</view>

						</view>
					</view>
					<view class="w-50 d-inline-block mb-2" v-if="userData.saltiness">
						<view class="centerY">
							<view class="w-40">
								<view class="picbox">
									<image class="picimg" src="@/static/img/userinfo/xd.png" mode=""></image>
								</view>
							</view>
							<view class="w-60 ml-1">
								<view class="fs-16">
									咸淡情况
								</view>
								<view class="fs-12" style="color: #818181;" v-if="userData.saltiness">
									无
								</view>
								<view class="fs-12" style="color: #818181;">
									{{userData.saltiness}}
								</view>
							</view>
						</view>
					</view>
					<view class="w-50 d-inline-block mb-2">
						<view class="centerY">
							<view class="w-40">
								<view class="picbox">
									<image class="picimg" src="@/static/img/userinfo/hb.png" mode=""></image>
								</view>
							</view>
							<view class="w-60 ml-1">
								<view class="fs-16">
									合并症
								</view>
								<view class="fs-12" style="color: #818181;"
									v-if="!userData.andComplication?true:userData.andComplication&&JSON.parse(userData.andComplication).length==0">
									无
								</view>
								<uni-tooltip :content="String(JSON.parse(userData.andComplication))">
									<view class=" text-view2 fs-12" style="color: #818181;">
										<span class=""
											v-for="(item,index) in JSON.parse(userData.andComplication)">{{item}}；</span>
									</view>
								</uni-tooltip>
							</view>
						</view>
					</view>
				</view>
				<view class="mt-2">
					<view class="fs-14 font-bold text-dark">
						并发症
					</view>
					<view class="fs-10 w-100">
						<span class="mr-1 text-center py-1 px-2 mt-2 d-inline-block"
							:style="{borderRadius:'50rpx',background:'#E8E8E8',color:'#868687',border:'1px solid #E8E8E8'}"
							v-for="(item,index) in JSON.parse(userData.complication)">
							{{item}}
						</span>
					</view>
				</view>
			</view>

		</view>
	</view>
</template>

<script>
	import {
		CULTURE,
		MEDICAL_INSURANCE_TYPE,
		CHRONIC_DISEASE_TYPE,
		DISEASE_HISTORY,
	} from '@/static/js/defult_value.js'
	export default {
		data() {
			return {
				MEDICAL_INSURANCE_TYPE,
				CHRONIC_DISEASE_TYPE,
				userData: {}
			};
		},
		onLoad() {
			this.getuserinfo()
		},
		onPullDownRefresh() {
			this.getuserinfo()
		},
		methods: {
			async getuserinfo() {
				uni.showLoading({
					title: '加载中'
				});
				let idCard = uni.getStorageSync('idCard')
				let {
					data,
					code
				} = await this.$api.getUserInfo({
					idCard
				})
				if (code == 0) {
					uni.setStorageSync('userData', data || {})
					this.userData = data || {}
					uni.hideLoading();
					uni.stopPullDownRefresh()
				} else {
					uni.hideLoading();
				}
			}
		}
	}
</script>

<style lang="scss">
	page {
		background: #F5F9FF;
	}
</style>
