add-group-member.vue
3.86 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
<template>
<div class="friend-item-container">
<el-row v-for="friend in currentUnMemberList" :key="friend.id" style="margin-bottom: 5px" class="friend-list"
type="flex" align="middle" justify="center" :gutter="16">
<el-col :span="6">
<avatar class="friend-avatar" :src="friend.avatar"/>
</el-col>
<el-col :span="14">
<el-tooltip placement="top" :key="friend.id" :content="friend.name">
<div class="friend-name text-ellipsis">{{ friend.name }}</div>
</el-tooltip>
</el-col>
<el-col :span="4">
<div class="btn-add-member" :title="`添加:${friend.name}`" @click="addGroupMember(friend)">
<span class="tim-icon-friend-add"></span>
</div>
</el-col>
</el-row>
<el-button v-show="currentUnMemberList.length < currentUnMemberTotal" style="width: inherit;margin: 0 auto" long
type="text"
@click="$store.dispatch('getGroupUnMemberList', group)">加载更多
</el-button>
</div>
</template>
<script>
import {mapState} from 'vuex'
import Helper from '../../../utils/helper'
import {Button, Tooltip} from 'element-ui'
export default {
components: {
ElTooltip: Tooltip,
ElButton: Button
},
props: {
group: {
type: String, required: true
}
},
computed: {
...mapState({
currentConversation: state => state.conversation.currentConversation,
currentMemberList: state => state.group.currentMemberList,
currentUnMemberList: state => state.group.currentUnMemberList,
currentUnMemberTotal: state => state.group.currentUnMemberMeta.total
}),
},
data() {
return {
list: []
}
},
methods: {
addGroupMember(user) {
const groupID = this.currentConversation.conversationID.replace('GROUP', '')
Helper.joinGroup(groupID, user.esm_id).then(() => {
this.$store.commit('showMessage', {message: `群成员:${user.name},加群成功`, type: 'success'})
this.tim.getGroupMemberProfile({groupID, userIDList: [user.esm_id]})
.then(({data: {memberList}}) => {
this.$store.commit('updateCurrentMemberList', memberList)
this.$store.commit('deleteGroupUnMember', user.esm_id)
})
})
// this.tim
// .addGroupMember({
// groupID,
// userIDList: [userID]
// })
// .then((imResponse) => {
// const {
// successUserIDList,
// failureUserIDList,
// existedUserIDList
// } = imResponse.data
// if (successUserIDList.length > 0) {
// this.$store.commit('showMessage', {message: `群成员:${successUserIDList.join(',')},加群成功`, type: 'success'})
// this.tim.getGroupMemberProfile({groupID, userIDList: successUserIDList})
// .then(({data: {memberList}}) => this.$store.commit('updateCurrentMemberList', memberList))
// }
// if (failureUserIDList.length > 0) {
// this.$store.commit('showMessage', {message: `群成员:${failureUserIDList.join(',')},添加失败!`, type: 'error'})
// }
// if (existedUserIDList.length > 0) {
// this.$store.commit('showMessage', {message: `群成员:${existedUserIDList.join(',')},已在群中`})
// }
// })
// .catch(error => {
// this.$store.commit('showMessage', {type: 'error', message: error.message})
// })
}
},
}
</script>
<style lang="stylus" scoped>
.friend-item-container
width: 200px;
max-height: 60vh;
overflow-x: hidden
overflow-y scroll
&::-webkit-scrollbar
width: 0 !important
.btn-add-member
width 30px
height 30px
font-size 28px
text-align center
line-height 32px
cursor pointer
float right
&:hover
color $light-primary
</style>