avatars.vue
1.23 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
<template>
<div class="avatar">
<img :src="avatarSrc">
</div>
</template>
<script>
import systemAvatar from '@/assets/image/system.png'
export default {
props: {
src: String,
type: {
type: String,
default: 'C2C'
},
shape: {
type: String,
default: 'circle'
}
},
computed: {
avatarSrc: function () {
let src = this.src
if(/^(https:|http:|\/\/)/.test(src)) {
return src
} else {
return this.defaultSrc
}
},
defaultSrc: function () {
switch(this.type) {
case 'C2C':
// 个人头像
return 'https://imgcache.qq.com/open/qcloud/video/act/webim-avatar/avatar-2.png'
case 'GROUP':
// 群默认头像
return 'https://imgcache.qq.com/open/qcloud/video/act/webim-avatar/avatar-3.png'
case this.TIM.TYPES.CONV_SYSTEM:
return systemAvatar
default:
// 默认头像
return 'https://imgcache.qq.com/open/qcloud/video/act/webim-avatar/avatar-1.png'
}
}
}
}
</script>
<style lang="stylus" scoped>
.avatar
background-color $first
text-align center
width 100%
height 100%
overflow hidden
img
width 100%
height 100%
</style>