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
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
77 additions
and
78 deletions
gzh/customer/guodong.html
gzh/customer/index.html
gzh/customer/naicha.html
gzh/customer/guodong.html
View file @
4b10a8cf
...
...
@@ -281,7 +281,6 @@
var
checkTimer
;
var
sendtime
=
0
;
var
map
=
new
Map
();
var
timmer
=
null
;
var
recOk
=
true
;
$
(
function
(){
btninit
();
...
...
@@ -310,17 +309,18 @@
// }
}
function
btninit
(){
connect
(
false
);
$
(
"#send"
).
click
(
function
(){
sendmsg
();
});
$
(
"#img"
).
click
(
function
(){
var
guestid
=
$
(
"#guestid"
).
val
();
if
(
null
==
guestid
||
guestid
==
''
){
//连接客服
system
(
'正在转接客服,请稍等'
);
connect
(
false
);
}
});
//
$("#img").click(function(){
//
var guestid=$("#guestid").val();
//
if(null==guestid||guestid==''){
//
//连接客服
//
system('正在转接客服,请稍等');
//
connect(false);
//
}
//
});
}
function
sendmsg
(){
...
...
gzh/customer/index.html
View file @
4b10a8cf
...
...
@@ -281,7 +281,6 @@
var
checkTimer
;
var
sendtime
=
0
;
var
map
=
new
Map
();
var
timmer
=
null
;
var
recOk
=
true
;
$
(
function
(){
btninit
();
...
...
@@ -295,32 +294,34 @@
}
else
{
map
.
set
(
'ua'
,
'other'
);
}
// map.set('pkg','wechat');
// map.set('cid','wechat');
// map.set('gzh','naicha');
if
(
url
.
indexOf
(
"?"
)
!=
-
1
)
{
var
p
=
url
.
substr
(
1
);
keys
=
p
.
split
(
"&"
);
for
(
i
=
0
;
i
<
keys
.
length
;
i
++
)
{
map
.
set
(
keys
[
i
].
split
(
"="
)[
0
],
keys
[
i
].
split
(
"="
)[
1
]);
if
(
"guestid"
===
keys
[
i
].
split
(
"="
)[
0
]){
setCookie
(
'cs-guestid'
,
keys
[
i
].
split
(
"="
)[
1
],
3
);
}
}
}
}
map
.
set
(
'pkg'
,
'wechat'
);
map
.
set
(
'cid'
,
'wechat'
);
map
.
set
(
'gzh'
,
'yabo'
);
// if (url.indexOf("?") != -1) {
// var p = url.substr(1);
// keys = p.split("&");
// for (i = 0; i
<
keys
.
length
;
i
++
)
{
// map.set(keys[i].split("=")[0],keys[i].split("=")[1]);
// if("guestid"===keys[i].split("=")[0]){
// setCookie('cs-guestid',keys[i].split("=")[1],3);
// }
// }
// }
}
function
btninit
(){
connect
(
false
);
$
(
"#send"
).
click
(
function
(){
sendmsg
();
});
$
(
"#img"
).
click
(
function
(){
var
guestid
=
$
(
"#guestid"
).
val
();
if
(
null
==
guestid
||
guestid
==
''
){
//连接客服
system
(
'正在转接客服,请稍等'
);
connect
(
false
);
}
});
//
$("#img").click(function(){
//
var guestid=$("#guestid").val();
//
if(null==guestid||guestid==''){
//
//连接客服
//
system('正在转接客服,请稍等');
//
connect(false);
//
}
//
});
}
function
sendmsg
(){
...
...
@@ -506,6 +507,7 @@
function WebSocketStart(guestid,send) {
state("连接中");
if(ws!=null&&ws.readyState == WebSocket.OPEN){
system("The socket is opening,please close first!");
...
...
@@ -523,7 +525,7 @@
}
ws.onopen = function()
{
clearInterval(timmer)
recOk=true;
state("连接成功");
system("客服已接入");
if(send){
...
...
@@ -541,20 +543,17 @@
};
ws.onclose = function(event)
{
if(recOk){
var recNum=0
timmer=setInterval(function(){
WebSocketStart(guestid,false)
recNum++
if(recNum>=5)clearInterval(timmer)
}, 1000);
}
state("连接断开");
$("#guestid").val('
'
);
tips
(
"连接已断开"
,
"error"
,
3000
);
if
(
recOk
){
var
guestid
=
$
(
"#guestid"
).
val
();
WebSocketStart
(
guestid
,
false
)
recOk
=
false
;
}
console
.
error
(
"WebSocket close observed:"
,
event
);
};
...
...
@@ -562,12 +561,9 @@
{
// 关闭 websocket
if
(
recOk
){
var
recNum
=
0
timmer
=
setInterval
(
function
(){
WebSocketStart
(
guestid
,
false
)
recNum
++
if
(
recNum
>=
5
)
clearInterval
(
timmer
)
},
1000
);
var
guestid
=
$
(
"#guestid"
).
val
();
WebSocketStart
(
guestid
,
false
)
recOk
=
false
;
}
state
(
"连接错误"
);
msgbulid
(
1
,
"会话意外断开,发送消息即可联系客服"
,
"系统"
,
1
);
...
...
gzh/customer/naicha.html
View file @
4b10a8cf
...
...
@@ -281,12 +281,13 @@
var
checkTimer
;
var
sendtime
=
0
;
var
map
=
new
Map
();
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'
);
...
...
@@ -295,7 +296,7 @@
}
map
.
set
(
'pkg'
,
'wechat'
);
map
.
set
(
'cid'
,
'wechat'
);
map
.
set
(
'gzh'
,
'
guodong
'
);
map
.
set
(
'gzh'
,
'
naicha
'
);
// if (url.indexOf("?") != -1) {
// var p = url.substr(1);
// keys = p.split("&");
...
...
@@ -307,19 +308,19 @@
// }
// }
}
console
.
log
(
map
)
function
btninit
(){
connect
(
false
);
$
(
"#send"
).
click
(
function
(){
sendmsg
();
});
$
(
"#img"
).
click
(
function
(){
var
guestid
=
$
(
"#guestid"
).
val
();
if
(
null
==
guestid
||
guestid
==
''
){
//连接客服
system
(
'正在转接客服,请稍等'
);
connect
(
false
);
}
});
//
$("#img").click(function(){
//
var guestid=$("#guestid").val();
//
if(null==guestid||guestid==''){
//
//连接客服
//
system('正在转接客服,请稍等');
//
connect(false);
//
}
//
});
}
function
sendmsg
(){
...
...
@@ -329,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
==
''
){
//连接客服
...
...
@@ -424,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
);
...
...
@@ -503,7 +504,9 @@
}
function WebSocketStart(guestid,send) {
state("连接中");
if(ws!=null&&ws.readyState == WebSocket.OPEN){
system("The socket is opening,please close first!");
...
...
@@ -521,7 +524,7 @@
}
ws.onopen = function()
{
clearInterval(timmer)
recOk=true;
state("连接成功");
system("客服已接入");
if(send){
...
...
@@ -539,31 +542,30 @@
};
ws.onclose = function(event)
{
var recNum=0
var timmer=null
state("连接断开");
$("#guestid").val('
'
);
tips
(
"连接已断开"
,
"error"
,
3000
);
timmer
=
setinterval
(
function
(
){
connect
(
false
);
recNum
++
if
(
recNum
>=
5
)
clearInterval
(
timmer
)
},
1000
);
if
(
recOk
){
var
guestid
=
$
(
"#guestid"
).
val
(
);
WebSocketStart
(
guestid
,
false
)
recOk
=
false
;
}
console
.
error
(
"WebSocket close observed:"
,
event
);
};
ws
.
onerror
=
function
(
event
)
{
// 关闭 websocket
var
recNum
=
0
var
timmer
=
null
if
(
recOk
){
var
guestid
=
$
(
"#guestid"
).
val
();
WebSocketStart
(
guestid
,
false
)
recOk
=
false
;
}
state
(
"连接错误"
);
msgbulid
(
1
,
"会话意外断开,发送消息即可联系客服"
,
"系统"
,
1
);
timmer
=
setinterval
(
function
(){
connect
(
false
);
recNum
++
if
(
recNum
>=
5
)
clearInterval
(
timmer
)
},
1000
);
console
.
error
(
"WebSocket error observed:"
,
event
);
};
}
else
{
...
...
@@ -588,6 +590,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