add-group-member.vue
1.95 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
<template>
<div>
<el-input v-model="userID" placeholder="输入userID后 按回车键" @keydown.enter.native="addGroupMember"></el-input>
</div>
</template>
<script>
import { Input } from 'element-ui'
import { mapState } from 'vuex'
export default {
components: {
ElInput: Input
},
data() {
return {
userID: ''
}
},
computed: {
...mapState({
currentConversation: state => state.conversation.currentConversation
})
},
methods: {
addGroupMember() {
const groupID = this.currentConversation.conversationID.replace('GROUP', '')
this.tim
.addGroupMember({
groupID,
userIDList: [this.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></style>