<template>
  <div class="sub_title" style="margin-bottom: 14px;">组排名</div>
  <div class="group-rankings">
    <div :class="`group-rankings-item ${getClassName(index)}`" :style="index > 2? 'display:none':'' " v-for="(item,index) in groupRankList" :key="index">
      <div class="group-mark">
        <span class="other-number" v-if="index > 2">{{ index+1 }}</span>
      </div>
      <div class="group-content">
        <div class="title">{{item.Name? item.Name: '【暂无组名】'}}</div>
        <div class="statistics">
          <div class="statistics-left">
            <div class="mark">
              <div class="other-mark" v-if="index > 2"></div>
            </div>
            <div class="quantity">{{item.count}}</div>
          </div>
          <div class="statistics-right">
            <div class="mark">
              <div class="other-mark" v-if="index > 2"></div>
            </div>
            <div class="quantity" v-if="false"></div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { onMounted, ref, defineProps, watch } from "vue"
import { GetGroupRankingList } from '@/api/demo/taskhall'

const props = defineProps(['getValueType'])

watch(() => props.getValueType, () => {
  getValue()
})

onMounted(() => {
  getValue()
})

const getValue = () => {
  GetGroupRankingList().then(res => {
    groupRankList.value = res
  })
}

const groupRankList = ref<{Name:string;count:number}[]>([])

const getClassName = (index) => {
  switch(index){
    case 0: return 'first-group'
    case 1: return 'second-group'
    case 2: return 'third-group'
    default: return 'other'
  }
}
</script>

<style lang="scss" scoped>
.group-rankings{
  width: 472px;
  height: 223px;
  margin-bottom: 10px;
  overflow: auto;
  scrollbar-width: none; 
  ::-webkit-scrollbar {
    width: 0;
    height: 0;
  }
  .first-group{
    .group-mark{
      background-image: url('/public/taskhall/first_group_mark.png');
    }
    .statistics-left{
      display: flex;
      .mark{
        background-image: url('/public/taskhall/first_group_mark_s.png');
      }
    }
    .statistics-right{
      display: flex;
      .mark{
        background-image: url('/public/taskhall/first_group_mark_m.png');
      }
    }
  }
  .second-group{
    .group-mark{
      background-image: url('/public/taskhall/second_group_mark.png');
    }
    .statistics-left{
      display: flex;
      .mark{
        background-image: url('/public/taskhall/second_group_mark_s.png');
      }
    }
    .statistics-right{
      display: flex;
      .mark{
        background-image: url('/public/taskhall/second_group_mark_m.png');
      }
    }
  }
  .third-group{
    .group-mark{
      background-image: url('/public/taskhall/third_group_mark.png');
    }
    .statistics-left{
      display: flex;
      .mark{
        background-image: url('/public/taskhall/third_group_mark_s.png');
      }
    }
    .statistics-right{
      display: flex;
      .mark{
        background-image: url('/public/taskhall/third_group_mark_m.png');
      }
    }
  }
  .group-rankings-item{
    width: 472px;
    height: 70px;
    background-image: url('/public/taskhall/group_rankings_item_background.png');
    background-size: contain;
    background-repeat: no-repeat;
    padding-left: 6px;
    display: flex;
    margin-bottom: 4px;
    .group-mark{
      width: 70px;
      height: 70px;
      display: flex;
      align-items: center;
      justify-content: center;
      .other-number{
        font-family: DINPro;
        font-weight: 500;
        font-size: 29px;
        color: #FFFFFF;
        user-select: none;
      }
    }
    .group-content{
      padding-top: 13px;
      padding-left: 12px;
      flex: 1;
      .title{
        font-family: AlibabaPuHuiTiM;
        font-weight: 500;
        font-size: 16px;
        color: #FFFFFF;
        margin-bottom: 8px;
        line-height: 15px;
      }
      .statistics{
        height: 26px;
        display: flex;
        align-items: center;
        .mark{
          width: 22px;
          height: 26px;
          // background-image: url('/public/taskhall/first_group_mark_m.png');
          margin-right: 10px;
          user-select: none;
          display: flex;
          align-items: center;
          justify-content: center;
          .other-mark{
            width: 8px;
            height: 8px;
            background: #036CFF;
            border-radius: 50%;
          }
        }
        .quantity{
          font-family: DINPro;
          font-weight: 500;
          font-size: 20px;
          color: #FFFFFF;
          width: 136px;
          user-select: none;
        }
        .statistics-left{
          display: flex
        }
        .statistics-right{
          display: flex
        }
      }
    }
  }
  .group-rankings-item:last-child{
    margin-bottom: 0px;
  }
}
</style>
