<template>
	<div>
		<common @asynCallBack="asynCallBack"></common>
		<top-header :pageTitle="pageTitle"></top-header>

		<div class="mui-content">
			<div class="mui-content-padded vongi-qingjiadt vongi-editme">
				<form class="mui-input-group">
					<div class="mui-input-row">
						<label>姓名</label>
						<span v-text="detail.name"></span>
					</div>
					<div class="mui-input-row">
						<label>手机号码</label>
						<span><a :href="'tel:'+detail.phone" v-text="detail.phone" style="color:#3385FF"></a></span>
					</div>
					<div class="mui-input-row">
						<label>身份证号</label>
						<span v-text="detail.idCard"></span>
					</div>
					<div class="mui-input-row">
						<label>联系地址</label>
						<span v-text="detail.address"></span>
					</div>
				</form>
			</div>
			<div class="mui-content-padded vongi-qingjiadt vongi-editme">
				<form class="mui-input-group">
					<div class="mui-input-row">
						<label>亲属关系</label>
						<span v-text="detail.relationName"></span>
					</div>
				</form>
			</div>
			<div class="mui-content-padded vongi-qingjiadt vongi-editme">
				<form class="mui-input-group">
					<div class="mui-input-row">
						<label>照片</label>
						<span class="vongi-qingjiadt-photo"><img :src="detail.faceImageUrl" /> </span>
					</div>
				</form>
			</div>
			<div class="vongi-btn vongi-login-btn">
				<button class="mui-btn mui-btn-danger" @click="del">
					<span class="iconfont icon-quxiaolianjie"></span>取消关联该亲属
				</button>
			</div>
		</div>

		<loading :visible="isLoading"></loading>
	</div>
</template>

<script>
	import * as API_Relatives from '@/apis/Master/relatives'
	import Common from '$project/components/Common.vue'
	import Loading from '$project/components/Loading.vue'
	import TopHeader from '$project/components/TopHeader.vue'
	import {
		mapGetters,
		mapMutations
	} from 'vuex'
	export default {
		name: 'MasterRelatives',
		components: {
			Common,
			Loading,
			TopHeader,
		},
		data() {
			return {
				pageTitle: '亲属信息',

				isLoading: false,

				popedomId: this.$route.query.popedomId,
				detail: {}
			}
		},
		created() {

		},
		methods: {
			//获取详情
			getInfo() {
				this.isLoading = true;
				API_Relatives.getRelationInfo(this.popedomId).then(response => {
					this.isLoading = false;

					this.detail = response.person;

				}).catch(error => {
					this.isLoading = false;
					mui.toast(error);
				})
			},
			//取消亲属关系
			del() {
				var _this = this;
				var btnArray = ['取消', '解绑'];
				mui.confirm('确认取消关联此亲属？取关后系统将删除该亲属的相关信息，该名亲属将无法以您的亲属身份登录本系统。', '确认取消关联', btnArray, function(e) {
					if (e.index == 1) {
						_this.isLoading = true;
						API_Relatives.delRelation(_this.popedomId).then(response => {
							_this.isLoading = false;

							mui.toast('处理成功');
							_this.$router.go(-1);

						}).catch(error => {
							_this.isLoading = false;
							mui.toast(error);
						})
					}
				});
			},
			asynCallBack() {},
		},
		mounted() {
			//获取详情
			this.getInfo()
		},
		destroyed() {

		},
		computed: {
			...mapGetters({
				openId: 'wx_openid',
				token: 'token',
				person_data: 'person_data',
				person_popedom: 'person_popedom',
			})
		}
	}
</script>

<style scoped src="$project/assets/css/pension.css"></style>
<style scoped src="$project/assets/css/xpwyfyy.css"></style>
<style src="$project/assets/css/iconfont.css"></style>
<style>
</style>
