<template>
  <div class="hot">
    <!-- 标题区域 -->
    <div class="hot_title">
      <div class="title_text">销售热榜TOP3</div>
      <img src="@/assets/images/33.png" />
    </div>

    <!-- 列表区域 -->
    <div class="hot_list">
      <!-- 每一个盒子区域 -->
      <div class="hot_item" v-for="(item, index) in list" :key="item.id">
        <div class="item_info">
          <div class="info_rank">TOP{{ index + 1 }}</div>
          <div class="info_name">{{ item.name }}</div>
          <div class="info_num" ref="infoNum" :data-value="item.num">
            {{ item.num }}
          </div>
        </div>
        <div class="item_progress">
          <el-progress
            :stroke-width="12"
            :percentage="item.rate"
            :show-text="false"
          />
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from "vue";
import { countUpNum } from "@/utils/countUpNum.ts";

// Dom元素数组
const infoNum = ref();

const list = ref([
  {
    id: 1,
    name: "靖安白茶",
    num: 8563,
    rate: 50,
  },
  {
    id: 2,
    name: "靖安柑橘",
    num: 6532,
    rate: 30,
  },
  {
    id: 3,
    name: "靖安泉水",
    num: 2365,
    rate: 20,
  },
]);

onMounted(() => {
  infoNum.value.forEach((ele: any) => {
    countUpNum(ele, ele.dataset.value);
  });
});
</script>

<style lang="scss" scoped>
.hot {
  width: 100%;
  height: 100%;

  .hot_title {
    position: relative;
    width: 548px;
    height: 41px;
    line-height: 41px;

    .title_text {
      position: absolute;
      left: 15px;
      z-index: 1;
      font-size: 23.5px;
      font-weight: bold;
      color: #e0efff;
    }

    img {
      position: absolute;
      left: 0;
      bottom: 0;
      width: 548px;
      height: 16px;
    }
  }

  .hot_list {
    margin-top: 40px;
    width: 100%;
    height: 228px;

    .hot_item {
      margin-bottom: 20px;

      .item_info {
        display: flex;
        align-items: center;
        width: 100%;
        height: 28px;
        font-size: 21px;
        color: #75bcff;

        .info_rank {
          color: #3bfcff;
        }

        .info_name {
          margin-left: 5px;
        }

        .info_num {
          margin-left: auto;
        }
      }

      .item_progress {
        margin-top: 15px;
        width: 100%;
        height: 18px;
      }
    }
  }
}

::v-deep(.el-progress-bar__outer) {
  background: linear-gradient(
    180deg,
    rgba(43, 47, 57, 1) 0%,
    rgba(26, 29, 40, 1) 100%
  );
  box-shadow: inset 0px 1px 3px rgba(116, 129, 163, 0.5);
}

::v-deep(.el-progress-bar__inner) {
  background: linear-gradient(
    90deg,
    rgba(38, 42, 52, 1) 0%,
    rgba(69, 164, 196, 1) 44.47%,
    rgba(78, 185, 242, 1) 100%
  );
}

::v-deep(.el-progress-bar__inner::after) {
  width: 4px;
  height: 150%;
  background-color: #fff;
}
</style>
