<template>
  <ul class="overview">
    <li>
      <p class="num">
        <span class="highColor">{{ data.times }}</span>次
      </p>
      <span class="label">服务次数</span>
    </li>
    <li>
      <p class="num">
        <span class="highColor">{{ data.duration }}</span>小时
      </p>
      <span class="label">服务时长</span>
    </li>
    <li>
      <p class="num">
        <span class="highColor">{{ data.score }}</span>分
      </p>
      <span class="label">服务积分</span>
    </li>
  </ul>
</template>

<script>
import axios from "axios";

export default {
  props: ["year"],
  data() {
    return {
      data: {},
    };
  },
  methods: {
    fetchYearScore() {
      const that = this;
      const year = this.year;
      axios
        .get("/api/service/yearScore", {
          params: { year },
        })
        .then(function (response) {
          const { error, data = {} } = response.data;
          if (error === 0) {
            that.data = data || {};
          }
        });
    },
  },
  watch: {
    year() {
      this.fetchYearScore();
    },
  },
};
</script>

<style scoped>
.overview {
  display: flex;
  justify-content: space-between;
  padding: 15px;
  background: white;
  list-style: none;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  margin-bottom: 5px;
}

.overview li {
  text-align: center;
}

.num {
  font-size: 20px;
  margin-bottom: 8px;
}

.highColor {
  color: #ff5d23;
  font-weight: bold;
}

.label {
  color: #666;
  font-size: 12px;
}
</style>
