Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
libai
/
guodong
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
4b10a8cf
authored
Mar 11, 2021
by
libai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
测试
parent
8e79daa9
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
75 additions
and
76 deletions
gzh/customer/guodong.html
gzh/customer/index.html
gzh/customer/naicha.html
gzh/customer/guodong.html
View file @
4b10a8cf
...
@@ -281,7 +281,6 @@
...
@@ -281,7 +281,6 @@
var
checkTimer
;
var
checkTimer
;
var
sendtime
=
0
;
var
sendtime
=
0
;
var
map
=
new
Map
();
var
map
=
new
Map
();
var
timmer
=
null
;
var
recOk
=
true
;
var
recOk
=
true
;
$
(
function
(){
$
(
function
(){
btninit
();
btninit
();
...
@@ -310,17 +309,18 @@
...
@@ -310,17 +309,18 @@
// }
// }
}
}
function
btninit
(){
function
btninit
(){
connect
(
false
);
$
(
"#send"
).
click
(
function
(){
$
(
"#send"
).
click
(
function
(){
sendmsg
();
sendmsg
();
});
});
$
(
"#img"
).
click
(
function
(){
//
$("#img").click(function(){
var
guestid
=
$
(
"#guestid"
).
val
();
//
var guestid=$("#guestid").val();
if
(
null
==
guestid
||
guestid
==
''
){
//
if(null==guestid||guestid==''){
//连接客服
//
//连接客服
system
(
'正在转接客服,请稍等'
);
//
system('正在转接客服,请稍等');
connect
(
false
);
//
connect(false);
}
//
}
});
//
});
}
}
function
sendmsg
(){
function
sendmsg
(){
...
...
gzh/customer/index.html
View file @
4b10a8cf
...
@@ -281,7 +281,6 @@
...
@@ -281,7 +281,6 @@
var
checkTimer
;
var
checkTimer
;
var
sendtime
=
0
;
var
sendtime
=
0
;
var
map
=
new
Map
();
var
map
=
new
Map
();
var
timmer
=
null
;
var
recOk
=
true
;
var
recOk
=
true
;
$
(
function
(){
$
(
function
(){
btninit
();
btninit
();
...
@@ -295,32 +294,34 @@
...
@@ -295,32 +294,34 @@
}
else
{
}
else
{
map
.
set
(
'ua'
,
'other'
);
map
.
set
(
'ua'
,
'other'
);
}
}
//
map.set('pkg','wechat');
map
.
set
(
'pkg'
,
'wechat'
);
//
map.set('cid','wechat');
map
.
set
(
'cid'
,
'wechat'
);
// map.set('gzh','naicha
');
map
.
set
(
'gzh'
,
'yabo
'
);
if
(
url
.
indexOf
(
"?"
)
!=
-
1
)
{
//
if (url.indexOf("?") != -1) {
var
p
=
url
.
substr
(
1
);
//
var p = url.substr(1);
keys
=
p
.
split
(
"&"
);
//
keys = p.split("&");
for
(
i
=
0
;
i
<
keys
.
length
;
i
++
)
{
//
for (i = 0; i
<
keys
.
length
;
i
++
)
{
map
.
set
(
keys
[
i
].
split
(
"="
)[
0
],
keys
[
i
].
split
(
"="
)[
1
]);
//
map.set(keys[i].split("=")[0],keys[i].split("=")[1]);
if
(
"guestid"
===
keys
[
i
].
split
(
"="
)[
0
]){
//
if("guestid"===keys[i].split("=")[0]){
setCookie
(
'cs-guestid'
,
keys
[
i
].
split
(
"="
)[
1
],
3
);
//
setCookie('cs-guestid',keys[i].split("=")[1],3);
}
//
}
}
//
}
}
//
}
}
}
function
btninit
(){
function
btninit
(){
connect
(
false
);
$
(
"#send"
).
click
(
function
(){
$
(
"#send"
).
click
(
function
(){
sendmsg
();
sendmsg
();
});
});
$
(
"#img"
).
click
(
function
(){
//
$("#img").click(function(){
var
guestid
=
$
(
"#guestid"
).
val
();
//
var guestid=$("#guestid").val();
if
(
null
==
guestid
||
guestid
==
''
){
//
if(null==guestid||guestid==''){
//连接客服
//
//连接客服
system
(
'正在转接客服,请稍等'
);
//
system('正在转接客服,请稍等');
connect
(
false
);
//
connect(false);
}
//
}
});
//
});
}
}
function
sendmsg
(){
function
sendmsg
(){
...
@@ -506,6 +507,7 @@
...
@@ -506,6 +507,7 @@
function WebSocketStart(guestid,send) {
function WebSocketStart(guestid,send) {
state("连接中");
state("连接中");
if(ws!=null&&ws.readyState == WebSocket.OPEN){
if(ws!=null&&ws.readyState == WebSocket.OPEN){
system("The socket is opening,please close first!");
system("The socket is opening,please close first!");
...
@@ -523,7 +525,7 @@
...
@@ -523,7 +525,7 @@
}
}
ws.onopen = function()
ws.onopen = function()
{
{
clearInterval(timmer)
recOk=true;
state("连接成功");
state("连接成功");
system("客服已接入");
system("客服已接入");
if(send){
if(send){
...
@@ -541,20 +543,17 @@
...
@@ -541,20 +543,17 @@
};
};
ws.onclose = function(event)
ws.onclose = function(event)
{
{
if(recOk){
var recNum=0
timmer=setInterval(function(){
WebSocketStart(guestid,false)
recNum++
if(recNum>=5)clearInterval(timmer)
}, 1000);
}
state("连接断开");
state("连接断开");
$("#guestid").val('
'
);
$("#guestid").val('
'
);
tips
(
"连接已断开"
,
"error"
,
3000
);
tips
(
"连接已断开"
,
"error"
,
3000
);
if
(
recOk
){
var
guestid
=
$
(
"#guestid"
).
val
();
WebSocketStart
(
guestid
,
false
)
recOk
=
false
;
}
console
.
error
(
"WebSocket close observed:"
,
event
);
console
.
error
(
"WebSocket close observed:"
,
event
);
};
};
...
@@ -562,12 +561,9 @@
...
@@ -562,12 +561,9 @@
{
{
// 关闭 websocket
// 关闭 websocket
if
(
recOk
){
if
(
recOk
){
var
recNum
=
0
var
guestid
=
$
(
"#guestid"
).
val
();
timmer
=
setInterval
(
function
(){
WebSocketStart
(
guestid
,
false
)
WebSocketStart
(
guestid
,
false
)
recNum
++
recOk
=
false
;
if
(
recNum
>=
5
)
clearInterval
(
timmer
)
},
1000
);
}
}
state
(
"连接错误"
);
state
(
"连接错误"
);
msgbulid
(
1
,
"会话意外断开,发送消息即可联系客服"
,
"系统"
,
1
);
msgbulid
(
1
,
"会话意外断开,发送消息即可联系客服"
,
"系统"
,
1
);
...
...
gzh/customer/naicha.html
View file @
4b10a8cf
...
@@ -281,12 +281,13 @@
...
@@ -281,12 +281,13 @@
var
checkTimer
;
var
checkTimer
;
var
sendtime
=
0
;
var
sendtime
=
0
;
var
map
=
new
Map
();
var
map
=
new
Map
();
var
recOk
=
true
;
$
(
function
(){
$
(
function
(){
btninit
();
btninit
();
params
();
params
();
});
});
function
params
(){
function
params
(){
//
var url = window.location.search;
var
url
=
window
.
location
.
search
;
var
ua
=
window
.
navigator
.
userAgent
.
toLowerCase
();
var
ua
=
window
.
navigator
.
userAgent
.
toLowerCase
();
if
(
ua
.
match
(
/MicroMessenger/i
)
==
'micromessenger'
){
if
(
ua
.
match
(
/MicroMessenger/i
)
==
'micromessenger'
){
map
.
set
(
'ua'
,
'wechat'
);
map
.
set
(
'ua'
,
'wechat'
);
...
@@ -295,7 +296,7 @@
...
@@ -295,7 +296,7 @@
}
}
map
.
set
(
'pkg'
,
'wechat'
);
map
.
set
(
'pkg'
,
'wechat'
);
map
.
set
(
'cid'
,
'wechat'
);
map
.
set
(
'cid'
,
'wechat'
);
map
.
set
(
'gzh'
,
'
guodong
'
);
map
.
set
(
'gzh'
,
'
naicha
'
);
// if (url.indexOf("?") != -1) {
// if (url.indexOf("?") != -1) {
// var p = url.substr(1);
// var p = url.substr(1);
// keys = p.split("&");
// keys = p.split("&");
...
@@ -307,19 +308,19 @@
...
@@ -307,19 +308,19 @@
// }
// }
// }
// }
}
}
console
.
log
(
map
)
function
btninit
(){
function
btninit
(){
connect
(
false
);
$
(
"#send"
).
click
(
function
(){
$
(
"#send"
).
click
(
function
(){
sendmsg
();
sendmsg
();
});
});
$
(
"#img"
).
click
(
function
(){
//
$("#img").click(function(){
var
guestid
=
$
(
"#guestid"
).
val
();
//
var guestid=$("#guestid").val();
if
(
null
==
guestid
||
guestid
==
''
){
//
if(null==guestid||guestid==''){
//连接客服
//
//连接客服
system
(
'正在转接客服,请稍等'
);
//
system('正在转接客服,请稍等');
connect
(
false
);
//
connect(false);
}
//
}
});
//
});
}
}
function
sendmsg
(){
function
sendmsg
(){
...
@@ -329,9 +330,9 @@
...
@@ -329,9 +330,9 @@
return
;
return
;
}
}
if
(
content
.
length
>
120
){
if
(
content
.
length
>
120
){
tips
(
"内容超过最大限制"
,
"warn"
,
5000
);
tips
(
"内容
2
超过最大限制"
,
"warn"
,
5000
);
return
;
return
;
2
}
}
2
var
guestid
=
$
(
"#guestid"
).
val
();
var
guestid
=
$
(
"#guestid"
).
val
();
if
(
null
==
guestid
||
guestid
==
''
){
if
(
null
==
guestid
||
guestid
==
''
){
//连接客服
//连接客服
...
@@ -424,7 +425,7 @@
...
@@ -424,7 +425,7 @@
var
chat
=
$
(
"#cs-chat"
);
var
chat
=
$
(
"#cs-chat"
);
chat
.
append
(
sysmsg
);
chat
.
append
(
sysmsg
);
var
offset
=
chat
[
0
].
scrollHeight
-
chat
[
0
].
clientHeight
;
var
offset
=
chat
[
0
].
scrollHeight
-
chat
[
0
].
clientHeight
;
if
(
offset
-
chat
[
0
].
scrollTop
<
(
chat
[
0
].
clientHeight
/
2
)){
if
(
offset
-
chat
[
0
].
scrollTop
<
(
500
)){
chat
.
animate
({
scrollTop
:
chat
.
scrollHeight
},
500
);
chat
.
animate
({
scrollTop
:
chat
.
scrollHeight
},
500
);
}
else
{
}
else
{
tips
(
"有新的系统消息"
,
"normal"
,
3000
);
tips
(
"有新的系统消息"
,
"normal"
,
3000
);
...
@@ -503,7 +504,9 @@
...
@@ -503,7 +504,9 @@
}
}
function WebSocketStart(guestid,send) {
function WebSocketStart(guestid,send) {
state("连接中");
state("连接中");
if(ws!=null&&ws.readyState == WebSocket.OPEN){
if(ws!=null&&ws.readyState == WebSocket.OPEN){
system("The socket is opening,please close first!");
system("The socket is opening,please close first!");
...
@@ -521,7 +524,7 @@
...
@@ -521,7 +524,7 @@
}
}
ws.onopen = function()
ws.onopen = function()
{
{
clearInterval(timmer)
recOk=true;
state("连接成功");
state("连接成功");
system("客服已接入");
system("客服已接入");
if(send){
if(send){
...
@@ -539,31 +542,30 @@
...
@@ -539,31 +542,30 @@
};
};
ws.onclose = function(event)
ws.onclose = function(event)
{
{
var recNum=0
var timmer=null
state("连接断开");
state("连接断开");
$("#guestid").val('
'
);
$("#guestid").val('
'
);
tips
(
"连接已断开"
,
"error"
,
3000
);
tips
(
"连接已断开"
,
"error"
,
3000
);
timmer
=
setinterval
(
function
(
){
if
(
recOk
){
connect
(
false
);
var
guestid
=
$
(
"#guestid"
).
val
(
);
recNum
++
WebSocketStart
(
guestid
,
false
)
if
(
recNum
>=
5
)
clearInterval
(
timmer
)
recOk
=
false
;
},
1000
);
}
console
.
error
(
"WebSocket close observed:"
,
event
);
console
.
error
(
"WebSocket close observed:"
,
event
);
};
};
ws
.
onerror
=
function
(
event
)
ws
.
onerror
=
function
(
event
)
{
{
// 关闭 websocket
// 关闭 websocket
var
recNum
=
0
if
(
recOk
){
var
timmer
=
null
var
guestid
=
$
(
"#guestid"
).
val
();
WebSocketStart
(
guestid
,
false
)
recOk
=
false
;
}
state
(
"连接错误"
);
state
(
"连接错误"
);
msgbulid
(
1
,
"会话意外断开,发送消息即可联系客服"
,
"系统"
,
1
);
msgbulid
(
1
,
"会话意外断开,发送消息即可联系客服"
,
"系统"
,
1
);
timmer
=
setinterval
(
function
(){
connect
(
false
);
recNum
++
if
(
recNum
>=
5
)
clearInterval
(
timmer
)
},
1000
);
console
.
error
(
"WebSocket error observed:"
,
event
);
console
.
error
(
"WebSocket error observed:"
,
event
);
};
};
}
else
{
}
else
{
...
@@ -588,6 +590,7 @@
...
@@ -588,6 +590,7 @@
msgbulid
(
1
,
"因您长时间未回复,本次会话已经中止,如果还有问题需要咨询,请直接发送消息"
,
"系统"
,
1
);
msgbulid
(
1
,
"因您长时间未回复,本次会话已经中止,如果还有问题需要咨询,请直接发送消息"
,
"系统"
,
1
);
checkTimer
=
null
;
checkTimer
=
null
;
sendtime
=-
1
;
sendtime
=-
1
;
recOk
=
false
$
(
"#guestid"
).
val
(
''
);
$
(
"#guestid"
).
val
(
''
);
ws
.
close
();
ws
.
close
();
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment