group-member-list.vue
4.29 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
<template>
<div class="group-member-list-wrapper">
<div class="header">
<span class="member-count text-ellipsis">群成员:{{currentConversation.groupProfile.memberCount}}</span>
</div>
<div class="scroll-content">
<div class="group-member-list">
<el-checkbox-group v-model="callingList" @change="handleCheckedMembersChange">
<el-checkbox v-for="member in members" :disabled="member.userID===userID" :label="member.userID" :key="member.userID">
<div class="group-member">
<avatar :title=getGroupMemberAvatarText(member.role) :src="member.avatar" />
<div class="member-name text-ellipsis">
<span v-if="member.nameCard" :title=member.nameCard>{{ member.nameCard }}</span>
<span v-else-if="member.nick" :title=member.nick>{{ member.nick }}</span>
<span v-else :title=member.userID>{{ member.userID }}</span>
</div>
</div>
</el-checkbox>
</el-checkbox-group>
</div>
</div>
<div class="more">
<el-button v-if="showLoadMore" type="text" @click="loadMore">查看更多</el-button>
</div>
</div>
</template>
<script>
import { mapState } from 'vuex'
export default {
data() {
return {
callingList:[],
addGroupMemberVisible: false,
currentMemberID: '',
count: 30 // 显示的群成员数量
}
},
components: {
},
computed: {
...mapState({
userID: state => state.user.userID,
currentConversation: state => state.conversation.currentConversation,
currentMemberList: state => state.group.currentMemberList
}),
showLoadMore() {
return this.members.length < this.currentConversation.groupProfile.memberCount
},
members() {
return this.currentMemberList.slice(0, this.count)
}
},
methods: {
handleCheckedMembersChange() {
this.$emit('getList',this.callingList)
},
getGroupMemberAvatarText(role) {
switch (role) {
case 'Owner':
return '群主'
case 'Admin':
return '管理员'
default:
return '群成员'
}
},
loadMore() {
this.$store
.dispatch('getGroupMemberList', this.groupProfile.groupID)
.then(() => {
this.count += 30
})
}
}
}
</script>
<style lang="stylus" scoped>
.group-member-list-wrapper
.header
height 50px
padding 10px 16px 10px 20px
border-bottom 1px solid $border-base
.member-count
display inline-block
max-width 130px
line-height 30px
font-size 14px
vertical-align bottom
.btn-add-member
width 30px
height 30px
font-size 28px
text-align center
line-height 32px
cursor pointer
float right
&:hover
color $light-primary
.scroll-content
max-height: 250px;
overflow-y: scroll;
padding 10px 15px 10px 15px
width 100%
.group-member-list
display flex
justify-content flex-start
flex-wrap wrap
width 100%
.group-member
width 100px
height 80px
display: flex;
justify-content center
align-content center
flex-direction: column;
text-align: center;
color: $black;
cursor: pointer;
.avatar
width 40px
height 40px
border-radius 50%
margin 0 auto
.member-name
font-size 12px
width: 100px;
text-align center
.more
padding 0 20px
border-bottom 1px solid $border-base
</style>