Newer
Older
securityFront / src / views / alarm / alarmMonitor.vue
wangxitong on 26 Jan 2021 1 KB bug4-12
<template>
  <div>
    <el-row>
      <!--<el-col :span="6">-->
        <!--&lt;!&ndash;<video-tree @click="handleCameraClicked"/>&ndash;&gt;-->
      <!--</el-col>-->

      <el-col :span="18" :offset="3">
        <web-play ref="webCtrl" />
      </el-col>
    </el-row>
  </div>
</template>

<script>
// import VideoTree from './videoTree'
import WebPlay from './webPlay'
import { getDetailDevice } from '@/api/device'
export default {
  name: 'VideoMonitor',
  components: { WebPlay },
  data() {
    return {
      camera:{
        ip:'',
        port:'',
        username:'',
        password:''
      }
    }
  },
  mounted() {

  },
  activated() {
    if (this.$route.query && this.$route.query.id) {
      const id = this.$route.query.id
      getDetailDevice(id).then(response => {
          if (response.code === 200) {
            console.log(response.data)
            this.camera.ip = response.data.ip
            this.camera.port = response.data.port
            this.camera.username = response.data.username
            this.camera.password = response.data.password
            this.handleCamera()
          }
      })
    }
  },
  methods: {
    handleCamera(){
      if (typeof this.camera.ip === 'undefined' || this.camera.ip === '') {
        console.log('ip is null')
        return false
      }
      if (typeof this.camera.port === 'undefined' || this.camera.port === '') {
        console.log('port is null')
        return false
      }else{
        this.camera.ip += (':'+ this.camera.port)
      }
      if (typeof this.camera.username === 'undefined' || this.camera.username === '') {
        console.log('username is null')
        return false
      }
      if (typeof this.camera.password === 'undefined' || this.camera.password === '') {
        console.log('password is null')
        return false
      }

      // 开始预览
      this.$refs.webCtrl.$refs.play.contentWindow.startPlayReal(this.camera)
    }
  }
}
</script>

<style scoped>

</style>