Newer
Older
CloudBrainNew / src / views / doubleScreen / leftScreen.vue
[wangxitong] on 4 Jun 2021 5 KB 0604 submit
<!--
 * @Description: 左半屏 1411
 * @Author: 王晓颖
 * @Date: 2021-01-20 11:20:11
 -->
<template>
  <div ref="container" class="container">
    <img :src="bkImg" class="bk-img" />
    <!--头-->
    <header-left ref="header" style="z-index: 10000;position: absolute;top: 0px;left: 0px;"/>
    <!--<header-middle/>-->
    <!--内容-->
    <div ref="body" class="body">
      <img :src="mainImg" class="main-img"/>
      <img :src="subImg" class="sub-img"/>
      <div class="center-click" @click="jumpScreen"/>
      <img :src="iconImg"   v-for="item in icon"
           :style="{
            opacity:0.8,
            position: 'absolute',
            height: item.size + '%',
            top: item.top + '%',
            left: item.left + '%'}"/>
      <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 {
      icon: [
        {size: 10, left: 7, top: 2},
        {size: 11, left: 9.8, top: 8.5},
        {size: 13, left: 4.5, top: 13},
        {size: 8, left: 10.8, top: 22},
        {size: 13, left: 5.5, top: 38.5},
        {size: 12, left: 11, top: 48},
        {size: 9, left: 65.5, top: -1},
        {size: 10, left: 68.5, top: 5.8},
        {size: 12, left: 63.5, top: 9.5},
        {size: 8, left: 69, top: 18},
        {size: 7.5, left: 64.2, top: 21},
        {size: 11, left: 65.5, top: 38.5}
      ],
      bkImg: require('@/assets/images/background/bk.gif'),
      mainImg: require('@/assets/images/1411/1411.png'),
      subImg: require('@/assets/images/1411/text.png'),
      iconImg: require('@/assets/images/1411/icon.gif'),
      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)
      }
    },
    jumpScreen () {
      this.$router.push({ path: '/layout1' })
    }
  }
}
</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;*/
  }
  .bk-img{
    position: absolute;
    width: 120%;
    height: 130%;
    top: -.1rem;
    left: -19%;
    opacity:0.3;
  }
  .body{
    /*flex:1;*/
    position:absolute;
    top: 0.6rem;
    height:calc(100% - 0.6rem);
    width:100%;
    .bk-img{
      position: absolute;
      width: 120%;
      height: 105%;
      top: -.1rem;
      left: -17%;
    }
    .main-img{
      position: absolute;
      width:70%;
      height:100%;
      top:-4%;
      left:5%;
    }
    .sub-img{
      position:absolute;
      height:55%;
      top:50%;
      right:4%;
      transform: translateY(-60%);
    }
    .center-click{
      position:absolute;
      width: 16%;
      height: 10%;
      top: 23%;
      left: 33%;
      z-index: 1000000;
    }
    .btn-group{
      width:90vw;
      position:absolute;
      bottom:4%;
      left:50%;
      transform: translateX(-60%);
      display: flex;
      justify-content: center;
    }
  }

</style>