-
Notifications
You must be signed in to change notification settings - Fork 75
/
Copy pathdemo.html
executable file
·173 lines (155 loc) · 4.13 KB
/
demo.html
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
<meta name="format-detection" content="telephone=no">
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,user-scalable=no">
<style>
body { background-color: #eee;color: #555; }
button, a { display: block;margin: 20px 0;background: #00CEB9;border: none;color: #fff;line-height: 40px;width: 200px;cursor: pointer;outline: none;text-align: center; }
button:hover, a:hover { box-shadow: 0 0 5px #33CEB9; }
button:active, a:active { background: #fff;color: #00CEB9; }
input { height: 40px;outline: none;width: 300px;text-align: center;font-size: 16px;color: #00CEB9; float: left;border: 1px solid #fff; }
</style>
</head>
<body>
<h1>Demo</h1>
<a target="_blank" href="http://docs.easemob.com/cs/300visitoraccess/web-widget">集成文档</a>
<a target="_blank" href="demos/custom-launch-button.html">自定义按钮样式demo</a>
<a target="_blank" href="demos/send-extend-message.html">发送扩展消息</a>
<br>
<br>
<br>
<br>
<br>
<br>
<h1>测试</h1>
<div><input id="testvalue" type="text" placeholder="请输入您的tenantId,点击测试按钮"/></div>
<button onclick="test()">测试</button>
<button onclick="deleteCurrentCookies()">Clear Current Cookie</button>
<button onclick="bindSkillGroup()">绑定技能组</button>
<button onclick="resizeChatWindow()">窗口加宽</button>
<br>
<br>
<br>
<script>
var tenantIdInput = document.getElementById("testvalue");
tenantIdInput.value = (window.localStorage && localStorage.getItem("easemobtest")) || "";
function test(){
// function sendCrmExt(){
// window.easemobim.sendExt(
// {
// ext:{
// cmd:{
// updateVisitorInfoSrc:{
// params:{
// uid: "cxn111111"
// }
// }
// }
// }
// }
// )
// }
window.easemobim.bind({
tenantId: getTenantId(),
resources: true,
configId: 'f112bee8-73c7-4d0f-9f82-2e89d92c4e0d',
onready: function(){
console.log("onready")
// sendCrmExt();
},
onclose: function(){
console.log("onclose")
},
onopen: function(){
console.log("onopen")
},
onEvaluationsubmit: function(){
console.log("onEvaluationsubmit")
},
onmessage: function(){
console.log("onmessage")
},
onsessionclosed: function(){
console.log("onsessionclosed")
},
onsessioncreat: function(){
console.log("oncreat")
}
// extMsg:{
// cmd:{
// updateVisitorInfoSrc:{
// params:{
// uid: "cxn111111"
// }
// }
// }
// },
});
}
function getTenantId(){
var tenantId = tenantIdInput.value;
tenantId = tenantId && tenantId.replace(/\s/g, "");
if(/\d+/.test(tenantId)) {
window.localStorage && localStorage.setItem("easemobtest", tenantId);
return tenantId;
}
}
function deleteCurrentCookies(){
var name = window.easemobim.config.tenantId || tenantIdInput.value;
name && (document.cookie = name
+ "=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/");
alert("cleared");
}
function bindSkillGroup(){
window.easemobim.bind({
tenantId: getTenantId(),
emgroup: "海盐"
});
}
function resizeChatWindow(){
window.easemobim.bind({
tenantId: getTenantId(),
dialogWidth: "500px"
});
}
</script>
<script>
function query(key){
var reg = new RegExp("[?&]" + key + "=([^&]*)(?=&|$)");
var matches = reg.exec(location.search);
return matches ? matches[1] : "";
}
window.easemobim = window.easemobim || {};
easemobim.config = {
configId: 'aeec1ace-2618-44c9-b7ee-affc0f4bf872',
// domain: '//sandbox.kefu.easemob.com',
visitor: {
trueName: 'lixiaoleng37777',
qq: '[email protected]',
phone: '13311111111',
companyName: 'easemob',
userNickname: 'lixiaoleng3',
description: 'suibian',
email: '[email protected]',
tags:[
'vip1',
'vip2'
]
},
// extMsg:{
// cmd:{
// updateVisitorInfoSrc:{
// params:{
// uid: "cxn111111"
// }
// }
// }
// },
};
</script>
<script src="easemob.js"></script>
</body>
</html>