<template>
  <div>
    <!-- <div class="realTime">
      <div class="leiji"></div>
      <div class="benyue"></div>
    </div> -->
    <div
      class="legend-box"
      @click="
        () => {
          tuliType = !tuliType;
        }
      "
    >
      <img src="../../assets/images/legend/legend.png" />
    </div>
    <!-- 图例模块 -->
    <div v-drag class="tuli" v-show="tuliType">
      <div class="box">
        <div class="title">
          <div class="close-legend" @click="tuliType = !tuliType;"></div>
        </div>
        <div class="tuil-body">
          <div class="title2" @click="siteShow=!siteShow">
            <img src="../../assets/images/legend/arrow.png" style="display: inline;margin-top: -4px;" v-if="siteShow"/>
            <img src="../../assets/images/legend/arrow.png" style="display: inline;transform: rotate(-90deg);margin-top: -4px;" v-else/>
            <span>站点</span>
          </div>
          <div class="title2-body" v-if="siteShow">
            <div class="legend-item">
              <div class="img-box">
                <img src="../../assets/images/legend/shuiwen.png" style="display: inline" />
              </div>
              水文站
            </div>
            <div class="legend-item">
              <div class="img-box"><img :src="'./static/img/legend/shuiwei.png'" style="display: inline" /></div>
              水位站
            </div>
            <div class="legend-item">
              <div class="img-box"> <img :src="'./static/img/legend/qixiang2.png'" style="display: inline" /></div>
              一般气象站
            </div>
            <div class="legend-item">
              <div class="img-box"> <img :src="'./static/img/legend/qixiang.png'" style="display: inline" /></div>
              标准气象站
            </div>
            <div class="legend-item">
              <div class="img-box"><img :src="'./static/img/legend/yuliang.png'" style="display: inline" /></div>
              雨量站
            </div>
            <div class="legend-item">
              <div class="img-box"><img :src="'./static/img/legend/tanshui.png'" style="display: inline" /></div>
              碳水通量站
            </div>
            <div class="legend-item">
              <div class="img-box"><img :src="'./static/img/legend/gc.png'" style="display: inline" /></div>
              工程
            </div>
          </div>
          <!-- <div class="title2" @click="rainShow=!rainShow">
            <img src="../../assets/images/legend/arrow.png" style="display: inline;margin-top: -4px;" v-if="rainShow"/>
            <img src="../../assets/images/legend/arrow.png" style="display: inline;transform: rotate(-90deg);margin-top: -4px;" v-else/>
            <span>雨量（mm）</span>
          </div>
          <div class="title2-body" v-if="rainShow">
            <div class="legend-item" v-for="item in rainLegend">
              <div class="color-box" :style="item.style"></div>
              {{ item.value }}
            </div>
          </div> -->
          <!-- <div class="title2" @click="wdShow=!wdShow">
            <img src="../../assets/images/legend/arrow.png" style="display: inline;margin-top: -4px;" v-if="wdShow"/>
            <img src="../../assets/images/legend/arrow.png" style="display: inline;transform: rotate(-90deg);margin-top: -4px;" v-else/>
            <span>温度（℃）</span>
          </div>
          <div class="title2-body" v-if="wdShow">
            <a-row>
              <a-col :span="12">
                <div class="legend-item" v-for="item in wdLegend2">
              <div class="color-box" :style="item.style"></div>
              {{ item.value }}
            </div>
              </a-col>
              <a-col :span="12">
                <div class="legend-item" v-for="item in wdLegend">
              <div class="color-box" :style="item.style"></div>
              {{ item.value }}
            </div>
              </a-col>
            </a-row>
          </div> -->
        </div>
        <div class="light"></div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, reactive } from 'vue';
import { CloseOutlined } from '@ant-design/icons-vue';
import eventBus from '/@/utils/eventBus';
window.eventBus = eventBus;
eventBus.on('legendColor', (e) => {
  // console.log('legendColor', e);
  if(e.flag){
    tuliType.value=true
    if(e.maptype==1||e.maptype==2||e.maptype==0){
      tuliType.value=true
    siteShow.value=false
    rainShow.value=true
    wdShow.value=false
    }else if(e.maptype==3){
      tuliType.value=true
    siteShow.value=false
    rainShow.value=false
    wdShow.value=true
    }else{
      tuliType.value=false
    siteShow.value=true
    rainShow.value=false
    wdShow.value=false
    }
  }else{
    tuliType.value=false
    siteShow.value=true
    rainShow.value=false
    wdShow.value=false
  }
});
let showZaihai = ref(true);
let showDev = ref(true);
const tuliType = ref(false);
const siteShow = ref(true);
const rainShow = ref(false);
const wdShow = ref(false);

