<template>
	<view class="page">
		<u-navbar :title="title" :border-bottom="false" :background="bgc" title-color='#000' title-size='36'
			:title-bold='true' height='45' id="navbar">
		</u-navbar>
		<view class="listvideo" v-if="flag">
			<view class="list_item" v-for="(item,index) in list" :key="index">
				<video :src="item.videoStream"></video>
			</view>
		</view>
		<view class="" v-else>
			<view class="no_cont">
				<view class="img">
					<image src="https://api.ccttiot.com/smartmeter/img/static/us7oiRxHLVwqu8plEy3o" mode=""></image>
				</view>
				<view class="txt">
					当前还没有添加视频监控哦
				</view>
			</view>
			<view class="btn" @click="addApiary">
				添加视频监控
			</view>
		</view>
		<view class="btn" v-if="flag" @click="addApiary">
			添加视频监控
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				bgc: {
					backgroundColor: " #F4FAF8",
				},
				title: "视频监控",
				apiaryId: '',
				list: [],
				pagesum: 1,
				pagesize: 10,
				flag: true,
				total: ''
			}
		},
		onLoad(option) {
			this.apiaryId = option.apiaryId
		},
		onShow() {
			this.getlist()
		},
		methods: {
			getlist() {
				let data = {
					pageNum: this.pagesum,
					pageSize: this.pagesize,
					apiaryId: this.apiaryId
				}
				this.$u.get(`/farm/video/list`, data).then(res => {
					if (res.code == 200) {
						this.total = res.total
						if (this.total >= 1) {
							this.list = res.rows
							this.flag = true
						} else {
							this.flag = false
						}
					}
				})
			},
			addApiary() {
				uni.navigateTo({
					url: '/pages/Apiary/addVadio?apiaryId=' + this.apiaryId
				})
			}

		}
	}
</script>

<style lang="scss">
	page {
		background-color: #F4FAF8;
	}

	.page {
		// position: relative;
		width: 750rpx;

		.listvideo {
			padding: 0 34rpx;
			box-sizing: border-box;
			margin-top: 56rpx;

			.list_item {
				width: 682rpx;
				height: 388rpx;
				border-radius: 28rpx 28rpx 28rpx 28rpx;
				overflow: hidden;
				margin-top: 20rpx;

				video {
					width: 100%;
					height: 100%;
				}
			}
		}

		.btn {
			margin: 86rpx auto;
			display: flex;
			align-items: center;
			justify-content: center;
			width: 432rpx;
			height: 88rpx;
			background: #FFCC25;
			border-radius: 20rpx 20rpx 20rpx 20rpx;
			font-weight: 500;
			font-size: 36rpx;
			color: #FFFFFF;
		}

		.no_cont {
			margin: 152rpx auto 0;
			width: 432rpx;

			.img {
				image {
					width: 432rpx;
					height: 432rpx;
				}
			}

			.txt {
				margin-top: 50rpx;
				width: 100%;
				text-align: center;
				font-weight: 500;
				font-size: 32rpx;
				color: #808080;
			}
		}



	}
</style>