1
1
<template >
2
- <div
3
- v-if =" show"
4
- :class =" prefixCls"
5
- >
6
- <div :class =" `${prefixCls}-label`" >
2
+ <div v-if =" show" class =" c-rank-users-component" >
3
+ <div class =" label" >
7
4
<h6 >{{ title }}</h6 >
8
- <div
9
- :class =" `${prefixCls}-more`"
10
- @click =" to(listUrl)"
11
- >
5
+ <div class =" label-more" @click =" to(listUrl)" >
12
6
<span >全部</span >
13
7
<svg class =" m-style-svg m-svg-small" >
14
8
<use xlink:href =" #icon-arrow-right" />
15
9
</svg >
16
10
</div >
17
11
</div >
18
- <div : class =" `${prefixCls}- label` " >
12
+ <div class =" label" >
19
13
<div
20
14
v-for =" user in getShow"
21
15
:key =" user.id"
22
- : class =" `${prefixCls}- user m-aln-st` "
16
+ class =" user-list m-aln-st"
23
17
@click =" to(`/users/${user.id}`)"
24
18
>
25
- <Avatar
26
- :class =" `${prefixCls}-user-avatar`"
27
- :user =" user"
28
- />
29
- <p class =" m-flex-grow1 m-flex-shrink1 m-text-cut" >{{ user.name }}</p >
19
+ <Avatar class =" avatar" :user =" user" />
20
+ <p class =" m-text-cut user-name" >{{ user.name }}</p >
30
21
</div >
31
22
</div >
32
23
</div >
33
24
</template >
34
25
35
26
<script >
36
- const prefixCls = ' rank-list-item'
37
27
export default {
38
28
name: ' RankUsersComponent' ,
39
29
props: {
@@ -42,31 +32,19 @@ export default {
42
32
title: { type: String , required: true },
43
33
name: { type: String , required: true },
44
34
},
45
-
46
35
data () {
47
36
return {
48
- prefixCls,
49
37
users: [],
50
38
}
51
39
},
52
-
53
40
computed: {
54
- /**
55
- * 是否展示该排行模块
56
- * @Author Wayne
57
- * @DateTime 2018-01-04
58
- * @Email qiaobin@zhiyicx.com
59
- * @return Boolean
60
- */
61
41
show () {
62
42
return this .users .length > 0
63
43
},
64
44
/**
65
45
* 获取前个要被展示的用户
66
46
* @Author Wayne
67
- * @DateTime 2018-01-04
68
47
* @Email qiaobin@zhiyicx.com
69
- * @return Array
70
48
*/
71
49
getShow () {
72
50
return this .users .slice (0 , 5 )
@@ -75,19 +53,15 @@ export default {
75
53
activated () {
76
54
this .getUsers ()
77
55
},
78
-
79
56
methods: {
80
57
to (path ) {
81
58
if (path) {
82
59
this .$router .push ({ path })
83
60
}
84
61
},
85
-
86
62
getUsers () {
87
63
this .$http
88
- .get (this .api , {
89
- validateStatus : status => status === 200 ,
90
- })
64
+ .get (this .api , { validateStatus : status => status === 200 })
91
65
.then (({ data = [] }) => {
92
66
this .users = [... data]
93
67
this .$store .commit (' SAVE_RANK_DATA' , { name: this .name , data })
@@ -99,33 +73,47 @@ export default {
99
73
</script >
100
74
101
75
<style lang="less" scoped>
102
- @rank-list-prefixCls : rank- list- item;
103
76
104
- .@{ rank-list-prefixCls} {
77
+ .c- rank-users-component {
105
78
background-color : #fff ;
79
+
106
80
& + & {
107
81
margin-top : 8px ;
108
82
}
109
- &-label {
110
- & :nth- child(2 ) {
111
- height : 164px ;
112
- margin-left : -30px ;
113
- justify-content : flex-start ;
114
- padding-bottom : 10px ;
115
- }
83
+
84
+ .label {
116
85
font-size : 26px ;
117
86
padding : 0 30px ;
118
87
height : 70px ;
119
88
display : flex ;
120
89
align-items : center ;
121
90
justify-content : space-between ;
122
91
92
+ & :nth- child(2 ) {
93
+ height : 164px ;
94
+ margin-left : -30px ;
95
+ justify-content : flex-start ;
96
+ padding-bottom : 10px ;
97
+ }
98
+
123
99
h6 {
124
100
font-size : 30px ;
125
101
color : #333 ;
126
102
}
103
+
104
+ .label-more {
105
+ display : flex ;
106
+ align-items : center ;
107
+
108
+ span {
109
+ margin : 0 5px ;
110
+ color : #999 ;
111
+ font-size : 24px ;
112
+ }
113
+ }
127
114
}
128
- &-user {
115
+
116
+ .user-list {
129
117
overflow : hidden ;
130
118
font-size : 24px ;
131
119
width : calc (~ " 20% - " 30px );
@@ -135,9 +123,10 @@ export default {
135
123
flex-direction : column ;
136
124
text-align : center ;
137
125
138
- &- avatar {
126
+ . avatar {
139
127
width : 100px ;
140
128
height : 100px ;
129
+
141
130
span {
142
131
color : #666 ;
143
132
width : 100% ;
@@ -148,14 +137,11 @@ export default {
148
137
height : 100px ;
149
138
}
150
139
}
151
- }
152
- &-more {
153
- display : flex ;
154
- align-items : center ;
155
- span {
156
- margin : 0 5px ;
157
- color : #999 ;
158
- font-size : 24px ;
140
+
141
+ .user-name {
142
+ flex : auto ;
143
+ margin-top : 10px ;
144
+ max-width : 4em ;
159
145
}
160
146
}
161
147
0 commit comments