message-status-icon.vue
1.08 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
<template>
<div
style="width:16px;height:16px;"
:class="messageIconClass"
@click="handleIconClick"
>{{messageIconClass==='message-send-fail'? '!':''}}</div>
</template>
<script>
export default {
name: 'MessageStatusIcon',
props: {
message: {
type: Object,
required: true
}
},
computed: {
messageIconClass() {
switch (this.message.status) {
case 'unSend':
return 'el-icon-loading'
case 'fail':
return 'message-send-fail'
default:
return ''
}
}
},
methods: {
handleIconClick() {
if (this.messageIconClass === 'message-send-fail') {
this.tim.resendMessage(this.message).catch(imError => {
this.$store.commit('showMessage', {
message: imError.message,
type: 'error'
})
})
}
}
}
}
</script>
<style lang="stylus" scoped>
.message-send-fail {
margin-right: 8px;
background-color: #f35f5f;
color: $white;
border-radius: 50%;
text-align: center;
line-height: 16px;
cursor: pointer;
}
</style>