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

		<div class="mui-content margin60">
			<div class="vongi-jy-list flew-sp">
				<div class="vongi-wordcard flew-items">
					<div class="mui-media-object mui-pull-left ">
					<img :src="info.faceImageUrl" width="50" /></div>
					<div class="mui-media-body">
						<h3>{{info.name}}</h3>
						<p class='mui-ellipsis mui-h4'>年龄：{{info.age}} · 性别：{{info.gender}}</p>
					</div>
				</div>
				<div class="vongi-center">
					<span class="iconfont icon-xinbaniconshangchuan- pink"></span>
					<div class="mui-media-body mui-h5" @click="edit()">编辑</div>
				</div>
			</div>
			<!--<div class="vongi-examineInfo vongi-center">
				<img src="~$project/assets/img/no.png" width="40%" />
				<p>暂无就医记录</p>
			</div>-->
			<NullList :remark="'笑口常开，无病无灾'" v-if="!recordList.length"></NullList>

			<ul class="mui-table-view vongi-jy-ul">
				<li class="mui-table-view-cell"  v-for="mod in recordList">
					<a class="mui-navigate-right" @click="add(mod.id)" >
						<div class="mui-media-body">
							{{mod.hospitalTime}}
							<h4 class='mui-ellipsis'>{{mod.pathogeny}}</h4>
						</div>
						<span>{{mod.hospitalName}}</span>
					</a>
				</li>

			</ul>
		</div>
		<div class="fyy-footer">
			<div class="bindfyy-btn"><button type="submit" class="mui-btn mui-btn-pink " @click="add('')">新增就医记录</button></div>
		</div>
				 <loading :visible="isLoading"></loading>

</div>
</template>


<script>
	import * as API from '@/apis/Master/hospital'
	import Common from '$project/components/Common.vue'
	import Loading from '$project/components/Loading.vue'
	import TopHeader from '$project/components/TopHeader.vue'
	import isReachBottom from '$project/utils/isReachBottom'
	import NullList from '$project/components/NullList.vue'
	import {

		currentTimeStamp,
		parseUnixTime
	} from '$project/utils'
	import {
		mapGetters,
		mapMutations
	} from 'vuex'
	export default {
		name: 'MasterHospital',
		components: {
			Common,
			Loading,
			TopHeader,NullList
		},
		data() {
			return {
				pageTitle: '就医记录',

				rightLink: {
					show: true,
					icon: 'icon-baobiao',
					style: 'font-size:14px',
					title: '账单记录'
				},
				isLoading: false,
                info:{
                faceImageUrl:''
                },
				listForm: {
					pageIndex: 1,
					pageSize: 20,
 					totalPage: 1,
 					status:10
 				},
				recordList: [],

			}
		},
		created() {
 		},
		methods: {
	        //右上角点击事件
			edit() {
				this.$router.push({
					name: 'MasterHospitalArchives',
					query: {
 					}
				})
			},
			add(id){

			    this.$router.push({
            			name: 'MasterHospitalForm',
            			query: {
            			    id:id
             			}
            	})
			},

            getInfo() {
                API.getElderInfo().then(res => {
                    this.info=res;



            	}).catch(error => {
             					mui.toast(error);
            	})
            },
			//获取列表
			getList() {
				this.isLoading = true;
				API.pageList(this.listForm).then(res => {
					var response=res;
					if (response) {
						if (this.listForm.pageIndex == 1) {
							this.recordList = response.data;
							this.listForm.pageIndex = response.pageNumber;
							this.listForm.totalPage = response.totalPage;
						} else {
							this.recordList = [
								...this.recordList,
								...response.data
							];
						}
					}
					this.listForm.pageIndex++;
					this.isLoading = false;
				}).catch(error => {
					this.isLoading = false;
					mui.toast(error);
				})
			},
			//下拉事件
			handleScrool() {
				if (isReachBottom()) {
					console.log('到达底部')
					if (this.listForm.pageIndex <= this.listForm.totalPage && this.isLoading == false) {
						this.getList();
					} else {
						return;
					}
				}
			},

			asynCallBack() {

			},
		},
		mounted() {
			this.getInfo();
            this.getList();
			//监控下拉加载事件
			var _this = this;
			window.addEventListener('scroll', _this.handleScrool);
		},
		destroyed() {
			//销毁监听事件
			var _this = this;
			window.removeEventListener('scroll', _this.handleScrool);
		},
		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>
