|
|
@@ -162,9 +162,7 @@ function Connect() {
|
|
162
|
162
|
//console.log("连接关闭!");
|
|
163
|
163
|
$(".hwzt").text('连接关闭!');
|
|
164
|
164
|
$("#top-search li i").removeClass("active");
|
|
165
|
|
- //layer.confirm('连接关闭!', {
|
|
166
|
|
- // btn: ['确定']
|
|
167
|
|
- //});
|
|
|
165
|
+ showMsgNotification('呼叫系统提示', '话务连接关闭');
|
|
168
|
166
|
reconnect();
|
|
169
|
167
|
}
|
|
170
|
168
|
};
|
|
|
@@ -172,6 +170,7 @@ function Connect() {
|
|
172
|
170
|
ws.onerror = function(evt) {
|
|
173
|
171
|
//产生异常
|
|
174
|
172
|
$(".hwzt").text('连接出现异常!');
|
|
|
173
|
+// showMsgNotification('呼叫系统提示', '连接出现异常');
|
|
175
|
174
|
console.log(ws);
|
|
176
|
175
|
if(ws == null || ws.readyState != ws.OPEN) {
|
|
177
|
176
|
console.log(new Date() + "开始重连");
|
|
|
@@ -545,4 +544,88 @@ function getNowFormatDate() {
|
|
545
|
544
|
" " + date.getHours() + seperator2 + date.getMinutes() +
|
|
546
|
545
|
seperator2 + date.getSeconds();
|
|
547
|
546
|
return currentdate;
|
|
548
|
|
-}
|
|
|
547
|
+}
|
|
|
548
|
+//桌面弹出提示
|
|
|
549
|
+ function showMsgNotification(title, msg) {
|
|
|
550
|
+ var Notification = window.Notification || window.mozNotification || window.webkitNotification;
|
|
|
551
|
+
|
|
|
552
|
+ if(Notification) {//支持桌面通知
|
|
|
553
|
+ if(Notification.permission == "granted") {//已经允许通知
|
|
|
554
|
+ var instance = new Notification(title, {
|
|
|
555
|
+ body: msg,
|
|
|
556
|
+ tag:msg,
|
|
|
557
|
+ icon: "img/tips.png",
|
|
|
558
|
+ requireInteraction:true,
|
|
|
559
|
+ renotify:true
|
|
|
560
|
+
|
|
|
561
|
+ });
|
|
|
562
|
+
|
|
|
563
|
+ instance.onclick = function() {
|
|
|
564
|
+// $('body').css({'background': 'red'});
|
|
|
565
|
+// console.log('onclick');
|
|
|
566
|
+// instance.close();
|
|
|
567
|
+ };
|
|
|
568
|
+ instance.onerror = function() {
|
|
|
569
|
+ console.log('onerror');
|
|
|
570
|
+ };
|
|
|
571
|
+ instance.onshow = function() {
|
|
|
572
|
+ console.log('onshow');
|
|
|
573
|
+ };
|
|
|
574
|
+ instance.onclose = function() {
|
|
|
575
|
+ console.log('onclose');
|
|
|
576
|
+ };
|
|
|
577
|
+ }else {//第一次询问或已经禁止通知(如果用户之前已经禁止显示通知,那么浏览器不会再次询问用户的意见,Notification.requestPermission()方法无效)
|
|
|
578
|
+ Notification.requestPermission(function(status) {
|
|
|
579
|
+ if (status === "granted") {//用户允许
|
|
|
580
|
+ var instance = new Notification(title, {
|
|
|
581
|
+ body: msg,
|
|
|
582
|
+ tag:msg,
|
|
|
583
|
+ icon: "img/tips.png",
|
|
|
584
|
+ requireInteraction:true,
|
|
|
585
|
+ renotify:true
|
|
|
586
|
+ });
|
|
|
587
|
+
|
|
|
588
|
+ instance.onclick = function() {
|
|
|
589
|
+ // Something to do
|
|
|
590
|
+ };
|
|
|
591
|
+ instance.onerror = function() {
|
|
|
592
|
+ // Something to do
|
|
|
593
|
+ };
|
|
|
594
|
+ instance.onshow = function() {
|
|
|
595
|
+ // Something to do
|
|
|
596
|
+ };
|
|
|
597
|
+ instance.onclose = function() {
|
|
|
598
|
+ // Something to do
|
|
|
599
|
+ };
|
|
|
600
|
+ }else {//用户禁止
|
|
|
601
|
+ return false
|
|
|
602
|
+ }
|
|
|
603
|
+ });
|
|
|
604
|
+ }
|
|
|
605
|
+ }else {//不支持(IE等)
|
|
|
606
|
+ var index = 0;
|
|
|
607
|
+
|
|
|
608
|
+ clearInterval(timer);
|
|
|
609
|
+ timer = setInterval(function() {
|
|
|
610
|
+ if(index%2) {
|
|
|
611
|
+ $('title').text('【 】'+ title);//这里是中文全角空格,其他不行
|
|
|
612
|
+ }else {
|
|
|
613
|
+ $('title').text('【新消息】'+ title);
|
|
|
614
|
+ }
|
|
|
615
|
+ index++;
|
|
|
616
|
+
|
|
|
617
|
+ if(index > 20) {
|
|
|
618
|
+ clearInterval(timer);
|
|
|
619
|
+ }
|
|
|
620
|
+ }, 500);
|
|
|
621
|
+ }
|
|
|
622
|
+
|
|
|
623
|
+
|
|
|
624
|
+
|
|
|
625
|
+
|
|
|
626
|
+
|
|
|
627
|
+ }
|
|
|
628
|
+
|
|
|
629
|
+
|
|
|
630
|
+
|
|
|
631
|
+
|