group-item.vue
1.79 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
<template>
<div @click="handleGroupClick" class="scroll-container">
<div class="group-item">
<avatar src=""/>
<div class="group-name text-ellipsis">{{ group.title }}</div>
</div>
</div>
</template>
<script>
import {MessageBox} from 'element-ui'
import Helper from '../../utils/helper'
export default {
props: ['group'],
data() {
return {
visible: false,
options: [
{
text: '退出群组',
handler: this.quitGroup
}
]
}
},
methods: {
handleGroupClick() {
if (this.group.is_join === 0) {
MessageBox.confirm('是否加入讨论组:' + this.group.title, '提示', {
type: 'warning', showClose: false
}).then(() => {
Helper.joinGroup(this.group.group_id, this.$store.state.user.userID).then(() => {
this.group.is_join = 1
this.handleGroupClick()
})
}).catch(() => {
})
} else {
const conversationID = `GROUP${this.group.group_id}`
this.$store.dispatch('checkoutConversation', conversationID)
}
},
quitGroup() {
this.tim.quitGroup(this.group.groupID)
.catch(error => {
this.$store.commit('showMessage', {
type: 'error',
message: error.message
})
})
}
}
}
</script>
<style lang="stylus" scoped>
.scroll-container
overflow-y scroll
flex 1
.group-item
display flex
padding 10px 20px
cursor pointer
position relative
overflow hidden
transition .2s
&:hover
background-color $background
.avatar
width 30px
height 30px
border-radius 50%
margin-right 10px
flex-shrink 0
.group-name
flex 1
color $font-light
line-height 30px
</style>