role.js
1.9 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
/*
yoho客服 im: 角色
@author xuan.chen@yoh.cn
*/
'use strict';
class ChatRole {
constructor(headIcon) {
this.headIcon = headIcon;
}
changeIcon(src) {
this.headIcon = src;
}
}
class Customer extends ChatRole {
sendMsg(msg, status) {
status = status ? '' : '<i class="send-fail">!</i>';
return `<div class="msg-wrap send-msg">
<img src="${this.headIcon}" alt="" class="head-icon">
<div class="chat-info">
${status}
<span>${msg}</span>
</div>
</div>`;
}
sendImg(src, status) {
status = status ? '' : '<i class="send-fail">!</i>';
return `<div class="msg-wrap send-msg">
<img src="${this.headIcon}" alt="" class="head-icon">
<div class="chat-info">
${status}
<span class="image">
<img src="${src}" alt="" data-lightbox="chat-image" class="chat-image">
</span>
</div>
</div>`;
}
}
class Employee extends ChatRole {
sendMsg(msg) {
return `<div class="msg-wrap recevied-msg">
<img src="${this.headIcon}" alt="" class="head-icon">
<div class="chat-info">
<span>${msg}</span>
</div>
</div>`;
}
sendImg(src) {
return `<div class="msg-wrap recevied-msg">
<img src="${this.headIcon}" alt="" class="head-icon">
<div class="chat-info">
<span class="image">
<img src="${src}" alt="" class="chat-image">
</span>
</div>
</div>`;
}
}
export {ChatRole, Customer, Employee};