StatisticBox.vue 3.72 KB
<template>
    <div class="statistics">
        <div class="statistics-item" v-for="(item, index) in list" :key="index" :style="{'width': 100 / list.length + '%'}">
          <div class="statistics-top">
            <div class="statistics-name">{{item.name}}</div>
            <div class="statistics-price"><span class="statistics-unit" v-if="item.unitType == 'left'">{{item.unit}}</span><span class="statistics-price-number">{{numAddSymbol(item.value)}}</span><span v-if="item.unitType == 'right'">{{item.unit}}</span></div>
            <div v-if="item.rate" class="statistics-top-rate">占比<span>{{item.rate}}%</span></div>
          </div>
          <div class="statistics-bottom" v-if="item.bottomLabel || item.bottomType">
            <template v-if="item.bottomType == 'money'">
              <span> {{item.bottomLabel}}</span>
              <span>¥{{numAddSymbol(item.bottomValue)}}</span>
            </template>
            <template v-else-if="item.bottomType == 'slot'">
              <slot :name="item.valueName" :[item.valueName]="item"></slot>
            </template>
            <template v-else-if="item.bottomType == 'ratio'">
              <div class="ratio">
                <div class="ratio-left">{{item.ratioLeftLabel}}<span :class="item.ratioLeftValue > 0 ? 'positive' : 'negative'">{{item.ratioLeftValue}}%</span></div>
                <div class="ratio-right">{{item.ratioRightLabel}}<span :class="item.ratioRightValue > 0 ? 'positive' : 'negative'">{{item.ratioRightValue}}%</span></div>
              </div>
            </template>
            <template v-else>
              <span>{{item.bottomLabel}}</span>
              <span>{{numAddSymbol(item.bottomValue)}}</span>
            </template>
          </div>
        </div>
      </div>
  </template>
  
  <script>
  export default {
    name: 'StatisticsBox',
    props: {
      list: {
        type: Array
      }
      // bottomType: {
      //   type: String,
      //   default: 'default'
      // }
    },
    data() {
      return {
      }
    },
  
    mounted() {},
  
    methods: {}
  }
  </script>
  
  <style lang="scss" scoped>
  .statistics {
    display: flex;
    color: #fff;
    height: 11.78vh;
    &-item {
      padding: 0.89vh 0.53vw;
      margin-right: 1.11vw;
      background: #061422;
      box-shadow: inset 0 0 20px 0 #3d57ff69;
      &:last-child {
        margin-right: 0;
      }
    }
    &-top {
      position: relative;
      padding-left: 0.3vw;
      &-rate {
        position: absolute;
        right: 0;
        top: 0;
        font-size: 12px;
        color: #95ACD9;
        span {
          color: #EB6001;
        }
      }
    }
    &-name {
      font-weight: 500;
      font-size: 14px;
      margin-bottom: 0.89vh;
      height: 2.22vh;
    }
    &-unit {
      padding-right: 0.56vw;
    }
    &-price {
      display: flex;
      align-items: center;
      color: #25D6FF;
      font-weight: 600;
      font-size: 14px;
      height: 3.11vh;
      &-number {
        padding-right: 0.56vw;
        font-size: 20px;
        color: #5894FF;
        background-image:-webkit-linear-gradient(left,#24D8FF,#7787FF);
        -webkit-background-clip:text;
        -webkit-text-fill-color:transparent;
      }
    }
    &-bottom {
      display: flex;
      justify-content: space-between;
      font-size: 12px;
      color: #95ACD9;
      border-top: 1px solid #2A3D72;
      padding: 0.89vh 0.3vw 0;
      margin-top: 0.89vh;
      .ratio {
        display: flex;
        width: 100%;
        justify-content: space-between;
        .positive,
        .negative{
          display: inline-block;
          margin-left: 0.28vw;
        }
        .positive {
          color: #EB6001;
        }
        .negative {
          color: #16E193;
        }
      }
    }
  }
  </style>