Newer
Older
urbanLifeline_YanAn / src / views / oneMap / components / ZHQL.vue
@zhangzhihui zhangzhihui 10 days ago 6 KB 1
<template>
  <div id="ZHQL">
    <!-- 左侧盒子 -->
    <div :class="['LeftBox', 'animate__animated', showPanel ? 'animate__fadeOutLeft' : 'animate__fadeInLeft']">
      <LeftBox></LeftBox>
    </div>
    <!-- 右侧盒子 -->
    <div :class="['RightBox', 'animate__animated', showPanel ? 'animate__fadeOutRight' : 'animate__fadeInRight']">
      <RightBox></RightBox>
    </div>
    <div :class="['TopBox', 'animate__animated', showPanel ? 'animate__fadeOutUp' : 'animate__fadeInDown']">
      <div class="TopInfoList" v-for="item in AllData.TopInfoData">
        <img class="TopInfoListIcon" :src="item.icon" alt="" />
        <div class="TopInfoListFont">{{ item.font }}</div>
        <div class="TopInfoListNum">
          {{ item.num }} <span class="TopInfoListunit">{{ item.unit }}</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup name="ZHQL">
import LeftBox from '@/views/oneMap/smartBridge/LeftBox.vue';
import RightBox from '@/views/oneMap/smartBridge/RightBox.vue';
import { ref, reactive, toRefs, onMounted } from 'vue';
import axios from 'axios';

// 顶部信息展示
import QL_WD from '@/assets/images/Sponge_screen/QiaoLiang/QL_WD.png';
import QL_SD from '@/assets/images/Sponge_screen/QiaoLiang/QL_SD.png';
import QL_FS from '@/assets/images/Sponge_screen/QiaoLiang/QL_FS.png';
import QL_FL from '@/assets/images/Sponge_screen/QiaoLiang/QL_FL.png';
import QL_JY from '@/assets/images/Sponge_screen/QiaoLiang/QL_JY.png';
import QL_QY from '@/assets/images/Sponge_screen/QiaoLiang/QL_QY.png';
import { getQLWeather } from '@/api/system/tool';

const AllData = reactive({
  // 顶部信息展示
  TopInfoData: [
    {
      icon: QL_WD,
      font: '温度',
      num: '--',
      unit: '℃',
    },
    {
      icon: QL_SD,
      font: '湿度',
      num: '--',
      unit: '%',
    },
    {
      icon: QL_FS,
      font: '风速',
      num: '--',
      unit: 'm/s',
    },
    // {
    //   icon: QL_FL,
    //   font: "风力",
    //   num: "4",
    //   unit: "级",
    // },
    {
      icon: QL_JY,
      font: '降雨',
      num: '--',
      unit: 'mm',
    },
    {
      icon: QL_QY,
      font: '气压',
      num: '--',
      unit: 'hPa',
    },
  ],
});

const { TopInfoData } = toRefs(AllData);
const showPanel = ref(true); //面板展开收起
// 面板内容展开收起控制
const props = defineProps({
  showPanel: {
    type: Boolean,
  },
});
watch(
  () => props.showPanel,
  () => {
    showPanel.value = props.showPanel;
  },
  { immediate: true }
);

// 获取天气信息
const getWeather = () => {
  // axios
  //   .get(
  //     'http://113.200.135.155:9103/custom/v1/api?interfaceId=getHourByCgj&stationno=53845&token=cee974c7f92e6b680940f172cbd1b74a'
  //   )
  //   .then(res => {
  //     var temVal = res.data.data[0];
  //     // console.log('-------------',temVal);
  //     TopInfoData.value[0].num = temVal.tem;
  //     TopInfoData.value[1].num = temVal.rhu;
  //     TopInfoData.value[2].num = temVal.win_s_avg_2mi;
  //     TopInfoData.value[3].num = temVal.pre_1h;
  //     TopInfoData.value[4].num = temVal.prs;
  //     // allData.weather = res.data.result.realtime;
  //     // allData.weatherTime = res.data.result.last_update;
  //     // allData.location = res.data.result.location;
  //   })
  //   .catch(res => {});

  // interfaceId=getHourByCgj&stationno=53845&token=cee974c7f92e6b680940f172cbd1b74a
  getQLWeather({
    interfaceId: 'getHourByCgj',
    stationno: '53845',
    token: 'cee974c7f92e6b680940f172cbd1b74a',
  })
    .then(res => {
      var temVal = res.data[0];
      // console.log('-------------',temVal);
      TopInfoData.value[0].num = temVal.tem;
      TopInfoData.value[1].num = temVal.rhu;
      TopInfoData.value[2].num = temVal.win_s_avg_2mi;
      TopInfoData.value[3].num = temVal.pre_1h;
      TopInfoData.value[4].num = temVal.prs;
      // allData.weather = res.data.result.realtime;
      // allData.weatherTime = res.data.result.last_update;
      // allData.location = res.data.result.location;
    })
    .catch(res => {});
};

