<template>
	<view>
		<view class="grxx">
			<view class="grxxItem">
				<view class="sfzhm">
					<view class="uni-list-cell-left">
						姓名
					</view>
					<view class="uni-list-cell-db">
						<input type="text" placeholder="按姓名查询" v-model="listData.name" @input="xmcx"/>
					</view>
				</view>
				<view class="sfzhm">
					<view class="uni-list-cell-left">
						手机号
					</view>
					<view class="uni-list-cell-db">
						<input type="text" placeholder="按手机号查询" v-model="listData.phone" @input="shcx"/>
					</view>
				</view>
			</view>
		</view>
		<view class="grxx">
			<view class="grxxItem" v-for="(item,index) in messageList" :key="index">
				<view class="ygxm">
					<text>姓名：{{item.name}}</text>
					<text>{{item.testDate}}</text>
				</view>
				<view class="sfzhm">
					<text>手机号：</text>
					<text>{{item.phone}}</text>
				</view>
				<view class="sfzhm">
					<text>核酸状态：</text>
					<text>{{item.outTimeType}}</text>
				</view>
			</view>
		</view>
		<view class="ydd" v-if="isReachBottom">
			~<没有了>~
		</view>
	</view>
</template>

<script>
	import {
		postRequest,
		getRequest
	} from '../../api/api.js'
	export default {
		data() {
			return {
				//为true时，停止下拉加载
				isReachBottom: false,
				//总list
				messageList: [],
				listData: {
					name:'',
					phone:'',
					current: 1,
					orders: [{
						asc: true,
						column: ""
					}],
					size: 10,
				},
				total: 0
			}
		},
		onLoad() {
			this.getList();
		},
		onReachBottom() {
			if (this.isReachBottom) {
				return
			} else {
				this.listData.current++;
				let list = this.messageList;
			    this.getList();
			}
		},
		methods: {
			xmcx(e){
				this.listData.name=e.target.value
				this.listData.current=1;
				this.messageList=[]
				console.log(this.messageList)
				this.getList();
			},
			shcx(e){
				this.listData.phone=e.target.value
				this.listData.current=1;
				this.messageList=[]
				this.getList();
			},
			getList() {
				console.log(this.messageList)
				postRequest('/covidDailyRegister/findTimeOutUser', this.listData).then(res => {
					if (res.code == '200' && res.data != null) {
						if (this.messageList.length <= 0) {
							this.messageList = res.data.records;
							this.total = res.data.total;
						} else {
							let list = []
							list = res.data.records;
							if (list.length > 0) {
								list.forEach(item => {
									this.messageList.push(item)
								})
							}
						}
						if (this.listData.current == res.data.pages) {
							this.isReachBottom = true
						}
					}
				})
			}
		}
	}
</script>

<style>
	.grxx {
		padding: 5%;
	}

	.grxxItem .sfzhm {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 10px;
		font-size: 84%;
		color: #999999;
		position: relative;
	}

	.grxxItem .mdd {
		justify-content: left;
	}

	.grxxItem .mdd input {
		width: 70%;
		margin-left: 10px;
	}

	.hxx {
		position: absolute;
		color: red;
		left: 3px;
		top: 25%;
	}


	.grxxItem {
		margin: 14px 0;
		border-radius: 5px;
		overflow: hidden;
		box-shadow: 0px 2px 15px 3px rgba(0, 0, 0, 0.1);
	}

	.grxxItem .ygxm {
		padding: 10px;
		background-color: #caccceab;
		display: flex;
		justify-content: space-between;
	}

	.grxxItem .ygxm text:last-of-type {
		color: #8d8888;
		font-size: 14px;
	}

	.ydd {
		text-align: center;
		padding: 5px;
		color: #cac5c5;
	}
</style>
