<template>
  <div class="bases">
    <div class="item" v-for="(item, i) in items" :key="i" @click="getItem(item)">
      <div class="inner">
        <img :src="getImgUrl(item.icon)" class="icon" />
        <div class="info">
          <p class="name">{{ item.name }}</p>
          <p class="count">{{ item.count.toLocaleString() }}</p>
        </div>
      </div>
    </div>
    <div class="clearfix"></div>
  </div>
</template>

<script setup>
import { getImgUrl } from "@/utils/tools.js"
const props = defineProps({ items: Array, num: Number })
const emit = defineEmits(["getItem"])
const getItem = item => {
  emit("getItem", item)
}
</script>
<style lang="scss" scoped>
.bases {
  display: flex;
  justify-content: start;
  flex-wrap: wrap;

  .item {
    width: 347px;
    float: left;
    padding: 5px;
    cursor: pointer;

    .inner {
      background: #d2f2e5;
      border-radius: 4px;
      padding: 5px 20px;
      display: flex;

      .icon {
        width: 60px;
        height: 60px;
        border: none;
        margin-top: 3px;
      }

      .info {
        flex: 1;
        color: #333;

        p {
          padding-left: 30px;
          margin: 0;

          &.name {
            font-size: 18px;
            margin: 7px 0;
          }

          &.count {
            font-size: 24px;
            font-weight: 500;
          }
        }
      }
    }
  }
}
</style>