onMounted(() => {
  getWeather();
});
</script>

<style lang="scss" scoped>
#ZHQL {
  .LeftBox {
    width: 450px;
    height: calc(100% - 98px);
    position: absolute;
    left: 10px;
    top: 70px;
    background: linear-gradient(0deg, rgba(4, 34, 84, 0.8) 0%, rgba(4, 34, 84, 0.8) 100%);
    border-radius: 6px;
    border: 1px solid #4aa4ff;
    box-shadow: inset 0 0 5px 5px #4aa4ff8a;
  }
  .RightBox {
    width: 450px;
    height: calc(100% - 98px);
    position: absolute;
    right: 10px;
    top: 70px;
    background: linear-gradient(0deg, rgba(4, 34, 84, 0.8) 0%, rgba(4, 34, 84, 0.8) 100%);
    border-radius: 6px;
    border: 1px solid #4aa4ff;
    box-shadow: inset 0 0 5px 5px #4aa4ff8a;
  }
  .TopBox {
    width: calc(100% - 1000px);
    height: 65px;
    position: absolute;
    left: 500px;
    top: 110px;
    // background: linear-gradient(
    //   0deg,
    //   rgba(0, 43, 67, 0.8) 0%,
    //   rgba(0, 69, 108, 0.8) 100%
    // );
    border-radius: 6px;
    // border: 1px solid #47eef3;
    box-sizing: border-box;
    // box-shadow: inset 0 0 5px 5px #47eef38a;
    padding: 10px;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: space-evenly;
    align-items: center;

    .TopInfoList {
      width: 180px;
      height: 65px;

      .TopInfoListIcon {
        width: 67px;
        height: 65px;
        float: left;
      }

      .TopInfoListFont {
        width: 113px;
        height: 35px;
        float: left;
        font-family: Source Han Sans CN;
        font-weight: 500;
        font-size: 16px;
        color: #ffffff;
        line-height: 35px;
        padding-left: 12px;
      }
      .TopInfoListNum {
        padding-left: 12px;
        width: 113px;
        height: 30px;
        float: left;
        font-family: Source Han Sans CN;
        font-weight: bold;
        font-size: 22px;
        color: #15d2fd;

        .TopInfoListunit {
          font-family: Source Han Sans CN;
          font-weight: 500;
          font-size: 16px;
          color: #cef6ff;
        }
      }
    }
  }
  // 左右两侧展示板块公共样式
  .ComBox {
    width: 100%;
    box-sizing: border-box;
    .Box_header {
      width: 100%;
      height: 43px;
      background: url('@/assets/images/Sponge_screen/Box_HeaderBackground.png') no-repeat center;
      background-size: cover;
      font-family: PangMenZhengDao;
      font-weight: 400;
      font-size: 23px;
      color: #ebfeff;
      line-height: 43px;
      box-sizing: border-box;
      padding-left: 35px;
    }

    .Box_Body {
      width: 100%;
      height: calc(100% - 43px);
      box-sizing: border-box;
      position: relative;
      overflow: auto;
    }
  }
  .color_red {
    color: #ff3f3f !important;
  }

  @keyframes moveUp {
    0% {
      transform: translateY(0);
    }
    100% {
      transform: translateY(-20px);
    }
  }
}
</style>