<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-around;
  padding: 20px 15px;
  background: white;
  list-style: none;
  border-radius: 16px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
  margin: 10px 12px 15px;
  position: relative;
  z-index: 10;
}

.overview li {
  text-align: center;
  flex: 1;
  position: relative;
}

.overview li:not(:last-child)::after {
  content: '';
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 1px;
  height: 40px;
  background: linear-gradient(to bottom, transparent, #eee, transparent);
}

.num {
  font-size: 14px;
  margin-bottom: 8px;
  color: #666;
}

.highColor {
  color: #ff6b35;
  font-weight: 700;
  font-size: 26px;
  display: block;
  margin-bottom: 2px;
}

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