Ranking.vue 2.75 KB
<template>
  <div>
    <div v-for="(item, index) in rankingsList" :key="index" class="ranking-box-item" @click="goDetailPage(item)">
      <div v-for="(itm, inx) in rankingDataObj" :key="inx">
        <template v-if="inx === 0">
          <div class="ranking-box-item-left">
            <div class="circle" :style="{ 'background-image': index < 3 ? RankColor[index] : '' }">{{ index + 1 }}</div>
            <div class="text">{{ item[itm.name] }}</div>
            <!-- 证书超过滚动显示 -->
            <!-- <template v-if="!isMultiple">
              <marquee class="marquee text" :direction="directionTimer" :delay="delayTimer" :text="item[itm.name]" />
            </template>
            <template v-else>
              <div class="text">{{ item[itm.name] }}</div>
            </template> -->
          </div>
        </template>
        <template v-else>
          <div class="ranking-box-item-right">{{ itm.type == 'number' ? numAddSymbol(item[itm.name]) : item[itm.name] }}</div>
        </template>
      </div>
    </div>
  </div>
</template>

<script>
import datas from '@/utils/data'
export default {
  name: 'Ranking',
  props: {
    // 排名对象值
    rankingsList: {
      type: Array,
      default: () => []
    },
    // 排名对象映射关系
    rankingDataObj: {
      type: Array,
      default: () => []
    },
    // 是否是多个
    isMultiple: {
      type: Boolean,
      default: true
    }
  },
  data() {
    return {
      RankColor: datas.RankColor,
      delayTimer: 3000,
      directionTimer: 3000
    }
  },

  mounted() {},

  methods: {
    // 跳转详情页面
    goDetailPage(item) {
      this.$emit('goDetailPage', item)
    }
  }
}
</script>

<style lang="scss" scoped>
.ranking-box-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 0.89vh;
  box-sizing: border-box;
  &-left {
    display: flex;
    .circle {
      width: 20px;
      height: 20px;
      border-radius: 20px;
      font-size: 14px;
      color: #ffffff;
      text-align: center;
      background: #1e3372;
    }
    .text {
      font-weight: 400;
      font-size: 14px;
      color: #ffffff;
      margin-left: 1.11vw;
      cursor: default;
      max-width: 20.3vw;
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
    }
    .marquee {
      width: 17vw;
      height: 20px;
    }
    .text:hover {
      box-sizing: border-box;
      // padding-bottom: 1px;
      // border-bottom: 1px solid #fff;
      color: #5894FF;
      background-image: -webkit-linear-gradient(left, #24D8FF, #7787FF);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
    }
  }
  &-right {
    font-weight: 400;
    font-size: 14px;
    color: #95acd9;
    text-align: right;
  }
}
</style>