<template>
  <Bg2 class='ConditionStatistics'>
    <div class="statistics-header">
      <div class="title keep-ratio" origin="left"></div>
      <img class="icon-right keep-ratio" origin="right" src="@screen/images/icon/icon_right.png" />
    </div>
    <div class="content-r-t-box">
      <div class="box-title keep-ratio" origin="left"><span>预警事件</span></div>
      <div class="box-content">
        <div class="box-content-l">
          <div class="event-item keep-ratio" origin="left">今日:<span>{{ earlyWarningEvents.day }}</span> 起</div>
          <div class="event-item keep-ratio" origin="left">本月:<span>{{ earlyWarningEvents.month }}</span> 起</div>
        </div>
        <div class="box-content-c keep-ratio">
          <span class="num">{{ earlyWarningEvents.processing }}</span>
          <span class="text">处理中</span>
        </div>
        <div class="box-content-r">
          <div class="event-item keep-ratio" origin="right">本周:<span>{{ earlyWarningEvents.week }}</span> 起</div>
          <div class="event-item keep-ratio" origin="right">本年:<span>{{ earlyWarningEvents.year }}</span> 起</div>
        </div>
      </div>
    </div>
    <div class="content-r-c-box">
      <div class="box-title"><span>在途车辆统计</span></div>
      <div class="box-content">
        <div class="count">
          <div class="charts keep-ratio" ref="carStatisticsEchartBox"></div>
          <div class="count-item cars">
            <span class="icon"></span>
            <span class="label">数量:</span>
            <span class="value">1006</span>
            <span class="unit">辆</span>
          </div>
        </div>
        <div class="count">
          <div class="charts keep-ratio" ref="focusStatisticsEchartBox"></div>
          <div class="count-item focus">
            <span class="icon"></span>
            <span class="label">数量:</span>
            <span class="value">1006</span>
            <span class="unit">辆</span>
          </div>
        </div>
        <div class="count">
          <div class="charts keep-ratio" ref="otherStatisticsEchartBox"></div>
          <div class="count-item other">
            <span class="icon"></span>
            <span class="label">数量:</span>
            <span class="value">1006</span>
            <span class="unit">辆</span>
          </div>
        </div>
      </div>
    </div>
    <div class="content-r-b-box">
      <div class="box-title"><span>今日交通异常</span></div>
      <div class="box-content">
        <div class="processed">
          <span class="text">处理中:</span>
          <div class="sections">
            <div class="num-box">
              <span>0</span>
            </div>
            <span class="unit">处 /</span>
          </div>
          <div class="kilometer">
            <div class="num-box">
              <span>0</span>
            </div>
            <span class="unit">Km</span>
          </div>
        </div>
        <div class="abnormalList">
          <div class="listItem total">
            <span class="label">日拥堵累计段数:</span>
            <div class="value">
              <span class="num">0</span>
              <span class="unit">处</span>
            </div>
          </div>
          <div class="listItem kilometer">
            <span class="label">日拥堵累计公里数:</span>
            <div class="value">
              <span class="num">13.25</span>
              <span class="unit">Km</span>
            </div>
          </div>
        </div>
      </div>
    </div>
  </Bg2>
</template>

<script>
import * as echarts from "echarts";

import carStatistics from "./js/carStatistics.js";
import focusStatistics from "./js/focusStatistics.js";
import otherStatistics from "./js/otherStatistics.js";
import Bg2 from "@screen/components/Decorations/bg-2.vue"
import request from "@/utils/request";

export default {
  name: 'ConditionStatistics',
  components: {
    Bg2
  },
  data() {
    return {
      earlyWarningEvents: {
        day: 0,
        processing: 0,
        month: 0,
        week: 0,
        year: 0,
      }
    }
  },
  created() {
    // 预警事件
    request({
      url: `/business/trafficIncidents/getTrafficIncidentsNum`,
      method: "get",
    })
      .then(({ code, data }) => {
        if (code != 200) return;

        this.earlyWarningEvents = data;
      })
  },
  mounted() {
    setTimeout(() => {
      this.$nextTick(() => {
        const myChart1 = echarts.init(this.$refs.carStatisticsEchartBox);
        myChart1.setOption(carStatistics);
        console.log("charts", carStatistics);

        const myChart2 = echarts.init(this.$refs.focusStatisticsEchartBox);
        myChart2.setOption(focusStatistics);
        console.log("charts", focusStatistics);

        const myChart3 = echarts.init(this.$refs.otherStatisticsEchartBox);
        myChart3.setOption(otherStatistics);
        console.log("charts", otherStatistics);
      });
    });
  }
}
</script>

