<template>
	<view style="height: 100%;">
		<u-empty marginTop="100rpx" :show="list.length == 0&&status == 'nomore'" mode="list" text="暂无数据"></u-empty>
		<u-list @scrolltolower="scrolltolower" style="height: calc(100% - 29rpx);padding-top:29rpx">
			<u-list-item v-for="(item, index) in list" :key="index">
				<view class="whiteCard">
					<view class="row1">
						摄像头：{{item.cameraNames}}
					</view>
					<view class="row2">
						查询时间：{{item.queryTime}}
					</view>
					<view class="row3">
						<view class="">
							<text>开始时间：</text>{{item.startTime}}
						</view>
						<view class="">
							<text>结束时间：</text>{{item.endTime}}
						</view>
						<view class="type">
							<text>分片类型：<text style="color: #333;">{{item.split ? "小时" : "天"}}</text></text>
							<view class="peopleNum">
								<image src="@/static/image/peopleNum.png" mode="aspectFill"></image>
								<text>总人数：{{item.total}}</text>
							</view>
						</view>
					</view>
					<view class="bottom">
						<view class="btn" @click="NAV_TO('./detail',item)">
							<image src="@/static/image/see.png" mode="aspectFill"></image>
							<text>分片详情</text>
						</view>
					</view>
				</view>
			</u-list-item>
			<u-loadmore :status="status" />
		</u-list>
	</view>
</template>
<script>
	import {
		page
	} from '@/api/work/passengerFlow.js'
	export default {
		data() {
			return {
				list: [],
				isLoading: false,
				status: 'loadmore', //loading正在加载 loadmore加载更多 nomore没有更多了
				page: {
					pageNum: 1,
					pageSize: 10,
				},
			}
		},
		methods: {
			scrolltolower() {
				this.loadmore()
			},
			loadmore() {
				if (this.status != 'loadmore') return
				this.status = 'loading'
				page({
					...this.page,
				}).then(res => {
					if(res.code != 200)return
					this.list = this.list.concat(res.data.list)
					// 获取到的总条数>=接口总条数
					if (this.list.length >= res.data.total) {
						this.status = 'nomore'
					} else {
						this.status = 'loadmore'
					}
				})
			},
			refresh() {
				this.status = 'loadmore'
				this.list = []
				this.page.page = 1
				this.loadmore()
			},
			pullDownRefresh() {
				this.refresh()
			}
		},
		onLoad() {
			this.loadmore()
		},
		onPullDownRefresh(){
			uni.stopPullDownRefresh()
			this.refresh()
		}
	}
</script>

<style lang="scss" scoped>
	.addBtn{
		width: 140rpx;
		height: 140rpx;
		position: fixed;
		right: 15rpx;
		bottom: 160rpx;
	}
	.whiteCard {
		background-color: #fff;
		border-radius: 18rpx;
		margin: 14rpx 28rpx;
		padding: 30rpx;
		padding-bottom: 24rpx;
		color: #333333;

		.row1 {
			font-size: 32rpx;
			font-weight: 700;
		}

		.row2 {
			font-size: 26rpx;
			margin-top: 14rpx;
		}
		
		.row3{
			background-color: #F2F8FF;
			border-radius: 16rpx;
			font-size: 26rpx;
			padding: 18rpx 24rpx;
			line-height: 48rpx;
			margin-top: 18rpx;
			text{
				color: #777777;
			}
			.type{
				display: flex;
				justify-content: space-between;
				
				.peopleNum {
					uni-image {
						width: 34rpx;
						height: 34rpx;
						position: relative;
						top: 8rpx;
						margin-right: 10rpx;
					}
				
					uni-text {
						color: #2388FF;
					}
				}
			}
		}

		.bottom {
			display: flex;
			border-top: 1rpx solid rgba(0, 0, 0, 0.1);
			margin-top: 24rpx;
			padding-top: 24rpx;
			position: relative;

			.btn {
				width: 100%;
				display: flex;
				align-items: center;
				justify-content: center;

				uni-image {
					width: 34rpx;
					height: 34rpx;
					margin-right: 6rpx;
				}

				uni-text {
					font-size: 28rpx;
				}
			}
		}
	}
</style>