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
| <template>
| <div class="item">
| <img
| v-if="config.img"
| :src="config.img"
| :style="coverSize"
| class="cover"
| @click="bindClick({ key:'cover', value: config.img })"
| />
| <div class="info">
| <p class="name" @click="bindClick({ key:'name', value: config.name })">{{config.name}}</p>
| <p class="dept" @click="bindClick({ key:'dept', value: config.dept })">{{config.dept}}</p>
| </div>
| </div>
| </template>
|
| <script>
| export default {
| name: 'JwChat-item',
| props: {
| config: {
| type: Object,
| default: () => ({
| img: '',
| name: 'JwChat',
| dept: '',
| }),
| required: true
| },
| size: {
| default: 35
| }
| },
| computed: {
|
| coverSize () {
| let size = this.size
| if (`${size}`.match(/\d$/)) {
| size += 'px'
| }
| return {
| width: size,
| height: size,
| }
| }
| },
| methods: {
| bindClick (type) {
| const target = type
| this.$emit('click', target)
| }
| },
| }
| </script>
| <style scoped>
| .item {
| display: flex;
| align-items: center;
| position: relative;
| }
| .item .cover {
| border-radius: 50%;
| margin-right: 12px;
| box-shadow: 0 3px 3px 0 rgba(0, 0, 0, 0.1);
| cursor: pointer;
| }
| .item .info {
| display: flex;
| flex-direction: column;
| justify-content: center;
| }
|
| .item .info p {
| margin: 0;
| margin: 0;
| padding: 0;
| width: 175px;
| text-overflow: ellipsis;
| overflow: hidden;
| text-align: left;
| white-space: nowrap;
| font-size: 13px;
| cursor: pointer;
| }
|
| .item .info p:hover {
| opacity: 0.8;
| }
| .item .info p:last-child {
| font-size: 12px;
| }
| </style>
|
|