<template>
	<view>
		<view class="list">
			<view class="message-bubble-received" v-for="(item, index) in list" :key="index" @click="detail(item)">
				<view class="title">
					<text class="icon">&#xe813;</text>
					<text>{{ item.templateName }}</text>
				</view>
				<view class="desc">{{ item.op }}</view>
				<view class="desc">
					<text>{{ item.createTime }}</text>
					<text class="look">查看详情</text>
				</view>
			</view>
			<view class="loading" v-if="loadMore"><u-loadmore :status="loadMore ? 'loading' : 'nomore'" /></view>
			<u-empty v-if="!loadMore && list.length == 0"></u-empty>
		</view>
		<u-popup :show="show" round="15" mode="center" :closeable="true" :customStyle="{ width: '95%' }" @close="show = false">
			<view class="popup">
				<view class="mtt">{{ item.templateName }}</view>
				<view class="item">
					<text class="tt">科室名称</text>
					<text class="la">{{ item.deptName }}</text>
				</view>
				<view class="item">
					<text class="tt">医生姓名</text>
					<text class="la">{{ item.doctorName }}</text>
				</view>
				<view class="item">
					<text class="tt">复诊内容</text>
					<text class="la">{{ item.op }}</text>
				</view>
				<view class="item">
					<text class="tt">提醒日期</text>
					<text class="la">{{ item.createTime }}</text>
				</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
export default {
	data() {
		return {
			list: [],
			param: { pageNum: 1, pageSize: 10, type: 0 },
			loadMore: true,
			show: false,
			item: {}
		};
	},
	onLoad(e) {
		this.getData();
	},
	methods: {
		getData() {
			this.http.request({
				url: '/app/follow/list',
				data: this.param,
				loading: 'false',
				success: (res) => {
					this.loadMore = res.data.pages > this.param.pageNum ? true : false;
					this.list.push(...res.data.rows);
				}
			});
		},
		detail(item) {
			this.item = item;
			this.show = true;
			//患者已查看
			if (item.state == 0) {
				this.http.request({
					url: '/app/follow/read/' + item.id,
					method: 'POST',
					data: this.item,
					success: (res) => {
						item.state = 1;
					}
				});
			}
		},
		//刷新数据
		refresh() {
			this.loadMore = true;
			this.param.pageNum = 1;
			this.list = [];
			this.getData();
		}
	},
	//下拉刷新
	onPullDownRefresh() {
		setTimeout(() => {
			this.refresh();
			uni.stopPullDownRefresh();
		}, 1000);
	},
	//上拉加载
	onReachBottom() {
		if (this.loadMore) {
			this.param.pageNum++;
			this.getData();
		}
	}
};
</script>

<style lang="scss">
.list {
	padding: 10px 12px;
	.message-bubble-received {
		.title {
			font-size: 16px;
			font-weight: bold;
			.icon {
				padding-right: 3px;
			}
		}
		.desc {
			font-size: 13px;
			padding-top: 10px;
			color: $font-c;
			.look {
				float: right;
				margin-top: 0px;
				color: $main-color;
			}
		}
	}
}
</style>
