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
39c7b11c
authored
Mar 11, 2021
by
libai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
测试
parent
0a71d2b3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
19 deletions
gzh/customer/guodong.html
gzh/customer/guodong.html
View file @
39c7b11c
...
...
@@ -281,12 +281,14 @@
var
checkTimer
;
var
sendtime
=
0
;
var
map
=
new
Map
();
var
timmer
=
null
;
var
recOk
=
true
;
$
(
function
(){
btninit
();
params
();
});
function
params
(){
//
var url = window.location.search;
var
url
=
window
.
location
.
search
;
var
ua
=
window
.
navigator
.
userAgent
.
toLowerCase
();
if
(
ua
.
match
(
/MicroMessenger/i
)
==
'micromessenger'
){
map
.
set
(
'ua'
,
'wechat'
);
...
...
@@ -328,9 +330,9 @@
return
;
}
if
(
content
.
length
>
120
){
tips
(
"内容超过最大限制"
,
"warn"
,
5000
);
return
;
}
tips
(
"内容
2
超过最大限制"
,
"warn"
,
5000
);
return
;
2
}
2
var
guestid
=
$
(
"#guestid"
).
val
();
if
(
null
==
guestid
||
guestid
==
''
){
//连接客服
...
...
@@ -423,7 +425,7 @@
var
chat
=
$
(
"#cs-chat"
);
chat
.
append
(
sysmsg
);
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
);
}
else
{
tips
(
"有新的系统消息"
,
"normal"
,
3000
);
...
...
@@ -502,6 +504,7 @@
}
function WebSocketStart(guestid,send) {
state("连接中");
if(ws!=null&&ws.readyState == WebSocket.OPEN){
...
...
@@ -538,31 +541,36 @@
};
ws.onclose = function(event)
{
var recNum=0
var timmer=null
if(recOk){
var recNum=0
timmer=setInterval(function(){
WebSocketStart(guestid,false)
recNum++
if(recNum>=5)clearInterval(timmer)
}, 1000);
}
state("连接断开");
$("#guestid").val('
'
);
tips
(
"连接已断开"
,
"error"
,
3000
);
timmer
=
setinterval
(
function
(){
connect
(
false
);
recNum
++
if
(
recNum
>=
5
)
clearInterval
(
timmer
)
},
1000
);
console
.
error
(
"WebSocket close observed:"
,
event
);
};
ws
.
onerror
=
function
(
event
)
{
// 关闭 websocket
var
recNum
=
0
var
timmer
=
null
if
(
recOk
){
var
recNum
=
0
timmer
=
setInterval
(
function
(){
WebSocketStart
(
guestid
,
false
)
recNum
++
if
(
recNum
>=
5
)
clearInterval
(
timmer
)
},
1000
);
}
state
(
"连接错误"
);
msgbulid
(
1
,
"会话意外断开,发送消息即可联系客服"
,
"系统"
,
1
);
timmer
=
setinterval
(
function
(){
connect
(
false
);
recNum
++
if
(
recNum
>=
5
)
clearInterval
(
timmer
)
},
1000
);
console
.
error
(
"WebSocket error observed:"
,
event
);
};
}
else
{
...
...
@@ -587,6 +595,7 @@
msgbulid
(
1
,
"因您长时间未回复,本次会话已经中止,如果还有问题需要咨询,请直接发送消息"
,
"系统"
,
1
);
checkTimer
=
null
;
sendtime
=-
1
;
recOk
=
false
$
(
"#guestid"
).
val
(
''
);
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