<template>
  <div class="company-home">
    <div class="top-bg">
      <div class="main-title">{{ mainTitle }}</div>
    </div>
    <div class="company-content">
      <div class="area-content">
        <div class="left-area">
          <!-- 矿井通风状态监测 -->
          <div class="area-card">
            <mineWind />
          </div>
          <!-- 一通三防风险分析与预警 -->
          <div class="area-card1">
            <riskWarn />
          </div>
        </div>
        <div class="center-area">
          <!-- 地图底图 -->
          <div class="center-bg">
            <div class="bg-map">
              <iconLight @show-detail="showDetail" />
            </div>
          </div>
          <!-- 榆家梁矿 -->
          <!-- <div class="area-card2">
            
          </div> -->
          <!-- 文件共享中心 -->
          <div class="area-card3">
            <fileShare />
          </div>
        </div>
        <div class="right-area">
          <!-- 关键场景通防综合监测 -->
          <div class="area-card">
            <sceneKey />
          </div>
          <!-- 通风巷道长度统计 -->
          <div class="area-card1">
            <windRoad />
          </div>
        </div>
      </div>
    </div>
    <div class="area-card2" v-show="isShowDialog">
      <dialogModal ref="dialogModalRef" @close-dialog="closeDialog" />
    </div>
  </div>
</template>
<script lang="ts" setup>
  import { ref, nextTick,onMounted,onUnmounted } from 'vue';
  import mineWind from './components/mine-wind.vue';
  import riskWarn from './components/risk-warn.vue';
  import fileShare from './components/file-share.vue';
  import windRoad from './components/wind-road.vue';
  import sceneKey from './components/scene-key.vue';
  import iconLight from './components/icon-light.vue';
  import dialogModal from './components/dialog-modal.vue';
  import {getHomeData} from './clique.api'
  const dialogModalRef = ref();
  // let mainTitle = ref('国家能源神东煤炭集团');
  let mainTitle = ref('XXXX集团');
  const isShowDialog = ref(false);

// https获取监测数据
let timer: null | NodeJS.Timeout = null;
function getMonitor() {
  timer = setTimeout(
    async () => {
      await getHomeDataList();
      if (timer) {
        timer = null;
      }
      getMonitor();
    },
    5000
  );
}

//获取公司端首页数据
async function getHomeDataList(){
  let res=await getHomeData()
  console.log(res,'公司端首页数据----------')
}


  function showDetail(code, leftV, topV) {
    if (code) {
      isShowDialog.value = true;
    }
    nextTick(() => {
      const tooltipDom = document.getElementById('detailModal') as HTMLElement;
      tooltipDom.style.left = leftV;
      tooltipDom.style.top = topV;
    });
  }
  function closeDialog() {
    isShowDialog.value = false;
  }

  onMounted(()=>{
    getMonitor()
  })
  onUnmounted(() => {
  if (timer) {
    clearTimeout(timer);
    timer = null;
  }
});
</script>
<style lang="less" scoped>
  @font-face {
    font-family: 'douyuFont';
    src: url('../../../../assets/font/douyuFont.otf');
  }

  // @font-face {
  //   font-family: 'yjsz';
  //   src: url('../../../../assets/font/yjsz.TTF');
  // }
  .company-home {
    width: 100%;
    height: 100%;
    position: relative;
    background: url('../../../../assets/images/company/home-pageBg.png') no-repeat center;
    background-size: 100% 100%;

    .top-bg {
      width: 100%;
      height: 97px;
      background: url('../../../../assets/images/company/top-bg.png') no-repeat center;
      position: absolute;
      z-index: 1;
      .main-title {
        height: 96px;
        color: #fff;
        font-family: 'douyuFont';
        font-size: 20px;
        letter-spacing: 2px;
        display: flex;
        justify-content: center;
        align-items: center;
      }
    }

    .company-content {
      position: absolute;
      left: 0;
      top: 0;
      width: 100%;
      height: 100%;
      background: url('../../../../assets/images/company/content-bg.png') no-repeat;
      background-size: 100% 100%;

      .area-content {
        position: absolute;
        top: 45px;
        width: 100%;
        height: calc(100% - 45px);
        padding: 0px 20px 20px 20px;
        box-sizing: border-box;
        display: flex;
        justify-content: space-between;
        .left-area {
          width: 23%;
          height: 100%;
          margin-right: 15px;
          display: flex;
          flex-direction: column;
          justify-content: space-between;
          align-items: center;
          .area-card {
            width: 100%;
            height: calc(60% - 15px);
            margin-bottom: 15px;
            background: url('../../../../assets/images/company/area-card.png') no-repeat;
            background-size: 100% 100%;
          }

          .area-card1 {
            width: 100%;
            height: 40%;
            background: url('../../../../assets/images/company/area-card1.png') no-repeat;
            background-size: 100% 100%;
          }
        }

        .center-area {
          width: calc(54% - 30px);
          height: 100%;
          position: relative;
          .center-bg {
            position: absolute;
            bottom: 269px;
            left: 50%;
            transform: translate(-50%, 0);
            height: calc(100% - 325px);
            width: 100%;
            background: url('../../../../assets/images/company/home-dz.png') no-repeat center;
            background-position: 50% 90%;
            .bg-map {
              width: 100%;
              height: 100%;
              background: url('../../../../assets/images/company/home-map.png') no-repeat center;
              background-size: 100% 100%;
            }
          }
          .area-card2 {
            position: absolute;
            right: 0;
            top: 62px;
            width: 568px;
            height: 437px;
            background: url('../../../../assets/images/company/area-card2.png') no-repeat;
            background-size: 100% 100%;
            // pointer-events: auto;
          }

          .area-card3 {
            position: absolute;
            right: 0;
            bottom: 0px;
            width: 100%;
            height: 269px;
            background: url('../../../../assets/images/company/area-card3.png') no-repeat;
            background-size: 100% 100%;
          }
        }

        .right-area {
          width: 23%;
          height: 100%;
          margin-left: 15px;
          display: flex;
          flex-direction: column;
          justify-content: space-between;
          align-items: center;
          // pointer-events: auto;
          .area-card {
            width: 100%;
            height: calc(60% - 15px);
            margin-bottom: 15px;
            background: url('../../../../assets/images/company/area-card.png') no-repeat;
            background-size: 100% 100%;
          }

          .area-card1 {
            width: 100%;
            height: 40%;
            background: url('../../../../assets/images/company/area-card1.png') no-repeat;
            background-size: 100% 100%;
          }
        }
      }
    }
  }
</style>
