Ranking.vue
3.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<template>
<div>
<div v-for="(item, index) in rankingsList" :key="index" class="ranking-box-item">
<div v-for="(itm, inx) in rankingDataObj" :key="inx">
<template v-if="inx === 0">
<div class="ranking-box-item-left" @click="goDetailPage(item)">
<div class="circle" :style="{ 'background-image': index < 3 ? RankColor[index] : '' }">{{ index + 1 }}</div>
<div class="text" :class="itm.action ? 'action-text' : ''" :style="{ width: itm.width }">{{ item[itm.name] }}</div>
</div>
</template>
<template v-else-if="inx !== rankingDataObj.length - 1">
<div class="ranking-box-item-middle" :style="{ width: itm.width, color: itm.color }">
{{ itm.preunit }}{{ item[itm.name] }}{{ itm.sufunit }}
</div>
</template>
<template v-else>
<div class="ranking-box-item-right" :style="{ width: itm.width, color: itm.color }">
{{ itm.preunit }}{{ itm.type == 'number' ? numAddSymbol(item[itm.name]) : itm.type == 'decimal' ? toPercent(item[itm.name]) : item[itm.name] }}{{ itm.sufunit }}
</div>
</template>
</div>
</div>
</div>
</template>
<script>
import datas from '@/utils/data'
export default {
name: 'Ranking',
props: {
// 排名对象值
rankingsList: {
type: Array,
default: () => []
},
/**
* 排名对象映射关系
* name: 字段名称
* width: 字段长度
* color: 字段颜色
* preunit: 字段前图标、字
* sufunit: 字段后图标、字
* type: 字段类别 --number、decimal
*/
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: 12px;
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;
}
.action-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;
}
}
&-middle {
font-weight: 400;
font-size: 12px;
color: #C0C0C0;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
&-right {
font-weight: 400;
font-size: 12px;
color: #95acd9;
text-align: right;
}
}
</style>