<template>
  <div>
    <div class="zr-infobox" v-if="toShow == '1'">
      <div class="zr-infotitle">
        {{ prefix }}<b class="info-num">{{ num }}</b
        >{{ append }}
      </div>
      <slot></slot>
    </div>
    <div class="info-plate2" v-if="toShow == '2'">
      <div
        class="info-plate2-li"
        v-for="(item, index) in itemOption"
        :key="index"
        :style="item.goTo ? 'cursor: pointer;' : 'cursor: auto;'"
        @click="goTo(item)"
      >
        <div v-if="item.type">
          <div class="top-t">
            <div class="li_tt">
              <span>{{ item.key }}</span>
              <span class="info" v-if="item.info">
                <el-tooltip
                  class="item"
                  effect="light"
                  placement="right"
                  popper-class="gray-type gray-type-census"
                >
                  <div slot="content">{{ item.info }}</div>
                  <el-link
                    icon="el-icon-question"
                    type="warning"
                    :underline="false"
                  ></el-link>
                </el-tooltip>
              </span>
              <span style="margin-left: auto" v-if="item.goTo">
                <i class="el-icon-arrow-right"></i>
              </span>
            </div>
            <span class="span" v-if="item.value"
              ><span class="symbol" v-if="item.symbol">￥</span
              >{{ item.value | toThousandFilter }}</span
            >
          </div>
          <div class="bottom-t">
            <div
              v-for="(item1, index1) in item.items"
              :key="index1"
              class="info-plate2-li"
            >
              <div class="li_tt">
                <span>{{ item1.key }}</span>
                <span class="info" v-if="item1.info">
                  <el-tooltip
                    class="item"
                    effect="light"
                    placement="right"
                    popper-class="gray-type gray-type-census"
                  >
                    <div slot="content">{{ item1.info }}</div>
                    <el-link
                      icon="el-icon-question"
                      type="warning"
                      :underline="false"
                    ></el-link>
                  </el-tooltip>
                </span>
                <span style="margin-left: auto" v-if="item1.goTo">
                  <i class="el-icon-arrow-right"></i>
                </span>
              </div>
              <span class="span">
                <span class="symbol" v-if="item1.symbol">￥</span>
                {{ item1.value | toThousandFilter }}
                <span v-if="item1.rate_icon">{{ item1.rate_icon }}</span>
                <span
                  :class="
                    +item1.value > 0
                      ? 'price_new_green font-weight'
                      : 'price_new_orange font-weight'
                  "
                  v-if="item1.change_trend">{{ item1.change_trend }}</span>
              </span>
            </div>
          </div>
        </div>
        <div v-else>
          <div class="li_tt">
            <span>{{ item.key }}</span>
            <span class="info" v-if="item.info">
              <el-tooltip
                class="item"
                effect="light"
                placement="right"
                popper-class="gray-type gray-type-census"
              >
                <div slot="content">{{ item.info }}</div>
                <el-link
                  icon="el-icon-question"
                  type="warning"
                  :underline="false"
                ></el-link>
              </el-tooltip>
            </span>
            <span style="margin-left: auto" v-if="item.goTo">
              <i class="el-icon-arrow-right"></i>
            </span>
          </div>
          <span class="span"
            ><span class="symbol" v-if="item.symbol">￥</span
            >{{ item.value | toThousandFilter }}</span
          >
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    prefix: {
      type: String,
      default: "",
    },
    num: {
      type: Number,
      default: 0,
    },
    append: {
      type: String,
      default: "",
    },
    toShow: {
      //展现形式
      type: String | Number,
      default: "1",
    },
    itemOption: {
      type: Array,
      default: () => [],
    },
  },
  data() {
    return {};
  },
  methods: {
    goTo(item){
       if (item.goTo) {
        this.$router.push({
            name: item.goTo
        });
      }
    }
  },
};
</script>

<style lang="less" scoped>
.zr-infobox {
  display: flex;
  align-items: center;
  font-size: 14px;
  color: #666;
  line-height: 24px;
  margin-bottom: 5px;
  .zr-infotitle {
    margin-right: 20px;
    position: relative;
    top: -1px;
    .info-num {
      font-size: 18px;
      margin: 0 5px;
      color: #333;
    }
  }
}
.info-plate2 {
  background: #fff;
  display: flex;
  justify-content: space-around;
  align-items: center;
  flex-wrap: wrap;
  padding: 20px 0;
  margin-top: 10px;
  margin-bottom: 10px;
  background: #f7f8fa;
  .info-plate2-li {
    text-align: center;
    position: relative;
    flex: 1;
    border-right: 2px solid #eee;
    &:last-child {
      border-right: none;
    }
    .info .item {
      vertical-align: top;
      font-size: 16px;
    }
    .li_tt {
      font-size: 16px;
      margin-bottom: 10px;
    }
    .span {
      font-size: 25px;
      font-family: "DIN";
      font-weight: bold;
      color: #6590ff;
      .symbol {
        font-size: 16px;
        font-weight: normal;
      }
    }
    .top-t {
      border-bottom: 2px solid #eee;
      padding-bottom: 10px;
      margin: 10px;
    }
    .bottom-t {
      display: flex;
      align-items: center;
      margin-top: 15px;
      .span {
        font-size: 18px;
        color: #333333;
      }
    }
  }
}
</style>