<template>
  <div class="card-item" @click="$emit('toDetail', data, index)">
    <div class="left">
      <p class="title">{{ title }}</p>
      <span class="count">
        {{ formatCount }}
        <span>人</span>
      </span>
    </div>
    <div class="right">
      <i class="iconfont icon-jinzitakehu icon"></i>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    title: String,
    count: Number,
    data: Object,
    index: Number
  },
  computed: {
    formatCount() {
      return Number(this.count).toLocaleString();
    }
  }
};
</script>

<style scoped lang="scss">
.card-item {
  padding: 12px;
  width: 250px;
  height: 80px;
  box-sizing: border-box;
  background: rgba(47, 84, 235, 0.04);
  border-radius: 4px;
  border: 1px solid rgba(47, 84, 235, 0.16);
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-width: 0;
  cursor: pointer;
  &:hover {
    box-shadow: 0px 4px 8px 0px rgba(220, 223, 230, 0.6);
  }
  .count {
    font-weight: bold;
    color: #2f54eb;
    font-size: 22px;
    white-space: nowrap;
    font-family: DINAlternate-Bold, DINAlternate;
    span {
      font-size: 14px;
      color: #303133;
    }
  }
  .title {
    color: #303133;
    font-size: 14px;
    margin-bottom: 10px;
  }
  .icon {
    font-size: 40px;
    color: #2f54eb;
    opacity: .14;
  }
}
</style>
