<template>
	<view class="app">
		<view class="title">
			<view class="left">
			</view>
			<view class="right">
				基本信息
			</view>
		</view>
		<view class="label">
			<view class="text">
				<view class="name">
					{{userInfo.sickName}}
					<text v-if="userInfo.sickSex == 1">男</text><text v-else>女</text><text>丨</text><text
						v-if="userInfo.nation == 1">汉族</text><text v-else>少数民族</text>
				</view>
				<view class="marriage">
					<text v-if="userInfo.marriageStatus == 1">未婚</text>
					<text v-if="userInfo.marriageStatus == 2">已婚</text>
					<text v-if="userInfo.marriageStatus == 3">丧偶</text>
					<text v-if="userInfo.marriageStatus == 4">离婚</text>
					<text v-if="userInfo.marriageStatus == 5">未说明的婚姻状况</text>
				</view>
				<view class="id">
					{{userInfo.identityCardNo}}
				</view>
				<view class="id">
					行为积分：{{score}}
				</view>
			</view>
		</view>
		<view class="information">
			<view class="p1">
				<view class="p1left">
					血型：
				</view>
				<text v-if="userInfo.bloodType == 1">A型</text>
				<text v-if="userInfo.bloodType == 2">B型</text>
				<text v-if="userInfo.bloodType == 3">O型</text>
				<text v-if="userInfo.bloodType == 4">AB型</text>
			</view>
			<view class="p1">
				<view class="p1left">
					RH：
				</view>
				<text v-if="userInfo.bloodRh == 1">阴性</text>
				<text v-if="userInfo.bloodRh == 2">阳性</text>
				<text v-else>不详</text>
			</view>
			<view class="p1">
				<view class="p1left">
					职业：
				</view>
				<text>{{occupation[userInfo.occupation]}}</text>
			</view>
			<view class="p1">
				<view class="p1left">
					文化程度：
				</view>
				<text>{{edu[userInfo.education]}}</text>
			</view>
			<view class="p1">
				<view class="p1left">
					常住类型：
				</view>
				<text>{{residenceType[userInfo.residenceType]}}</text>
			</view>
			<view class="p1">
				<view class="p1left">
					出生日期：
				</view>
				<text>{{userInfo.birthday}}</text>
			</view>
			<view class="p1">
				<view class="p1left">
					本人电话：
				</view>
				<text>{{userInfo.sickPhone}}</text>
			</view>
			<view class="p1">
				<view class="p1left">
					现住地址：
				</view>
				<text>{{userInfo.sickAddress}}</text>
			</view>
			<view class="p1">
				<view class="p1left">
					医疗费用支付方式：
				</view>
				<text>{{payment[userInfo.payment]}}</text>
			</view>
		</view>

		<view class="title">
			<view class="left">
			</view>
			<view class="right">
				药物过敏史
			</view>
		</view>
		<view class="allergy">
			<text>{{allergy[userInfo.allergyHistory]}}</text>
		</view>

		<view class="title">
			<view class="left">
			</view>
			<view class="right">
				暴露史
			</view>
		</view>
		<view class="allergy">
			<text>{{exposure[userInfo.exposureHistory]}}</text>
		</view>

		<view class="title">
			<view class="left">
			</view>
			<view class="right">
				既往史
			</view>
		</view>
		<view class="allergy">
			<view class="p1">
				<view class="p1left">
					疾病史：
				</view>
				<text v-if="userInfo.diseaseHistory != '13'">{{disease[userInfo.diseaseHistory]}}</text>
				<text v-else>{{userInfo.otherDiseaseContent}}</text>
			</view>
			<view class="p1">
				<view class="p1left">
					手术史：
				</view>
				<text v-if="userInfo.existSurgeryHistory == 2">无</text>
				<text v-else>{{userInfo.surgeryList}}</text>
			</view>
			<view class="p1">
				<view class="p1left">
					外伤史：
				</view>
				<text v-if="userInfo.existTraumaHistory == 2">无</text>
				<text v-else>{{userInfo.traumaList}}</text>
			</view>
			<view class="p1">
				<view class="p1left">
					输血史：
				</view>
				<text v-if="userInfo.existTransfusionHistory == 2">无</text>
				<text>{{userInfo.transfusionList}}</text>
			</view>
		</view>

		<view class="title">
			<view class="left">
			</view>
			<view class="right">
				家族史
			</view>
		</view>
		<view class="allergy">
			<view class="p1">
				<view class="p1left">
					父亲：
				</view>
				<text v-if="userInfo.familyHistoryFather == '12'">{{userInfo.fatherOtherContent}}</text>
				<text
					v-if="userInfo.familyHistoryFather && userInfo.familyHistoryFather != '12'">{{familyDisease[userInfo.familyHistoryFather]}}</text>
				<text v-if="!userInfo.familyHistoryFather">无</text>
			</view>
			<view class="p1">
				<view class="p1left">
					母亲：
				</view>
				<text v-if="userInfo.familyHistoryMother == '12'">{{userInfo.motherOtherContent}}</text>
				<text
					v-if="userInfo.familyHistoryMother && userInfo.familyHistoryMother != '12'">{{familyDisease[userInfo.familyHistoryMother]}}</text>
				<text v-if="!userInfo.familyHistoryMother">无</text>
			</view>
			<view class="p1">
				<view class="p1left">
					兄弟姐们：
				</view>
				<text v-if="userInfo.familyHistoryBrothers == '12'">{{userInfo.brotherOtherContent}}</text>
				<text
					v-if="userInfo.familyHistoryBrothers && userInfo.familyHistoryBrothers != '12'">{{familyDisease[userInfo.familyHistoryBrothers]}}</text>
				<text v-if="!userInfo.familyHistoryBrothers">无</text>
			</view>
			<view class="p1">
				<view class="p1left">
					子女：
				</view>
				<text v-if="userInfo.familyHistoryChildren == '12'">{{userInfo.childrenOtherContent}}</text>
				<text
					v-if="userInfo.familyHistoryChildren && userInfo.familyHistoryChildren != '12'">{{familyDisease[userInfo.familyHistoryChildren]}}</text>
				<text v-if="!userInfo.familyHistoryChildren">无</text>
			</view>
		</view>

		<view class="title">
			<view class="left">
			</view>
			<view class="right">
				遗传病史
			</view>
		</view>
		<view class="allergy">
			<text v-if="userInfo.existGeneticDisease == 2">无</text>
			<text
				v-if="userInfo.existGeneticDisease && userInfo.existGeneticDisease != 2">{{userInfo.geneticDiseaseName}}</text>
		</view>

		<view class="title">
			<view class="left">
			</view>
			<view class="right">
				残疾情况
			</view>
		</view>
		<view class="allergy">
			<text v-if="userInfo.disability && userInfo.disability != '8'">{{disability[userInfo.disability]}}</text>
			<text v-if="!userInfo.disability">无残疾</text>
			<text v-if="userInfo.disability == '8'">{{userInfo.disabilityOtherContent}}</text>
		</view>

		<view class="title">
			<view class="left">
			</view>
			<view class="right">
				生活环境
			</view>
		</view>
		<view class="allergy">
			<view class="p1">
				<view class="p1left">
					饮水：
				</view>
				<text>{{liveDrinkingWater[userInfo.liveDrinkingWater]}}</text>
			</view>
			<view class="p1">
				<view class="p1left">
					厕所：
				</view>
				<text>{{liveToilet[userInfo.liveToilet]}}</text>
			</view>
			<view class="p1">
				<view class="p1left">
					禽畜栏：
				</view>
				<text>{{liveLivestock[userInfo.liveLivestock]}}</text>
			</view>
			<view class="p1">
				<view class="p1left">
					燃料类型：
				</view>
				<text>{{liveFuelType[userInfo.liveFuelType]}}</text>
			</view>
			<view class="p1">
				<view class="p1left">
					厨房排风设施：
				</view>
				<text>{{liveExhaust[userInfo.liveExhaust]}}</text>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getUserInfo
	} from "@/api/pagesC/Healthrecords/index.js"
	import {
		PageData
	} from './config/config.js'
	import {
		scoretotal
	} from '@/api/pagesB/Behaviorpoints/index.js'
	export default {
		data() {
			return {
				userInfo: '',
				...PageData,
				score: '',
			};
		},
		onLoad() {
			getUserInfo(uni.getStorageSync('userinfo').cardNo).then(res => {
				if (!res.data || res.data.length == 0) {
					uni.showModal({
						title: '提示',
						content: '暂无相关数据',
						showCancel: false,
						success(res) {
							if (res.confirm) {
								uni.navigateBack({
									delta: 1
								})
							}
						}
					})
					return
				}
				res.data.surgeryList = []
				res.data.traumaList = []
				res.data.transfusionList = []
				if (res.data.surgeryHistory) {
					this.resultFormat(res.data.surgeryHistory, res.data.surgeryList)
				}
				if (res.data.traumaHistory) {
					this.resultFormat(res.data.traumaHistory, res.data.traumaList)
				}
				if (res.data.transfusionHistory) {
					this.resultFormat(res.data.transfusionHistory, res.data.transfusionList)
				}
				this.userInfo = res.data
			})
			this.scoreinfo();
		},
		methods: {
			scoreinfo() {
				scoretotal(uni.getStorageSync('userinfo').cardNo).then(res => {
					this.score = res.data
				})
			},
			resultFormat(list, mylist) {
				if (list.length > 0) {
					list.map(item => {
						return mylist.push(item.name).toString()
					})
				}
			}
		}
	}
