<template>
	<view>
		<view class="onekeep" v-for="(item,index) in keeplist" :key="item.id">
			<view class="onekeeplabel" @click="optionShow(index)">
				<text>{{item.poleGroupName}}</text>
			</view>
			<view class="twokeep" v-for="(item2,index2) in item.cameraList" :key="item2.id" v-show="item.show">
				<text>{{item2.poleGroupName}}</text>
				<button type="primary" @click="lookVedio(index,index2)">查看</button>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		direct
	} from '../api/Supervisory/Supervisory.js'
	export default {
		data() {
			return {
				keeplist: []
			};
		},
		methods: {
			lookVedio(index,index2){
				uni.navigateTo({
					url:'/pages/Supervisory_keep/Supervisory_keep?index=' + index + '&index2=' + index2,
				})
			},
			optionShow(index){
				var that = this
				var keeplist = that.keeplist
				keeplist[index].show == true ? keeplist[index].show = false : keeplist[index].show = true
				that.keeplist = keeplist
			}
		},
		onLoad() {
			direct().then(res => {
				if (res.code == 200) {
					var keeplist = res.data
					for(let arr of keeplist){
						arr.show = false
					}
					this.keeplist = keeplist
				}
			})
		},
		onShow() {
			if(this.keeplist.length == 0){
				direct().then(res => {
					if (res.code == 200) {
						var keeplist = res.data
						for(let arr of keeplist){
							arr.show = false
						}
						this.keeplist = keeplist
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.onekeep{
		margin-bottom: 4rpx;
		width: 750rpx;
	}
	
	.onekeeplabel{
		width: 750rpx;
		height: 110rpx;
		background-color: #333333;
		color: #ffffff;
		position: relative;
		text{
			font-size: 36rpx;
			position: absolute;
			left: 20rpx;
			top: 37rpx;
		}
	}
	
	.twokeep{
		width: 750rpx;
		height: 100rpx;
		position: relative;
		border-bottom: 1px royalblue solid;
		text{
			position: absolute;
			top: 34rpx;
			font-size: 32rpx;
			left: 30rpx;
		}
		button{
			width: 140rpx;
			height: 80rpx;
			position: absolute;
			font-size: 32rpx;
			top: 10rpx;
			right: 30rpx;
			display: flex;
			align-items: center;
			justify-content: center;
		}
	}
</style>
