Newer
Older
CloudBrainNew / src / views / doubleScreen / leftScreen.vue
StephanieGitHub on 4 Feb 2021 3 KB first commit
<!--
 * @Description: 左半屏 1411
 * @Author: 王晓颖
 * @Date: 2021-01-20 11:20:11
 -->
<template>
  <div ref="container" class="container">
    <!--头-->
    <!--<header-left ref="header"/>-->
    <header-middle/>
    <!--内容-->
    <div ref="body" class="body">
      <img :src="mainImg" class="main-img"/>
      <img :src="subImg" class="sub-img"/>
      <div class="btn-group">
        <el-row>
          <el-button @click="changeScreen('community')">智慧社区</el-button>
          <el-button @click="changeScreen('gongdi')">智慧工地</el-button>
          <el-button @click="changeScreen('shehuizhili')">社会治理</el-button>
          <el-button @click="changeScreen('gongan')">智慧公安</el-button>
          <el-button @click="changeScreen('jiaotong')">智慧交通</el-button>
          <el-button @click="changeScreen('chengguan')">智慧城管</el-button>
        </el-row>
      </div>
    </div>
  </div>
</template>

<script>
import { mapActions } from 'vuex'
import HeaderLeft from './components/headerLeft'
import HeaderMiddle from './components/headerMiddle'
export default {
  name: 'leftScreen',
  components: {HeaderMiddle, HeaderLeft},
  data () {
    return {
      mainImg: require('@/assets/images/1411/1411.png'),
      subImg: require('@/assets/images/1411/text.png')
    }
  },
  mounted () {
    const that = this
    // this.calSize()
    window.onload = () => {
      that.calSize()
    }
    window.onresize = () => {
      that.calSize()
    }
  },
  methods: {
    calSize () {
      // const height = document.body.clientHeight
      const height = this.$refs.container.offsetHeight
      const headerHeight = this.$refs.header.$el.clientHeight
      const bodyHeight = height - headerHeight
      this.$refs.body.style.height = bodyHeight + 'px'
      console.log('calSize:' + bodyHeight)
    },
    ...mapActions(['changeDoubleScreen']),
    changeScreen (screen) {
      console.log('click changeScreen')
      if (this.$ws.readyState === 1) {
        console.log(this.$ws.readyState)
        this.$ws.send(JSON.stringify('doubleScreen:' + screen))
        this.changeDoubleScreen(screen)
      }
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
  @media screen and (max-width: 3000px) {
    .container{
      height: 100%;
      width:100%;
    }
  }
  @media screen and (min-width: 3000px) {
    .container{
      height: 1080px;
      width:1920px;
    }
  }
  .container{
    top:0px !important;
    background: url("../../assets/images/background/background-left.png") no-repeat;
    -webkit-background-size: 100% 100%;
    background-size: 100% 100%;
    background-color: black;
    /*display: flex;*/
    /*justify-content: space-between;*/
    /*flex-direction: column;*/
  }
  .body{
    /*flex:1;*/
    position:relative;
    height:calc(100% - 0.6rem);
    width:100%;
    .main-img{
      position: absolute;
      width:70%;
      top:50%;
      left:50%;
      transform: translate(-62%,-55%);
    }
    .sub-img{
      position:absolute;
      height:55%;
      top:50%;
      right:4%;
      transform: translateY(-60%);
    }
    .btn-group{
      width:auto;
      position:absolute;
      bottom:4%;
      left:50%;
      transform: translateX(-60%);
    }
  }

</style>