<template>
	<view style="height: 100%;">
		<view class="topBox">
			<SelectRadio v-model="search.departCalss" placeholder="请选择摄像头" :options="[{value:1,label:'走廊尽头(海康)'},{value:2,label:'厨房(海康)'},{value:3,label:'走廊尽头(海康)'},{value:4,label:'厨房(海康)'}]" />
		</view>
		<u-empty marginTop="100rpx" :show="false" mode="list" text="暂无数据"></u-empty>
		<u-list @scrolltolower="scrolltolower" style="height: calc(100% - 150rpx);">
			<u-list-item v-for="(item, index) in list" :key="index">
				<u-checkbox v-if="isManage" :name="item.name" shape="circle" label=""></u-checkbox>
				<view :class="{whiteCard:true,active:checkboxValue.includes(item.name)}">
					<view class="left">
						<view class="row1">
							教室（海康）
						</view>
						<view class="row2">
							<view class="">
								持续时间：20
							</view>
							<view class="">
								相似度：0.5
							</view>
						</view>
					</view>
					<view class="right" v-show="!isManage">
						<view class="btn" @click="NAV_TO('./detail')">
							<view>
								<image src="@/static/image/seeBlue.png" mode="aspectFill"></image>
							</view>
							<text>查看</text>
						</view>
					</view>
				</view>
			</u-list-item>
			<u-loadmore :status="status" />
		</u-list>
	</view>
</template>

<script>
	import SelectRadio from "@/components/selectRadio.vue"
	export default {
		components: {
			SelectRadio
		},
		data() {
			return {
				list: [{
					name: 1
				}, {
					name: 2
				}, {
					name: 3
				}, {
					name: 4
				}, {
					name: 5
				}, {
					name: 6
				}, {
					name: 7
				}, {
					name: 8
				}, {
					name: 9
				}],
				isLoading: false,
				status: 'loadmore', //loading正在加载 loadmore加载更多 nomore没有更多了
				search: {
					class: '',
				},
				page: {
					size: 8,
					page: 8,
				},
				checkboxValue: [],
				isManage: false,
			}
		},
		methods: {
			scrolltolower() {
				this.loadmore()
			},
			loadmore() {
				if (this.status != 'loadmore') return
				this.status = 'loading'
				setTimeout(() => {
					for (let i = 0; i < 1; i++) {
						this.list.push({}, {}, {}, {}, {}, {})
					}
					// 获取到的总条数>=接口总条数 || 接口总条数为0
					if (this.list.length >= 14) {
						this.status = 'nomore'
					} else {
						this.status = 'loadmore'
					}
				}, 2000)
			},
			refresh() {
				this.status = 'loadmore'
				this.list = []
				this.page.page = 1
				this.loadmore()
			},
			manageClick() {
				this.checkboxValue = []
				this.isManage = this.isManage ? false : true
			},
			radioChange(e) {
				if (e) {
					let ids = this.list.map(e => e.name)
					this.checkboxValue = ids
				} else {
					this.checkboxValue = []
				}
			},
			pullDownRefresh() {
				this.refresh()
			}
		},
		onLoad() {
			this.loadmore()
		},
	}
</script>

<style lang="scss" scoped>

	.topBox {
		padding: 26rpx 30rpx;
	}

	.u-list-item {
		display: flex;
		align-items: center;
		flex-direction: unset;
		margin: 12rpx 30rpx;

		&:first-child {
			margin-top: 0rpx;
		}

		.whiteCard {
			flex: 1;

			&.active {
				border: 1rpx solid #2388FF;
				background-color: #F2F8FF;
			}
		}

		.u-checkbox {
			margin-right: 12rpx;
		}
	}

	.whiteCard {
		background-color: #fff;
		border-radius: 18rpx;
		padding: 30rpx;
		color: #333333;
		display: flex;
		.left{
			width: 76%;
		}
		.row1 {
			font-size: 32rpx;
			font-weight: 700;
		}

		.row2 {
			font-size: 26rpx;
			margin-top: 24rpx;
			display: flex;
			justify-content: space-between;
		}

		.right {
			display: flex;
			justify-content: right;
			flex: 1;
			padding-top: 12rpx;
			.btn {
				text-align: center;

				uni-image {
					width: 40rpx;
					height: 40rpx;
				}

				uni-text {
					font-size: 26rpx;
					color: #2388FF;
					position: relative;
					bottom: 12rpx;
				}
			}
		}
	}
</style>