<template>
  <div class="top10">
      <template v-if="data.length">
        <div v-for="(item,index) in data" :key="index" class="item">
        <span class="num" :class="'num'+index">
          {{index+1}}
        </span>
          <span>
          {{item.userName}}
        </span>
          <CountUp :endVal="item.in" :duration="3"/>
        </div>
      </template>
    <EmptyCom v-else></EmptyCom>
  </div>
</template>
<script setup lang="ts">
import {ref, onMounted, onUnmounted, watch} from "vue";
import mittBus from "@/utils/mitt";
import EmptyCom from "@/components/empty-com";
import CountUp from "@/components/count-up";
const data = ref([]);
const props = defineProps({
  content: {
    type: Array,
    default: () => [],
  },
});
watch(
  () => props.content,
  (newData:any) => {
    data.value = newData;
  }
);
onMounted(() => {
  mittBus.on('BsSeatStateDataShowArea2', (res: any) => {
    data.value = res;
  });
});
onUnmounted(() => {
  mittBus.off('BsSeatStateDataShowArea2');
});
</script>
<style scoped lang="scss">
.top10{
  margin-top: 10px;
  height: calc(100% - 10px);
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  transition: max-height .3s ease-in;
  transform-origin: 50% 0;
  animation: slide-down 0.3s ease-in;
 .item{
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 10px;
    &:nth-child(even){
      background-color: rgba(255,255,255,.1);
    }
  }
  .item{
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 30px;
    line-height: 30px;
    padding: 0 10px;
    &:nth-child(even){
      background-color: rgba(255,255,255,.1);
    }
    .num{
      display: inline-block;
      width: 30px;
      height: 20px;
      line-height: 20px;
      text-align: center;
      color: #fff;
      background-color: var(--el-color-primary);
      border-radius: 5px;
      &:before{
        content: "";
        width: 0;
        height: 0;
        border-top: 10px solid transparent;
        border-bottom: 10px solid transparent;
        border-left: 10px solid var(--el-color-primary);
        position: absolute;
        left: 52px;
      }
    }
    .num0{
      display: inline-block;
      width: 30px;
      height: 20px;
      line-height: 20px;
      text-align: center;
      color: #fff;
      background-color: var(--el-color-danger);
      border-radius: 5px;
      &:before{
        content: "";
        width: 0;
        height: 0;
        border-top: 10px solid transparent;
        border-bottom: 10px solid transparent;
        border-left: 10px solid var(--el-color-danger);
        position: absolute;
        left: 52px;
      }
    }
    .num1{
      display: inline-block;
      width: 30px;
      height: 20px;
      line-height: 20px;
      text-align: center;
      color: #fff;
      background-color: var(--el-color-warning);
      border-radius: 5px;
      &:before{
        content: "";
        width: 0;
        height: 0;
        border-top: 10px solid transparent;
        border-bottom: 10px solid transparent;
        border-left: 10px solid var(--el-color-warning);
        position: absolute;
        left: 52px;
      }
    }
    .num2{
      display: inline-block;
      width: 30px;
      height: 20px;
      line-height: 20px;
      text-align: center;
      color: #fff;
      background-color: var(--el-color-success);
      border-radius: 5px;
      &:before{
        content: "";
        width: 0;
        height: 0;
        border-top: 10px solid transparent;
        border-bottom: 10px solid transparent;
        border-left: 10px solid var(--el-color-success);
        position: absolute;
        left: 52px;
      }
    }
  }
}
</style>
