<template>
	<view>
		<block v-if="list.length > 0">
			<view class="title-bar">
				<view style="width: 66upx;">进/出</view>
				<view style="width: 190upx;text-align: center;">出入时间</view>
				<view style="width: 168upx;">小区名称</view>
				<view style="width: 168upx;">单元名称</view>
				<view style="width: 70upx;">体温</view>
			</view>
			<block v-for="(item, index) in list" :key="index">
				<view class="record" :class="index % 2 == 0 ? 'bg-gray':''">
					<view style="width: 28upx;">
						<block v-if="item.isOut == 1">进</block>
						<block v-else>出</block>
					</view>
					<view style="width: 190upx;">{{cutTime(item.accessDate)}}</view>
					<view style="width: 200upx;">{{item.residentialName}}</view>
					<view style="width: 168upx;">{{item.unitName}}</view>
					<view style="width: 70upx;">
						<block v-if="$isEmpty(item.temperature)">-</block>
						<block v-else>{{item.temperature}}</block>
					</view>
				</view>
			</block>
			<view style="height: 80rpx;" v-if="status">
				<u-divider bgColor="#f1f1f1;"  height="80">到底了</u-divider>
			</view>
		</block>
		<block v-else>
			<DtEmpty type="1" wrapBgColor="#fff"></DtEmpty>
		</block>
	</view>
</template>

<script>
	var app = getApp();
	import DtEmpty from '@/comps/dt_empty.vue';
	export default {
		components: {
			DtEmpty
		},
		data() {
			return {
				list: [], //出入记录
				page: {
					current: 1,
					size:30,
				},
				status: false,
			}
		},
		onLoad() {
			this.getTravelRecord();
		},
		onReachBottom() {
			if (this.list.length < this.page.current * this.page.size) {
				this.status = true;
			} else {
				this.page.current += 1;
				this.getTravelRecord();
			}
		},
		methods: {
			getTravelRecord() {
				let _this = this;
				let data = {};
				data.page = this.page;
				data.memberId = app.globalData.member.id;
				let operation = 'accessRecords/getAccessRecordPage';
				app.globalData.postRequest(data, operation, function (res) {
				  if (res.data.code != 200) {
				    app.globalData.oneFailHint(res.data.msg, function () {
				      uni.switchTab({
				      	url:"../wode"
				      })
				    });
				  }
					_this.list = [..._this.list,...res.data.data.records];
				});
			},
			cutTime(str) {
				return str.substring(5, str.length);
			},
		}
	}
</script>
<style>
	page {
		background-color: #fff;
	}
</style>
<style lang="scss" scoped>
	.title-bar {
		display: flex;
		line-height: 80upx;
		border-top: #CCC 1upx solid;
		justify-content: space-around;

	}
	.record {
		display: flex;
		justify-content: space-around;
		line-height: 80upx;
		text-align: center;
	}
</style>
