approval-rating.vue
3.4 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<script setup lang="ts" name="ApprovalRating">
// $import
import { defineProps } from "vue";
// $import
// types
interface ApprovalRatingProps {
voteInfo: any;
gameInfo: any;
}
// types
// $props
const props = withDefaults(defineProps<ApprovalRatingProps>(), {
voteInfo: () => ({}),
gameInfo: () => ({}),
});
// $props
</script>
<template>
<div class="approval-rating-section">
<div class="top">
<div>
<span class="team-name">{{ props.gameInfo?.host_name }}</span>
{{ props.voteInfo?.win_num }}%
</div>
<div>支持率</div>
<div>
<span class="team-name">{{ props.gameInfo?.away_name }}</span>
{{ props.voteInfo?.lose_num }}%
</div>
</div>
<div class="rate-range-wrapper">
<div
class="team_logo left"
:style="`margin-left: ${
props.voteInfo?.win_num / 10
}px;background-image: url(${props.gameInfo?.away_photo});`"
></div>
<div
class="team_logo right"
:style="`margin-right: ${
props.voteInfo?.lose_num / 10
}px;background-image: url(${props.gameInfo?.host_photo});`"
></div>
<div :style="`width: ${props.voteInfo?.win_num}%`" class="win">
<span>{{ props.voteInfo?.win }}</span>
</div>
<div
:style="`width: ${props.voteInfo?.draw_num}%; margin-left: ${
-props.voteInfo?.win_num / 10 + props.voteInfo?.lose_num / 10
}px`"
class="draw"
>
<span>{{ props.voteInfo?.draw }}</span>
</div>
<div :style="`width: ${props.voteInfo?.lose_num}%`" class="lose">
<span>{{ props.voteInfo?.lose }}</span>
</div>
</div>
</div>
</template>
<style lang="scss">
@use '@/common/style/common' as *;
.approval-rating-section {
padding: 10px;
padding-bottom: 20px;
background-color: #fff;
border-bottom: #f5f5f5 10px solid;
.top {
padding: 0 4px;
display: flex;
align-items: center;
justify-content: space-between;
font-size: 14px;
.team-name {
color: #999;
}
.look {
@include sc(12px, #b2b2b2);
}
}
.rate-range-wrapper {
position: relative;
padding: 8px 0;
width: 100%;
height: 50px;
display: flex;
align-items: center;
justify-content: space-evenly;
border-radius: 25px;
// overflow: hidden;
.win {
color: #ff3333;
background-color: #ff3333;
border-radius: 20px 6px 6px 50px; /* 左边圆角 */
transform: skewY(-20deg) rotate(20deg);
}
.draw {
color: #00c423;
background-color: #00c423;
border-radius: 6px;
transform: skewY(-20deg) rotate(20deg);
}
.lose {
color: #1f78ff;
background-color: #1f78ff;
border-radius: 6px 50px 20px 6px; /* 右边圆角 */
transform: skewY(-20deg) rotate(20deg);
}
.team_logo {
position: absolute;
width: 26px;
height: 26px;
border-radius: 50%;
background-repeat: no-repeat;
background-size: contain;
background-position: 50%;
transform: translateY(-50%);
z-index: 9;
&.left {
left: 8px;
top: 50%;
}
&.right {
right: 8px;
top: 50%;
}
}
div {
height: 100%;
display: flex;
align-items: flex-end;
justify-content: center;
span {
position: relative;
bottom: -22px;
transform: skewY(20deg) rotate(-20deg);
}
}
}
}
</style>