<template>
	<view class="app">
		<view class="item">
			<view class="itemimgs">
				<image class="picture" src="../../static/user.png" mode=""></image>
			</view>
			<view class="text">
				姓名：{{list.patientName?list.patientName:''}}
			</view>
			<view class="text">
				性别：
				{{list.sex=='MALE'?'男':''}}
				{{list.sex=='FEMALE'?'女':''}}
			</view>
			<view class="text">
				出生日期：
				{{list.birthDate?list.birthDate:''}}
			</view>
			<view class="text">
				身份证号：
				{{list.cardNo?list.cardNo:''}}
			</view>
			<view class="text">
				联系电话：
				{{list.patientPhone?list.patientPhone:''}}
			</view>
			<view class="text">
				家庭住址：
				{{list.address?list.address:''}}
			</view>
		</view>
		<view class="myorder" @click="show= true">
			点击解绑
		</view>
		<u-toast ref="uToast" />
		<u-modal v-model="show" content="是否解除当前用户与微信号的绑定?" @confirm='confirm' :show-cancel-button='true'></u-modal>
	</view>
</template>

<script>
	import {
		getResidentInfoById,
		unbindOpenId
	} from '@/api/personal/index.js'
	import {
		parseTime
	} from '@/api/time.js'
	export default {
		data() {
			return {
				list: {},
				show: false
			};
		},
		onLoad(options) {
			this.info(options.id)
		},
		methods: {
			info(id) {
				getResidentInfoById(uni.getStorageSync('patientId')).then(res => {
					this.list = res.data
				})
			},
			confirm() {
				let obj = {
					phoneNum: uni.getStorageSync('phone'),
					openId: uni.getStorageSync('openid')
				}
				unbindOpenId(obj).then(res => {
					if (res.code == 200) {
						uni.removeStorageSync('patientId');
						uni.removeStorageSync('openid');
						uni.removeStorageSync('phone');
						this.$refs.uToast.show({
							title: res.msg,
							type: 'success',
							duration: '1500',
							back: true
						})
					} else {
						this.$refs.uToast.show({
							title: res.msg,
							type: 'error',
							duration: '1500',
						})
					}
				})
			},
		},
	}
</script>

<style lang="scss">
	page {
		background-color: #F4F5F7;
	}

	.app {
		padding: 0 0 40rpx;

		.myorder {
			padding: 0 30rpx;
			width: 95%;
			height: 80rpx;
			font-size: 35rpx;
			margin: 0 auto;
			color: white;
			text-align: center;
			border-radius: 10rpx;
			background-color: #26A888;
			line-height: 80rpx;
		}

		.itemimgs {
			width: 100%;
			height: 400rpx;
			border-bottom: 1rpx solid #D8D4D4;
			position: relative;

			.picture {
				border-radius: 50%;
				width: 200rpx;
				height: 200rpx;
				position: absolute;
				top: 50%;
				left: 50%;
				transform: translate(-50%, -50%);
			}
		}

		.item {
			background-color: #fff;
			width: 95%;
			margin: 20rpx auto;
			border-radius: 10rpx;
			padding: 30rpx;

			.text {
				padding: 30rpx 0;
				line-height: 46rpx;
				border-bottom: 1rpx solid #D8D4D4;
				font-size: 30rpx;
			}
		}
	}
</style>