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

		<div class="mui-content vongi-tell">
			<div class="vongi-center">
				<div class="mui-media-object"><img src="~$project/assets/img/default_face.png" width="50" /></div>
				<h1 v-text="detail.name"></h1>
				<button v-if="detail.urgentStatus" type="button" class="mui-btn  mui-btn-danger mui-btn-outlined">紧急联系人</button>
			</div>
			<div class='flew-sp mui-h1'>
				{{detail.phone}}<a :href="'tel:'+detail.phone" class="iconfont icon-ziyuan1 color55f868"></a>
			</div>
		</div>
		<div class="fyy-footer">
			<ul class="mui-table-view mui-grid-view mui-grid-9">
				<li class="mui-table-view-cell mui-media mui-col-xs-6">
					<router-link :to="{name:'MasterRelativesPhoneSave',query:{'bookId':detail.id}}">
						<span class="mui-icon iconfont icon-xinbaniconshangchuan-"></span>
						<div class="mui-media-body">编辑紧急联系人</div>
					</router-link>
				</li>
				<li class="mui-table-view-cell mui-media mui-col-xs-6">
					<a @click="del">
						<span class="mui-icon iconfont icon-guanbi"></span>
						<div class="mui-media-body">删除紧急联系人</div>
					</a>
				</li>
			</ul>
		</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: 'MasterRelativesPhoneInfo',
		components: {
			Common,
			Loading,
			TopHeader,
		},
		data() {
			return {
				pageTitle: '紧急联系人',

				isLoading: false,

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

		},
		methods: {
			//获取详情
			getInfo() {
				this.isLoading = true;
				API_Relatives.getPhoneNumberInfo(this.bookId).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.delPhoneNumber(_this.bookId).then(response => {
							_this.isLoading = false;

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

						}).catch(error => {
							_this.isLoading = false;
							mui.toast(error);
						})
					}
				});
			},
			asynCallBack() {},
		},
		mounted() {
			//获取详情
			this.getInfo();
			document.body.style.backgroundColor = '#fff';
		},
		destroyed() {
			document.body.style.backgroundColor = '';
		},
		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>