const rainLegend=reactive([
{
    style:'background:#fd00f9',
    value:'>100'
  },
  {
    style:'background:#0000f7',
    value:'50~100'
  },
  {
    style:'background:#62b7fb',
    value:'25~50'
  },
  {
    style:'background:#43b635',
    value:'10~25'
  },
  {
    style:'background:#6dd969',
    value:'5~10'
  },
  {
    style:'background:#b4f7a3',
    value:'2.5~5'
  },

  {
    style:'background:#d9f9ce',
    value:'0~2.5'
  },
])
const wdLegend=reactive([
{
    style:'background:#e60101',
    value:'>40'
  },
  {
    style:'background:#f55900',
    value:'37~40'
  },
  {
    style:'background:#f99782',
    value:'35~37'
  },
  {
    style:'background:#fecda1',
    value:'32~35'
  },
  {
    style:'background:#fef2c2',
    value:'28~32'
  },
  {
    style:'background:#fdfb96',
    value:'24~28'
  },
  {
    style:'background:#bffb91',
    value:'20~24'
  },
  {
    style:'background:#ccffcc',
    value:'16~20'
  },
])
const wdLegend2=reactive([

  {
    style:'background:#f3fdee',
    value:'12~16'
  },
  {
    style:'background:#cffcff',
    value:'8~12'
  },
  {
    style:'background:#abe9f8',
    value:'4~8'
  },
  {
    style:'background:#82d1ff',
    value:'0~4'
  },
  {
    style:'background:#3f9fe9',
    value:'-4~0'
  },
  {
    style:'background:#1d75d4',
    value:'-8~-4'
  },
  {
    style:'background:#195da7',
    value:'-12~-8'
  },
  {
    style:'background:#032b8b',
    value:'<-12'
  },
])
</script>
<style lang="less" scoped>
.legend-box {
  position: absolute;
  right: 450px;
  bottom: 100px;
  z-index: 10;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  opacity: 1;

  /* 工具栏背景色 */
  background: rgba(10, 80, 110, 0.9);
  line-height: 34px;
  text-align: center;
  img {
    display: inline-block;
  }
}
.tuli {
  position: absolute;
  width: 160px;
  height: 270px;
  overflow: hidden;
  padding: 0px;
  bottom: 100px;
  right: 500px;

  border: 1px solid rgba(0, 106, 255, 0.5);
  background: rgba(0, 22, 44, 0.7);

  box-sizing: border-box;
  opacity: 1;
  border-radius: 2px;
  z-index: 11;
  .box {
    height: 100%;
    width: 100%;
    position: relative;
    .title {
      position: relative;
      height: 34px;
      background: url('/@/assets/images/legend/legendtitle.png');
      background-size: 100% 100%;
      .close-legend{
        width: 20px;
        height: 20px;
        // background: red;
        // opacity: 0.4;
        position: absolute;
        right: 3px;
        top: 6px;
        cursor: pointer;
      }
    }
    .tuil-body {
      height: calc(100% - 34px);
      padding: 9px;
      overflow: auto;
      .title2 {
        width: 124px;
        height: 20px;
        background: linear-gradient(90deg, rgba(0, 124, 240, 0.24) 0%, rgba(216, 216, 216, 0) 100%);
        cursor: pointer;
      }
      .title2-body {
        padding: 5px 0;
        .legend-item {
          width: 100%;
          height: 25px;
          line-height: 25px;
          padding: 0 0 0 20px;
          margin-bottom: 5px;
          overflow: hidden;
          display: flex;
          align-items: center;
          .img-box {
            width: 15px;
            display: inline-block;
            text-align: center;
            margin-right: 10px;
          }
          .color-box {
            width: 15px;
            height: 15px;
            display: inline-block;
            text-align: center;
            background: #fff;
            border-radius: 10px;
            margin-right: 10px;
          }
        }
      }
    }
    .light {
      background: url('/@/assets/images/legend/light.png');
      background-position: center center;
      height: 10px;
      width: 100%;
      position: absolute;
      bottom: -5px;
    }
  }
}
.layerListTitle {
  display: flex;
  // background-color: aliceblue;
  line-height: 30px;
  height: 30px;
  background-image: linear-gradient(to left, rgba(0, 139, 253, 0.2), rgba(67, 255, 249, 0.2)); /* 设置背景颜色 */
  // width: 200px;
  img {
    margin-top: 6px;
    margin-left: 0px;
    margin-right: 5px;
    width: 20px;
    height: 19px;
  }
}
.leiji {
  width: 143px;
  height: 22px;
  position: absolute;
  top: 100px;
  left: 470px;
  background: url('/@/assets/images/legend/leij.png');
  z-index: 11;
}
.benyue {
  width: 143px;
  height: 22px;
  position: absolute;
  top: 150px;
  left: 470px;
  background: url('/@/assets/images/legend/benyue.png');
  z-index: 11;
}
</style>
