Newer
Older
KaiFengPC / src / views / sponeScreen / cityGK / rainfall.vue
@jimengfei jimengfei on 16 Aug 5 KB updata
<template>
  <div class="partTitleHM">
    降雨特征
    <div class="head-right" style="">
      <div
        class="head-item"
        v-for="(item, index) in yearList"
        :key="item"
        :class="activedname == item.name ? 'activedright' : ''"
        @click="yearclick(item, index)"
      >
        {{ item.name }}
      </div>
    </div>
  </div>

  <div class="partContHM">
    <div class="HeadContent" v-if="activedname == '年际降雨变化'">丰、枯年交替出现,且降雨量变化幅度大</div>
    <div class="HeadContent" v-else>年内降雨量分配不均匀,冬季干旱,雨雪稀少</div>
    <div class="box-body">
      <div style="height: 100%">
        <RainfallEcharts :data="chartData2" :refresh="chartData2.refresh" v-if="activedname == '年际降雨变化'"></RainfallEcharts>
        <RainfallLegend :data="chartData3" :refresh1="chartData3.refresh1" v-else></RainfallLegend>
      </div>
    </div>
  </div>
</template>

<script setup>
import RainfallEcharts from '@/views/sponeScreen/Echarts/RainfallEcharts.vue'; //年际降雨变化

import RainfallLegend from '@/views/sponeScreen/Echarts/RainfallLegend.vue'; //年内降雨量
import { onBeforeUnmount } from 'vue';
import newfiberVectorLayer from '@/views/sponeScreen/gisMF/newfiberVectorLayer.js';

const chartData2 = ref({
  xAxis: [1985, 1990, 1995, 2000, 2005, 2010, 2015, 2020, 2021],
  yAxis: [650, 800, 502, 630, 820, 800, 510, 805, 1203],
  // yAxis2: [7, 9, 10, 9, 11, 10, 12, 15],
  refresh: 1,
});
const chartData3 = ref({
  XName: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12'],
  data1: [8, 15, 24, 36, 58, 63, 165, 125, 72, 30, 23, 10],
  data: [
    {
      coords: [
        ['1', 8],
        ['2', 15],
        ['3', 24],
        ['4', 36],
        ['5', 58],
        ['6', 63],
        ['7', 165],
        ['8', 125],
        ['9', 72],
        ['10', 30],
        ['11', 23],
        ['12', 10],
      ],
    },
  ],
  refresh1: 1,
});
const activedname = ref('年际降雨变化');
const weatherTimer = ref(null);

const ContentDetails = ref('');
const yearList = ref([
  { name: '年际降雨变化', value: 1 },
  { name: '年内降雨量', value: 2 },
]);
const a = ref('');

function yearclick(val) {
  console.log(val.name, 'val.name');
  activedname.value = val.name;
  console.log(activedname.value, 'activedname.value ');
  if (val.name == '年内降雨量') {
    //消除实时天气效果
    clearInterval(window.currentWeatherTimer);
    window.currentWeatherTimer = null;
    newfiberMap.weatherRemove();
    let mounthIndex = 0;
    weatherTimer.value = setInterval(() => {
      if (mounthIndex == 0) {
        newfiberMap.weatherSnow({
          snowSize: 0.01,
          snowSpeed: 60,
        });
      } else if (mounthIndex == 1) {
        newfiberMap.weatherSnow({
          snowSize: 0.02,
          snowSpeed: 100,
        });
      } else if (mounthIndex == 6 || mounthIndex == 7) {
        newfiberMap.weatherRain({
          tiltAngle: -0.2,
          rainSize: 0.1,
          rainSpeed: 150.0,
        }); // 暴雨
      } else if (mounthIndex == 8) {
        newfiberMap.weatherRain({
          tiltAngle: -0.2,
          rainSize: 0.2,
          rainSpeed: 150.0,
        }); // 大
      } else if (mounthIndex == 5) {
        newfiberMap.weatherRain({
          tiltAngle: -0.2,
          rainSize: 0.5,
          rainSpeed: 150.0,
        }); //中
      } else {
        newfiberMap.weatherRain({
          tiltAngle: -0.2,
          rainSize: 1,
          rainSpeed: 150.0,
        }); //小
      }
      mounthIndex = mounthIndex + 1;
      if (mounthIndex == 12) {
        mounthIndex = 0;
      }
    }, 2000);
  } else {
    // clearInterval(weatherTimer.value);
    // weatherTimer.value = null;
    // newfiberMap.weatherRemove();
    // //恢复实时天气效果
    // window.currentWeatherTimer = null;
    // newfiberVectorLayer.setCurrentWeather();
    // window.currentWeatherTimer = setInterval(() => {
    //   newfiberVectorLayer.setCurrentWeather();
    // }, 300000);
  }
}

const refresh = ref(1);
const refresh1 = ref(1);
onBeforeUnmount(() => {
  clearInterval(weatherTimer.value);
  weatherTimer.value = null;
  // if (!newfiberMap) return;
  // newfiberMap.weatherRemove();
});
</script>

<style lang="scss" scoped>
// height: 260px;
// background: red;
.HeadContent {
  width: 100%;
  height: 30px;
  background: rgba(34, 112, 255, 0.4);
  text-align: center;
  line-height: 30px;
  color: #ffffff;
}
.box-body {
  height: calc(100vh - 760px);
  padding-left: 5px;
  position: relative;
  overflow: auto;
}
.head-right {
  cursor: pointer;
  position: relative;
  font-size: 14px;
  left: 200px;
  top: -32px;
  color: #ffffff;
  display: flex;
  max-width: 200px;
  overflow: hidden;
  overflow-x: auto;
  line-height: 18px;

  .head-item {
    margin-left: 10px;
    padding: 2px 3px;
    border: 1px solid transparent;
    background: #013a73;
    height: 23px;
    text-align: center;
    min-width: 42px;
    border: 1px solid #2270ff;
  }

  .activedright {
    border: 1px solid #2cfce9;
    color: #e4f5ff;
    background: #166f84;
  }
}
</style>