</script>

<style lang="scss">
	.app {
		background-color: #f6f6f6;

		.allergy {
			width: 92%;
			margin: 0 auto;
			background-color: #ffffff;
			border-radius: 10rpx;
			padding: 20rpx 0 20rpx 25rpx;

			text {
				display: block;
				font-size: 32rpx;
				line-height: 60rpx;
				letter-spacing: 1rpx;
				color: #333333;
			}

			.p1 {
				display: flex;
				font-size: 26rpx;
				line-height: 80rpx;
				letter-spacing: 1rpx;
				color: #666666;

				.p1left {
					width: 38%;
				}

				text {
					font-size: 28rpx;
					line-height: 80rpx;
					letter-spacing: 1rpx;
					color: #333333;
				}
			}
		}

		.information {
			width: 92%;
			margin: 0 auto;
			background-color: #ffffff;
			border-radius: 0rpx 0rpx 20rpx 20rpx;
			padding-left: 25rpx;

			.p2 {
				border-top: 1rpx solid #f0f1f6;
				font-size: 28rpx;
				line-height: 100rpx;

				letter-spacing: 1rpx;
				color: #333333;
				display: flex;

				.p2left {
					width: 40%;
				}
			}

			.p1 {
				display: flex;
				font-size: 26rpx;
				line-height: 80rpx;
				letter-spacing: 1rpx;
				color: #666666;

				.p1left {
					width: 38%;
				}

				text {
					font-size: 28rpx;
					line-height: 80rpx;
					letter-spacing: 1rpx;
					color: #333333;
				}
			}
		}

		.title {
			display: flex;
			padding: 30rpx 0 30rpx 20rpx;
			font-size: 30rpx;

			.right {
				line-height: 34rpx;
				padding-left: 10rpx;
				color: #666666;
			}

			.left {
				width: 8rpx;
				height: 32rpx;
				background-color: #55d0df;
				border-radius: 4rpx;
			}
		}

		.label {
			background: url(../images/zu112x.png) no-repeat;
			width: 92%;
			margin: 0 auto;
			padding-left: 24rpx;
			border-radius: 20rpx 20rpx 0 0;
			position: relative;
			height: 280rpx;

			.text {
				padding: 40rpx 0 0 25rpx;

				.name {
					font-size: 42rpx;
					line-height: 40rpx;
					color: #ffffff;

					text:nth-child(2) {
						padding: 0;
					}

					text {
						font-size: 28rpx;
						line-height: 40rpx;
						color: #ffffff;
						padding: 0 20rpx;
					}
				}

				.marriage {
					font-size: 26rpx;
					line-height: 20rpx;
					letter-spacing: 2rpx;
					color: #ffffff;
					padding-top: 20rpx;
				}

				.id {
					font-size: 32rpx;
					line-height: 40rpx;
					letter-spacing: 2rpx;
					color: #ffffff;
					opacity: 0.85;
					padding-top: 20rpx;
				}
			}
		}
	}
</style>