<template>
  <div class="card-panel posi-relative" :style="cardStyle">
    <div class="top-panel text-align-center pb-10">
      <span :class="['icon',icon]">
        <span class="path1"></span>
        <span class="path2"></span>
        <span class="path3"></span>
        dsds
      </span>
    </div>
    <div class="content-panel text-align-center">
      <p class="font-16">{{name}}</p>
      <p class="pt-5">
        <span class="font-16">{{value}}</span>
        <span class="font-14">{{unit}}</span>
      </p>
    </div>
    <div class="line-panel"></div>
    <div class="description-panel">
      <p v-for="(item,idx) of desc" :key="idx">• {{item}}</p>
    </div>
    <div class="btn">
      <div class="btn-panel" :class="{'clickStyle':isClick}" @click="handlerBtnClick">
        <span v-if="btnText!==''">{{btnText}}</span>
        <slot name="btn-text"></slot>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: "card",
  props: {
    width: {
      default: "100%"
    },
    height: {
      default: "240px"
    },
    icon: {
      default: ""
    },
    name: {
      default: ""
    },
    value: {
      default: ""
    },
    unit: {
      default: ""
    },
    desc: {
      default() {
        return [];
      }
    },
    btnText: {
      default: "一键直达"
    }
  },
  computed: {
    cardStyle() {
      return {
        width: this.width,
        height: this.height
      };
    }
  },
  data() {
    return {
      isClick: false
    };
  },
  methods: {
    handlerBtnClick() {
      this.isClick = true;
      this.$emit("click", this.data);
    }
  }
};
</script>
<style scoped lang='scss'>
.card-panel {
  background: #ffffff;
  border: 1px solid #e1e6ea;
  box-shadow: 0 10px 12px 0 rgba(0, 57, 184, 0.1);
  border-radius: 6px;
  padding: 12px 20px;

  .content-panel {
    color: #3e4245;
    padding-bottom: 10px;
  }
  .line-panel {
    height: 1px;
    content: "";
    width: 100%;
    border: 1px solid #eaeaea;
  }
  .description-panel {
    font-size: 12px;
    color: #8a949d;
    p {
      padding-top: 10px;
      word-wrap: break-word;
      word-break: break-all;
      overflow: hidden;
      white-space: normal;
    }
  }
  .btn {
    position: absolute;
    width: 100%;
    margin-left: -20px;
    bottom: 12px;
  }
  .btn-panel {
    margin: 0 20px;
    height: 32px;
    line-height: 32px;
    background: #ecf6ff;
    border: 1px solid #aadcff;
    border-radius: 34px;
    font-size: 14px;
    color: #39acff;
    text-align: center;
    &:hover {
      background: #39acff;
      box-shadow: 0 2px 4px 0 rgba(57, 172, 255, 0.3);
      color: #ffffff;
    }
  }
  .clickStyle {
    background: #39acff;
    box-shadow: 0 2px 4px 0 rgba(57, 172, 255, 0.3);
    color: #ffffff;
  }
}
</style>