<template>
    <div class="monitor-container">
        <div class="monitor-list-container">
            <div class="monitor-list-title">
                费县森林防火视频监控
            </div>
            <div class="monitor-list-scroll-container">
                <div class="monitor-class-name" @click="monitorShow = !monitorShow">
                    <i class="el-icon el-icon-s-grid"></i>
                    费县森林防火视频监控({{ monitorList.length }})
                    <i class="el-icon  el-icon-arrow-down" style="float:right;margin-top:16px;"></i>
                </div>
                <div v-show="monitorShow">
                    <div class="monitor-item" v-for="(item,index) in monitorList" :key="index" >
                        <i class="el-icon el-icon-video-camera"></i>
                        {{ item.cameraname }}
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>

import axios  from 'axios';
import { getMethodCommon } from '../../../api/common';

import 'video.js/dist/video-js.css'
import videojs from "video.js";
import "videojs-contrib-hls";

export default{
    components:{

    },
    data(){
        return {
            diviceIds:"550810a41e024bc884fcbd750529b3ce,d0442e062c6c4c5982ee6fe0b5935126,9039ca8768b7412aae7a6a46b6dec3a5",
            ids:["550810a41e024bc884fcbd750529b3ce","d0442e062c6c4c5982ee6fe0b5935126","9039ca8768b7412aae7a6a46b6dec3a5"],
            videoUrl:"http://221.2.83.254:7012/live/37130100181328000390.m3u8",
            aspect:"16:9",
            fluent:true,
            playArrays:[],
            monitorShow:false,
            monitor2Show:true,
            monitorList:[],
            monitorList2:[],
            player:null,
        }
    },
    created(){
        this.getHKmonitorlist();
        this.getYJmonitorlist();
    }, 
    mounted() {
        let _this = this;
        setTimeout(()=>{
            
        },5000)
    },
 
    methods:{
        getVideo() {
            videojs("myvideo",{
                bigPlayButton: false,
                textTrackDisplay: false,
                posterImage: true,
                errorDisplay: false,controlBar: true
            },
            function() {
                this.play();
            });
        },
        playVideo(item,index){
            if(this.playArrays.find((it,idx)=>{
                return it == "http://221.2.83.254:7012/live/"+item.jkdgbidzlkjg+".m3u8"
            })){
                this.$message({
                    type:"error",
                    message:"已经添加至播放列表"
                })
                return;
            }
            if(this.playArrays.length>=4){
                this.playArrays.shift();
            }
            this.playArrays.push("http://221.2.83.254:7012/live/"+item.jkdgbidzlkjg+".m3u8")
        },

        // 获取海康监控列表
        getHKmonitorlist(){
            axios({
                method:"get",
                url:"http://221.2.83.254:9007/geoserver/ksp/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=ksp%3Amonitornest&maxFeatures=10000&outputFormat=application%2Fjson",
            }).then(res=>{
                res.data.features.forEach((item,index)=>{
                    let obj = item.properties;
                    this.monitorList.push(obj);
                    if(index<=3){
                        this.playArrays.push("http://221.2.83.254:7012/live/"+item.jkdgbidzlkjg+".m3u8")
                    }
                })
                
            })
        },
        // 市应急局监控设备
        getYJmonitorlist(){
            getMethodCommon("/YingJiJu/LoadCameraInfo?county=费县&pageIndex=1&pageSize=999").then(res=>{
                if(res.code ==  200){
                    this.monitorList2 = res.data;

                }
            })
        },

    }
}
</script>

<style scoped>

.monitor-container{
    width:100%;
    height:100%;
    background:#30645eaa;
    padding:15px;
    background-image: url(/img/biaohui.png);
    background-size:100% 100%;
}

.monitor-list-container{
    width:240px;
    height:100%;
    float:left;
}

.monitor-list-title{
    width:100%;
    height:60px;
    font-size:20px;
    text-indent:15px;
    color:#fff;
    cursor:pointer;
}

.monitor-list-scroll-container{
    width: calc( 100% - 12px);
    height: calc(100% - 70px);
    overflow-y: auto;
    padding-right:12px;
}

.monitor-class-name{
    width:100%;
    height:42px;
    line-height:42px;
    color:#fff;
}
.monitor-item{
    width:100%;
    height:24px;
    line-height:24px;
    color:#cfcfcf;
    font-size:12px;
    text-indent: 4px;
    overflow: hidden;
    cursor: pointer;
}
.monitor-item:hover{
    background:#30645e;
}

.video-container{
    width: calc( 100% - 240px);
    float:right;
    height:100%;
}

.layout-container{
    width:100%;
    height:50px;
}

::-webkit-scrollbar-track,
::-webkit-scrollbar-thumb {
  border: 0;
}

::-webkit-scrollbar {
  height: 10px;
  width: 10px;
  background: transparent;
  border-radius: 5px;
}

::-webkit-scrollbar-thumb {
  padding-top: 100px;
  -webkit-box-shadow: inset 1px 1px 1px rgba(0, 0, 0, 0.25);
  background-color: rgba(0, 0, 0, 0.4);
  min-height: 28px;
  border-radius: 4px;
  background-clip: padding-box;
}

::-webkit-scrollbar-track,
::-webkit-scrollbar-thumb {
  border: 0;
}

::-webkit-scrollbar-thumb:hover {
    -webkit-box-shadow: inset 1px 1px 0 rgba(0, 0, 0, 0.1),
    inset -1px -1px 0 rgba(0, 0, 0, 0.07);
  background-color: #797979;
}

::-webkit-scrollbar-thumb:active {
  -webkit-box-shadow: inset 1px 1px 3px rgba(0, 0, 0, 0.35);
  background-color: rgba(0, 0, 0, 0.5);
}
</style>