<template>
  <div class="d-flex">
    <svg style="position: absolute;" width="0" height="0">
      <defs>
        <linearGradient id="card-item-color" x1="50%" y1="0%" x2="50%" y2="100%">
          <stop offset="0%" stop-color="#00000033"></stop>
          <stop offset="100%" stop-color="#3eb29c66"></stop>
        </linearGradient>
      </defs>
    </svg>
    <dv-border-box-13 v-for="item in items" class="dv-box">
      <div class="card">
        <div class="card-left">
          <p class="card__title">{{ item.text }}</p>
          <p class="card__text">
            <span class="card__text--num">{{ total(item.tag) }}</span>
            <span class="card__text--unit">{{ item.unit }}</span>
          </p>
        </div>
        <div class="card-right">
          <SvgIcon :icon-class="item.icon" class="img"></SvgIcon>

          <div class="img-base">
            <div class="square3"></div>
            <div class="square1"></div>
            <div class="square2"></div>
          </div>
        </div>
      </div>
    </dv-border-box-13>
  </div>
</template>

<script>
import SvgIcon from "@/components/SvgIcon"
export default {
  components: {
    SvgIcon
  },
  data() {
    return {
      items: [
        {
          text: "资产总量",
          num: 36650,
          tag: "total",
          unit: "平方",
          icon: "zichan"
        },
        {
          text: "土地资产",
          num: 99966,
          unit: "平方米",
          tag: "land",
          icon: "tudi"
        },
        {
          text: "汇总数据",
          num: 8888,
          unit: "",
          tag: "static",
          icon: "fangwu"
        }
      ]
    }
  },
  methods: {},
  computed: {
    total () {
      return function(tag) {
        let total = 0;
        const [houses,lands] = this.$store.state.bigdata.assets
        switch (tag) {
          case "total":
            total += houses.reduce((a,b) => a + parseFloat(b.dengjimianji ?? 0),0)
            total += lands.reduce((a,b) => a + parseFloat(b.dengjimianji ?? 0),0)
            return total.toFixed(2);
          case "land":
            total += lands.reduce((a,b) => a + parseFloat(b.dengjimianji ?? 0),0)
            return total.toFixed(2);
          case "static":
            return `土地 ${lands.length}处，房产 ${houses.length}处`;
          default:
            return total.toFixed(2);
        }
      }
    }
  }
}
</script>

<style scoped lang="scss">
.card {
  display: flex;
  align-items: center;
  justify-content: space-between;

  padding: 20px 22px;
  &__title {
    line-height: 2;
    font-size: 22px;
    font-weight: 600;
    color: #73f3df;
    padding: 6px 0;
  }
  &__text {
    color: #fff;
    font-size: 20px;

    &--num {
      font-size: 28px;
      font-weight: 600;
      padding-right: 6px;
    }
  }
  & > .card-right {
    z-index: 2;
    position: relative;
    top: 0;
    & > .img {
      color: #73f3e0;
      width: 54px;
      height: 54px;
      z-index: 3;
      transform: translate(-19px,-10px);
      position: relative;
    }
    .img-base {
      width: 100%;
      perspective: 200px;

      z-index: 1;
      position: absolute;
      left: -12px;
      bottom: -14px;

      .square1 {
        background: linear-gradient(135deg, #00000066 ,#4fa497);
        width: 40px;
        height: 40px;
        box-shadow: 0 0 2px 2px #7ddacd;
        transform: rotateX(45deg) rotateZ(45deg)skew(-15deg, -15deg);
        position: relative;
        &::after {
          content: "";
          width: 146%;
          height: 146%;
          filter: drop-shadow(2px 2px 6px #9ce8de);
          background: transparent;
          border: 3px solid #25aba8;
          position: absolute;
          left: -22%;
          top: -22%;
        }
      }
      .square2 {
        background: linear-gradient(135deg, #ffffff33 , #1da4a1);
        width: 52px;
        height: 50px;
        transform: rotateX(45deg) rotateZ(45deg)skew(-15deg, -15deg);
        box-shadow: 0 0 2px 2px #86bdb5;
        position: absolute;
        left: -6px;
        top: -16px;
      }
      .square3 {
        content: "";
        width: 104px;
        height: 46px;
        background: linear-gradient(to bottom, #00000022 , #61b9ac66);
        filter: drop-shadow(0 2px 6px #9ce8de);
        position: absolute;
        left: -32px;
        bottom: 20px;
      }
      //&::before {
      //  content: "";
      //  width: 100%;
      //  height: 100%;
      //  background: linear-gradient(to bottom, #00000033 , #61b9ac);
      //  filter: drop-shadow(0 2px 6px #9ce8de);
      //  transform: translateY(-96%);
      //  position: absolute;
      //  left: 0%;
      //  top: 0;
      //}
      //.square1 {
      //  background: linear-gradient(to bottom, #00000033 ,#4fa497);
      //  width: 100%;
      //  height: 34px;
      //  box-shadow: 0 0 2px 2px #7ddacd;
      //  transform: rotateX(45deg);
      //  position: relative;
      //
      //  &::after {
      //    content: "";
      //    width: 120%;
      //    height: 136%;
      //    filter: drop-shadow(0 4px 6px #9ce8de);
      //    background: transparent;
      //    border: 2px solid #7ddacd;
      //    position: absolute;
      //    left: -10%;
      //    top: -18%;
      //  }
      //}
    }
  }
}
.dv-box + .dv-box {
  margin-left: .5rem;
}
</style>
<style>
.dv-box path:nth-child(1) {
  fill: url(#card-item-color);
}
</style>
