Newer
Older
CloudBrainNew / src / views / socialLive / socialLivelihoodLeft.vue
wangxitong on 29 Apr 2021 3 KB 0429 submit
<!--
 * @Description: 社会民生左半
 * @Author: 王晓颖
 * @Date: 2020-11-16 10:02:47
 -->
<template>
  <div class="chart-container">
    <div class="left">
      <div class="modular">
        <!--整个:左右50%-->
        <div class="modular-row-100">
          <!--左半 33%-->
          <div class="modular-col-30 modular-padding-right">
            <div class="modular-row-60">
              <buildings/>
            </div>
            <div class="modular-row-30">
              <go-through/>
            </div>
          </div><!-- .col50 over-->
          <!--./左半-->
          <!--右半 66%-->
          <div class="modular-col-60">
            <div class="modular-row-30">
              <introduce/>
            </div>
            <div class="modular-row-30">
              <population/>
            </div>
            <div class="modular-row-30">
              <div class="modular-col-50 modular-padding-right">
                <trouble-count/>
              </div>
              <div class="modular-col-50">
                <trouble-statistic/>
              </div>
            </div>
          </div><!-- .col50 over-->
          <!--./右半-->
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import Introduce from './components/community/introduce'
import Population from './components/community/population'
import TroubleCount from './components/community/troubleCount'
import TroubleStatistic from './components/community/troubleStatistic'
import Buildings from './components/community/buildings'
import GoThrough from './components/community/goThrough'
export default {
  name: 'SocialLivelihoodLeft',
  components: {
    GoThrough,
    Buildings,
    TroubleStatistic,
    TroubleCount,
    Population,
    Introduce
  },
  data () {
    return {
      populationComp: 0, // 人口组件
      populationComps: ['youth-pie', 'special-bar', 'introduce4'],
      populationTimer: null,
      parkComp: 0, // 停车场组件
      parkComps1: ['park-introduce', 'park-earth', 'park-income-count'],
      parkComps2: ['park-flow-line', 'park-detail', 'park-income-line'],
      parkTimer: null
    }
  },
  mounted () {
    // this.populationChange()
    // setTimeout(() => {
    //   this.parkChange()
    // }, 2000)
  },
  methods: {
    // 人口组件切换
    populationChange () {
      this.populationTimer = setTimeout(() => {
        const max = this.populationComps.length - 1
        if (this.populationComp < max) {
          this.populationComp++
        } else {
          this.populationComp = 0
        }
        this.populationChange()
      }, 10000)
    },
    // 停止切换人口组件
    stopPopulationChange () {
      clearInterval(this.populationTimer)
      this.populationTimer = null
    },
    parkChange () {
      this.parkTimer = setTimeout(() => {
        const max = this.parkComps1.length - 1
        if (this.parkComp < max) {
          this.parkComp++
        } else {
          this.parkComp = 0
        }
        this.parkChange()
      }, 5000)
    },
    stopParkChange () {
      clearInterval(this.parkTimer)
      this.parkTimer = null
    }
  },
  beforeDestroy () {
    this.stopPopulationChange()
    this.stopParkChange()
  }

}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
  .chart-container{
    position: absolute;
    top:0;
    left:.2rem;
    width: 30%;
    height:98%;
    display: flex;
    z-index: 20;
    justify-content: space-between;
    background: transparent;
    .left{
      width:100%;
      height:100%;
      display: flex;
      justify-content: center;
      /*position: relative;*/
    }
    .modular{
      width:100%;
      height:100%;
      position:relative;
      .modular-50{
        height:50%;
        wdith:100%;
      }
    }
  }

  .v-enter,
  .v-leave-to {
    opacity: 0;
    transform: translateX(-150px);
  }

  .v-enter-active,
  .v-leave-active {
    transition: all 0.5s ease;
  }

</style>