<template>
	<view class="main">
		<view class="one">
			<image class="image" :src="user.icon&&user.icon.length>0?user.icon[0].url:config.user_url[0].url" mode="">
			</image>
		</view>
		<view class="two">
			<view class="two_1">
				<view class="left">姓名</view>
				<view class="right textOne">
					<text>{{user.name||'暂无姓名'}}</text>
				</view>
			</view>
			<view class="two_1">
				<view class="left">手机号</view>
				<view class="right textOne">
					<text>{{user.mobile||'暂无手机号'}}</text>
				</view>
			</view>
			<view class="two_1">
				<view class="left">就诊编号/卡号</view>
				<view class="right textOne">
					<text>{{user.card_no||'暂无就诊编号/卡号'}}</text>
				</view>
			</view>
			<view class="two_1">
				<view class="left">性别</view>
				<view class="right textOne">
					<text>{{user.gender||'暂无性别'}}</text>
				</view>
			</view>
			<view class="two_1">
				<view class="left">年龄</view>
				<view class="right textOne">
					<text>{{user.age||'暂无年龄'}}</text>
				</view>
			</view>
			<view class="two_1">
				<view class="left">住址</view>
				<view class="right textOne">
					<text>{{user.address||'暂无住址'}}</text>
				</view>
			</view>
			<view class="two_1">
				<view class="left">紧急联系人</view>
				<view class="right textOne">
					<text>{{user.urgent_name||'暂无紧急联系人'}}</text>
				</view>
			</view>
			<view class="two_1">
				<view class="left">紧急联系人电话</view>
				<view class="right textOne">
					<text>{{user.urgent_mobile||'暂无紧急联系人电话'}}</text>
				</view>
			</view>
			<view class="two_1">
				<view class="left">病例</view>
				<view class="right" @tap="toImage(user.emrs[0].url)">
					<image class="image" :src="user.emrs&&user.emrs.length>0?user.emrs[0].url:''" mode="">
					</image>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				id: '',
				user: {},
				config: {},
			}
		},
		onLoad: async function(e) {
			const that = this;
			that.$set(that, `id`, e && e.id || '');
			await that.searchConfig();
			await that.search();
		},
		methods: {
			searchConfig() {
				const that = this;
				try {
					const res = uni.getStorageSync('config');
					if (res) that.$set(that, `config`, res);
				} catch (e) {}
			},
			// 查询
			async search() {
				const that = this;
				if (that.id) {
					let res = await that.$api(`/patient/${that.id}`, 'GET', {})
					if (res.errcode == '0') {
						that.$set(that, `user`, res.data)
					} else {
						uni.showToast({
							title: res.errmsg,
							icon: 'none'
						});
					}
				}
			},
			// 预览图片
			toImage(e) {
				uni.previewImage({
					urls: [e]
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.main {
		.one {
			display: flex;
			justify-content: center;
			padding: 2vw;

			.image {
				width: 25vw;
				height: 25vw;
				border-radius: 5px;
			}
		}

		.two {
			padding: 2vw;

			.two_1 {
				display: flex;
				justify-content: space-between;
				padding: 4vw;
				border-bottom: 1px solid var(--f9Color);
				font-size: var(--font14Size);
				color: var(--f69Color);

				.right {
					text-align: right;
					width: 60vw;

					.image {
						width: 20vw;
						height: 20vw;
						border-radius: 5px;
					}
				}
			}
		}
	}
</style>