<style lang='scss' scoped>
.ConditionStatistics {
  position: relative;
  // background: url("~@screen/images/bg/box_bg_003.png") no-repeat;
  // background-size: 100% 100%;
  height: 100%;

  ::v-deep {
    .BackgroundClip.bg {
      padding-top: 51px;
      display: flex;
      flex-direction: column;
      justify-content: space-around;
    }
  }

  // .icon-right {
  //   position: absolute;
  //   right: 23px;
  //   top: 35px;
  // }

  .statistics-header {
    width: 100%;
    position: absolute;
    top: 0;
    display: flex;
    align-items: center;
    width: 100%;
    justify-content: space-between;

    .icon-right {
      margin-right: 24px;
      margin-top: 36px;
    }

    .title {
      width: 240px;
      height: 51px;
      margin-top: 10px;
      margin-left: 10px;
      display: flex;
      align-items: center;
      background: url("~@screen/images/title/title_bg_001.png") no-repeat;
      background-size: 100% 100%;

      span {
        font-size: 30px;
        font-family: YouSheBiaoTiHei;
        font-weight: 400;
        letter-spacing: 2px;
        text-shadow: 0px 5px 0px rgba(0, 0, 0, 0.25);
        background: linear-gradient(180deg, #ffffff 0%, #4dd4ff 100%);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        margin-left: 24px;
      }
    }

  }

  .box-title {
    width: 449px;
    height: 26px;
    margin-top: 24px;
    margin-left: 7px;
    background: url("~@screen/images/title/title_bg_002.png") no-repeat;

    span {
      display: inline-block;
      margin-left: 35px;
      font-size: 16px;
      font-family: Source Han Sans SC, Source Han Sans SC;
      font-weight: 500;
      color: #ffffff;
    }
  }

  .content-r-t-box {

    .box-content {
      display: flex;
      justify-content: space-between;
      margin-top: 22px;

      .box-content-l {
        width: 163px;
        height: 80px;
        margin-top: 21px;
        margin-left: 22px;
        background: url("~@screen/images/bg/box_bg_left.png") no-repeat;
      }

      .box-content-c {
        width: 135px;
        height: 120px;
        background: url("~@screen/images/ybp.png") no-repeat;
        background-size: 100% 100%;
        position: relative;

        .num {
          width: 100%;
          text-align: center;
          position: absolute;
          top: 50px;
          font-size: 18px;
          font-family: 'Hiragino Sans GB', 'Hiragino Sans GB';
          font-weight: 600;
          color: #3de8ff;
          text-shadow: 0px 1px 2px rgba(23, 147, 227, 0.58);
        }

        .text {
          width: 100%;
          text-align: center;
          position: absolute;
          top: 75px;
          // left: 50px;
          margin: auto;
          font-size: 12px;
          font-family: 'Hiragino Sans GB', 'Hiragino Sans GB';
          font-weight: normal;
          color: #ffffff;
        }
      }

      .box-content-r {
        width: 163px;
        height: 80px;
        margin-top: 21px;
        margin-right: 22px;
        background: url("~@screen/images/bg/box_bg_right.png") no-repeat;
        background-size: 100% 100%;
      }

      .event-item {
        display: flex;
        justify-content: center;
        align-items: center;
        width: 124px;
        height: 28px;
        margin-top: 7px;
        margin-left: 12px;
        background: url("~@screen/images/bg/button-bg.png") no-repeat;
        background-size: 100% 100%;
        font-size: 14px;
        font-family: Source Han Sans CN, Source Han Sans CN;
        font-weight: 500;
        color: #ffffff;

        span {
          display: inline-block;
          width: 20px;
          margin-right: 12px;
          font-size: 16px;
          font-family: PangMenZhengDao-3, PangMenZhengDao-3;
          font-weight: 400;
          color: #FFCD4D;
          text-align: left;
          font-style: normal;
          text-transform: none;
        }
      }
    }
  }

  .content-r-c-box {
    .box-content {
      width: 85%;
      margin: 0 auto;
      display: flex;
      justify-content: space-between;

      .count {
        margin-top: 20px;

        .charts {
          width: 120px;
          height: 120px;
          margin: auto;
        }

        .count-item {
          width: 118px;
          height: 26px;
          margin-top: 10px;
          background: url("~@screen/images/bg/button-bg.png") no-repeat;
          background-size: 100% 100%;
          opacity: 1;
          // border: 1px solid;
          display: flex;
          justify-content: center;
          align-items: center;

          // border-image: linear-gradient(
          //     90deg,
          //     rgba(42, 217, 253, 1),
          //     rgba(42, 217, 253, 0)
          //   )
          //   1 1;
          .icon {
            width: 6px;
            height: 6px;
            border-radius: 3px 3px 3px 3px;
            opacity: 1;
          }

          .label {
            display: inline-block;
            margin-left: 5px;
            font-size: 12px;
            font-family: PingFang SC, PingFang SC;
            font-weight: 400;
            color: #ffffff;
          }

          .value {
            display: inline-block;
            // margin-left: 10px;
            font-size: 14px;
            font-family: PangMenZhengDao;
            font-weight: 400;
          }

          .unit {
            display: inline-block;
            margin-left: 5px;
            font-size: 12px;
            font-family: PingFang SC, PingFang SC;
            font-weight: 400;
            color: #ffffff;
          }
        }

        .cars {
          .icon {
            background: #3fd7fe;
          }

          .value {
            color: #3fd7fe;
          }
        }

        .focus {
          .icon {
            background: #ff8820;
          }

          .value {
            color: #ff8820;
          }
        }

        .other {
          .icon {
            background: #29deaf;
          }

          .value {
            color: #29deaf;
          }
        }
      }
    }
  }

  .content-r-b-box {
    margin-top: 30px;

    .box-content {
      .processed {
        display: flex;
        justify-content: center;
        align-items: center;
        margin-top: 20px;

        .text {
          font-size: 14px;
          font-family: PangMenZhengDao;
          font-weight: 400;
          color: #23bee1;
          line-height: 16px;
          letter-spacing: 1px;
        }

        .sections {
          display: flex;
          justify-content: center;
          align-items: center;

          .num-box {
            width: 30px;
            height: 30px;
            background: #047b6e;
            border-radius: 5px 5px 5px 5px;
            opacity: 1;
            border: 1px solid #2fe2cf;
            display: flex;
            justify-content: center;
            align-items: center;

            span {
              font-size: 16px;
              font-family: PangMenZhengDao-3, PangMenZhengDao-3;
              font-weight: 400;
              color: #ffffff;
            }
          }

          .unit {
            display: inline-block;
            margin-left: 10px;
            font-size: 14px;
            font-family: PangMenZhengDao;
            font-weight: 400;
            color: #2fe2cf;
          }
        }

        .kilometer {
          display: flex;
          justify-content: center;
          align-items: center;

          .num-box {
            width: 30px;
            height: 30px;
            background: #583500;
            border-radius: 5px 5px 5px 5px;
            opacity: 1;
            border: 1px solid #f4b149;
            margin-left: 10px;
            display: flex;
            justify-content: center;
            align-items: center;

            span {
              font-size: 16px;
              font-family: PangMenZhengDao-3, PangMenZhengDao-3;
              font-weight: 400;
              color: #ffffff;
            }
          }

          .unit {
            display: inline-block;
            margin-left: 10px;
            font-size: 14px;
            font-family: PangMenZhengDao;
            font-weight: 400;
            color: #f4b149;
          }
        }
      }

      .abnormalList {
        padding-bottom: 20px;

        .listItem {
          width: 410px;
          height: 34px;
          margin: 0 auto;
          margin-top: 10px;
          display: flex;
          justify-content: space-around;
          // align-items: center;
          background: url("~@screen/images/bg/box_total.png") no-repeat;
          font-weight: bold;

          .label {
            width: 220px;
            text-align: right;
            font-size: 12px;
            font-family: 'Hiragino Sans GB', 'Hiragino Sans GB';
            color: #fff;
            line-height: 40px;
            letter-spacing: 7px;
          }

          .value {
            flex: 1;
            width: 0;
            font-family: 'Hiragino Sans GB', 'Hiragino Sans GB';
            line-height: 40px;
            text-align: center;

            .num {
              font-size: 14px;
            }

            .unit {
              font-size: 12px;
              display: inline-block;
              margin-left: 5px;
            }
          }

        }

        .listItem.total {
          .value {
            color: #2fe2cf;
            text-shadow: 0px 1px 4px #2fe2cf;
          }
        }

        .listItem.kilometer {
          .value {
            span {
              font-size: 10px;
            }

            color: #f29600;
            text-shadow: 0px 1px 4px #f29600;
          }
        }

      }
    }
  }
}
</style>