Newer
Older
CloudBrainNew / src / views / doubleScreen / leftScreen.vue
StephanieGitHub on 26 Mar 2021 3 KB ADD: 双屏显示优化
<!--
 * @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 justify="center">-->
          <el-button v-for="item of screenList" @click="changeScreen(item.name)">{{item.fullName}}</el-button>
          <!--<el-button @click="changeScreen('gongdi')">智慧工地</el-button>-->
          <!--<el-button @click="changeScreen('xiangguan')">智慧项管</el-button>-->
          <!--<el-button @click="changeScreen('jiaoyu')">智慧教育</el-button>-->
          <!--<el-button @click="changeScreen('tingcheyun')">停车云</el-button>-->
          <!--<el-button @click="changeScreen('shehuizhili')">社会治理</el-button>-->
          <!--<el-button @click="changeScreen('yuanlin')">智慧园林</el-button>-->
          <!--<el-button @click="changeScreen('wulianwang')">物联网</el-button>-->
          <!--<el-button @click="changeScreen('huanbao')">智慧环保</el-button>-->
          <!--<el-button @click="changeScreen('huanwei')">智慧环卫</el-button>-->
        <!--</el-row>-->
      </div>
    </div>
  </div>
</template>

<script>
import { mapActions } from 'vuex'
import HeaderLeft from './components/headerLeft'
import HeaderMiddle from './components/headerMiddle'
import {fetchAllScreens} from '@/api/doubleScreen'
export default {
  name: 'leftScreen',
  components: {HeaderMiddle, HeaderLeft},
  data () {
    return {
      mainImg: require('@/assets/images/1411/1411.png'),
      subImg: require('@/assets/images/1411/text.png'),
      screenList: [] // 大屏列表
    }
  },
  created () {
    this.getAllScreen()
  },
  mounted () {
    const that = this
    // this.calSize()
    window.onload = () => {
      that.calSize()
    }
    window.onresize = () => {
      that.calSize()
    }
  },
  methods: {
    // 获取所有大屏
    getAllScreen () {
      fetchAllScreens().then(response => {
        if (response.code === 200) {
          this.screenList = response.data
        }
      })
    },
    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:90vw;
      position:absolute;
      bottom:4%;
      left:50%;
      transform: translateX(-60%);
      display: flex;
      justify-content: center;
    }
  }

</style>