瀏覽代碼

异常断开,签出,签入

miaofuhao 6 年之前
父節點
當前提交
0f6487dd96
共有 3 個文件被更改,包括 119 次插入78 次删除
  1. 0 28
      CallCenterWeb.UI/index.html
  2. 117 44
      CallCenterWeb.UI/js/main.js
  3. 2 6
      CallCenterWeb.UI/login.html

+ 0 - 28
CallCenterWeb.UI/index.html

28
                 url('./fonts/iconfont.svg#iconfont') format('svg');
28
                 url('./fonts/iconfont.svg#iconfont') format('svg');
29
                 /* iOS 4.1- */
29
                 /* iOS 4.1- */
30
             }
30
             }
31
-
32
             body {
31
             body {
33
                 font-family: "微软雅黑";
32
                 font-family: "微软雅黑";
34
             }
33
             }
35
-
36
             ul li {
34
             ul li {
37
                 list-style: none;
35
                 list-style: none;
38
                 overflow: hidden;
36
                 overflow: hidden;
39
             }
37
             }
40
-
41
             .iconfont {
38
             .iconfont {
42
                 font-family: "iconfont";
39
                 font-family: "iconfont";
43
                 font-style: normal;
40
                 font-style: normal;
44
                 color: #FFFFFF;
41
                 color: #FFFFFF;
45
             }
42
             }
46
-
47
             .fr {
43
             .fr {
48
                 float: right;
44
                 float: right;
49
             }
45
             }
50
-
51
             .fl {
46
             .fl {
52
                 float: left;
47
                 float: left;
53
             }
48
             }
54
-
55
             .size-12 {
49
             .size-12 {
56
                 font-size: 12px;
50
                 font-size: 12px;
57
             }
51
             }
58
-
59
             .title-box {
52
             .title-box {
60
                 margin-top: 5px;
53
                 margin-top: 5px;
61
             }
54
             }
62
-
63
             .title-box li {
55
             .title-box li {
64
                 margin-left: 30px;
56
                 margin-left: 30px;
65
             }
57
             }
66
-
67
             .title-box li:hover {
58
             .title-box li:hover {
68
                 cursor: pointer;
59
                 cursor: pointer;
69
             }
60
             }
70
-
71
             .HoverColor {
61
             .HoverColor {
72
                 color: #f8ac59;
62
                 color: #f8ac59;
73
             }
63
             }
74
-
75
             .FailureColor {
64
             .FailureColor {
76
                 color: #f95f5e;
65
                 color: #f95f5e;
77
             }
66
             }
78
-
79
             .navbar-header {
67
             .navbar-header {
80
                 width: 100%;
68
                 width: 100%;
81
                 background-color: #2f4050;
69
                 background-color: #2f4050;
82
                 padding-top: 10px;
70
                 padding-top: 10px;
83
             }
71
             }
84
-
85
             .title-box li p {
72
             .title-box li p {
86
                 color: #FFFFFF;
73
                 color: #FFFFFF;
87
                 font-size: 14px;
74
                 font-size: 14px;
89
                 letter-spacing: 2px;
76
                 letter-spacing: 2px;
90
                 margin-top: 5px;
77
                 margin-top: 5px;
91
             }
78
             }
92
-
93
             .size-14 {
79
             .size-14 {
94
                 font-size: 14px;
80
                 font-size: 14px;
95
                 color: #FFFFFF !important;
81
                 color: #FFFFFF !important;
96
             }
82
             }
97
-
98
             .img-circle {
83
             .img-circle {
99
                 width: 58px;
84
                 width: 58px;
100
             }
85
             }
101
-
102
             .xian {
86
             .xian {
103
                 border: 1px solid #FFFFFF;
87
                 border: 1px solid #FFFFFF;
104
                 display: inline-block;
88
                 display: inline-block;
105
                 width: 15%;
89
                 width: 15%;
106
                 margin: 5px;
90
                 margin: 5px;
107
             }
91
             }
108
-
109
             .ss {
92
             .ss {
110
                 margin-left: 20px;
93
                 margin-left: 20px;
111
             }
94
             }
112
-
113
             .fe-3 {
95
             .fe-3 {
114
                 font-size: 3em;
96
                 font-size: 3em;
115
             }
97
             }
116
-
117
             .title-box p {
98
             .title-box p {
118
                 text-align: center;
99
                 text-align: center;
119
             }
100
             }
120
-
121
             .closed {
101
             .closed {
122
                 display: inline-block;
102
                 display: inline-block;
123
                 /*				margin-left: 5%;*/
103
                 /*				margin-left: 5%;*/
126
                 float: right;
106
                 float: right;
127
                 margin-right: 5%;
107
                 margin-right: 5%;
128
             }
108
             }
129
-
130
             .closed div {
109
             .closed div {
131
                 overflow: hidden;
110
                 overflow: hidden;
132
             }
111
             }
133
-
134
             .closed ul {
112
             .closed ul {
135
                 margin-bottom: 0px;
113
                 margin-bottom: 0px;
136
             }
114
             }
137
-
138
             .closed li {
115
             .closed li {
139
                 float: left;
116
                 float: left;
140
                 margin-right: 20px;
117
                 margin-right: 20px;
141
             }
118
             }
142
-
143
             .closed i {
119
             .closed i {
144
                 display: inline-block;
120
                 display: inline-block;
145
                 background: url(./img/chilun.png) no-repeat;
121
                 background: url(./img/chilun.png) no-repeat;
148
                 height: 16px;
124
                 height: 16px;
149
                 vertical-align: middle;
125
                 vertical-align: middle;
150
             }
126
             }
151
-
152
             .ga {
127
             .ga {
153
                 background-position: 0 0 !important;
128
                 background-position: 0 0 !important;
154
             }
129
             }
155
-
156
             .sz {
130
             .sz {
157
                 background-position: 0 -15px !important;
131
                 background-position: 0 -15px !important;
158
             }
132
             }
159
-
160
             .tc {
133
             .tc {
161
                 background-position: 0 -33px !important;
134
                 background-position: 0 -33px !important;
162
             }
135
             }
163
-
164
             .zhuangtai {
136
             .zhuangtai {
165
                 display: block;
137
                 display: block;
166
                 width: 30%;
138
                 width: 30%;

+ 117 - 44
CallCenterWeb.UI/js/main.js

8
 var sendType;
8
 var sendType;
9
 var mesCont;
9
 var mesCont;
10
 var lasttime = new Date().getTime();
10
 var lasttime = new Date().getTime();
11
+var errorState;
12
+var reconnecTion;
13
+var recon;
14
+var loginOr;
11
 //创建scoket连接
15
 //创建scoket连接
12
 function createWebSocket() {
16
 function createWebSocket() {
13
 	try {
17
 	try {
14
 		$("#top-search li i").removeClass("active");
18
 		$("#top-search li i").removeClass("active");
15
 		ws = new WebSocket("ws://" + huayi.config.socket_ip + ":" + huayi.config.socket_port);
19
 		ws = new WebSocket("ws://" + huayi.config.socket_ip + ":" + huayi.config.socket_port);
16
-		Connect();
17
-		
18
-		
20
+		Connect();		
19
 	} catch(e) {
21
 	} catch(e) {
20
 		reconnect();
22
 		reconnect();
21
 	}
23
 	}
29
 			heartCheck.reset().start();
31
 			heartCheck.reset().start();
30
 			cls = 0;
32
 			cls = 0;
31
 			$(".Login").addClass("active");
33
 			$(".Login").addClass("active");
32
-			//自动签入
33
-//			lasttime = new Date().getTime();
34
-//			obj.Type = "Login";
35
-//			obj.AgentType = "0";
36
-			Send();
34
+			if (errorState) {
35
+				//自动签入
36
+				lasttime = new Date().getTime();
37
+				obj.Type = "Login";
38
+				obj.AgentType = "0";
39
+				Send();
40
+				clearInterval(timer);
41
+				//loginOr=false;
42
+				errorState=false;
43
+			}else{
44
+				//签入
45
+				Send();
46
+				
47
+			}
48
+			
49
+			
37
 		};
50
 		};
38
 		//接收到消息的回调方法
51
 		//接收到消息的回调方法
39
 		ws.onmessage = function(evt) {
52
 		ws.onmessage = function(evt) {
75
 						case "setstate":
88
 						case "setstate":
76
 							SetState(data);
89
 							SetState(data);
77
 							break; //置忙置闲
90
 							break; //置忙置闲
78
-							//case "saybusy": SayBusyBack(data); break;
79
-							//case "sayfree": SayFreeBack(data); break;
91
+							break;
80
 						case "meeting":
92
 						case "meeting":
81
 							MeetingBack();
93
 							MeetingBack();
82
 							break; //多方通话
94
 							break; //多方通话
120
 				} else {
132
 				} else {
121
 					if(rlt == false) {
133
 					if(rlt == false) {
122
 						if (data.Type=="AcdConnectNotify") {
134
 						if (data.Type=="AcdConnectNotify") {
123
-							LogoutBack();
124
-							obj.Type = "login";
125
-							Send();
135
+							//LogoutBack();
136
+							$(".hwzt").text('连接异常!');
137
+							setTimeout(function () {
138
+//								签入
139
+								obj.Type = "login";
140
+								Send();
141
+					        }, 5000);
126
 						}
142
 						}
127
 						$(".hwzt").text('操作失败!');
143
 						$(".hwzt").text('操作失败!');
128
 					} else {
144
 					} else {
129
 						$(".hwzt").text(rlt);
145
 						$(".hwzt").text(rlt);
130
-						//layer.confirm(rlt, {
131
-						//    btn: ['确定']
132
-						//});
133
 					}
146
 					}
134
 				}
147
 				}
135
 			}
148
 			}
137
 		//连接关闭的回调方法
150
 		//连接关闭的回调方法
138
 		ws.onclose = function(evt) {
151
 		ws.onclose = function(evt) {
139
 			//打印日志
152
 			//打印日志
153
+			//LogoutBack();
140
 			var data = JSON.parse(evt.data)[0];
154
 			var data = JSON.parse(evt.data)[0];
141
 			directType="recive";
155
 			directType="recive";
142
 			sendType="close"; //JSON.stringify(data)
156
 			sendType="close"; //JSON.stringify(data)
143
 			mesCont=JSON.stringify(data);
157
 			mesCont=JSON.stringify(data);
144
-			debuggerLog()
145
-			if(cls == 0) {
146
-				cls = 1;
147
-				//console.log("连接关闭!");
148
-				//layer.confirm('连接关闭!', {
149
-				//    btn: ['确定']
150
-				//});
151
-				$(".hwzt").text('连接关闭!');
152
-				$("#top-search li i").removeClass("active");
153
-				reconnect();
154
-			}
158
+			debuggerLog();
159
+			$(".hwzt").text('连接关闭!');
160
+//			if(cls == 0) {
161
+//				cls = 1;
162
+//				$(".hwzt").text('连接关闭!');
163
+//				$("#top-search li i").removeClass("active");
164
+//				//reconnect();
165
+//			}
155
 		};
166
 		};
156
 		//连接发生错误的回调方法
167
 		//连接发生错误的回调方法
157
 		ws.onerror = function(evt) {
168
 		ws.onerror = function(evt) {
161
 			directType="recive";
172
 			directType="recive";
162
 			sendType="连接错误 "; //JSON.stringify(data)
173
 			sendType="连接错误 "; //JSON.stringify(data)
163
 			mesCont=JSON.stringify(data);
174
 			mesCont=JSON.stringify(data);
164
-			debuggerLog()
165
-			$(".hwzt").text('连接出现异常!');
175
+			debuggerLog();
176
+			//LogoutBack();
177
+			$(".hwzt").text('连接异常!');
166
 			console.log(ws);
178
 			console.log(ws);
167
-			if(ws == null || ws.readyState != ws.OPEN) {
168
-				directType="send";
169
-				sendType="开始重连 "; //JSON.stringify(data)
170
-				mesCont=mesCont;
171
-				debuggerLog()
172
-				console.log(new Date() + "开始重连");
173
-				reconnect();
174
-				eorrorConnect=true
175
-			}
179
+//			if(ws == null || ws.readyState != ws.OPEN) {
180
+//				directType="send";
181
+//				sendType="开始重连 "; //JSON.stringify(data)
182
+//				mesCont=mesCont;
183
+//				debuggerLog()
184
+//				console.log(new Date() + "开始重连");
185
+//				reconnect();
186
+//				eorrorConnect=true
187
+//				$(".hwzt").text('连接异常!');
188
+//			}
189
+			$(".hwzt").text('连接异常!');
176
 		};
190
 		};
177
 	} catch(ex) {
191
 	} catch(ex) {
178
 		$(".hwzt").text('连接关闭 try-catch!');
192
 		$(".hwzt").text('连接关闭 try-catch!');
183
 
197
 
184
 //重连
198
 //重连
185
 function reconnect() {
199
 function reconnect() {
186
-	if(lockReconnect) return;
200
+	if(lockReconnect){return};
187
 	lockReconnect = true;
201
 	lockReconnect = true;
188
 	//没连接上会一直重连,设置延迟避免请求过多
202
 	//没连接上会一直重连,设置延迟避免请求过多
189
 	setTimeout(function() {
203
 	setTimeout(function() {
194
 		console.log(new Date() + "    " + "重连中……");
208
 		console.log(new Date() + "    " + "重连中……");
195
 		createWebSocket("ws://" + huayi.config.socket_ip + ":" + huayi.config.socket_port);
209
 		createWebSocket("ws://" + huayi.config.socket_ip + ":" + huayi.config.socket_port);
196
 		lockReconnect = false;
210
 		lockReconnect = false;
197
-	}, 2000);
211
+	}, 5000);
198
 }
212
 }
199
 function debuggerLog(){
213
 function debuggerLog(){
200
 	$.post(huayi.config.callcenter_url + 'Log/CallOpt', {
214
 	$.post(huayi.config.callcenter_url + 'Log/CallOpt', {
205
 	}, function(result) {
219
 	}, function(result) {
206
 		result = $.parseJSON(result);
220
 		result = $.parseJSON(result);
207
 		if(result.state.toLowerCase() == "warning") {
221
 		if(result.state.toLowerCase() == "warning") {
208
-			debugger
209
 			//layer.msg("创建工单成功");
222
 			//layer.msg("创建工单成功");
210
 		}
223
 		}
211
 	})
224
 	})
212
 }
225
 }
226
+//异常重连
227
+function errorFun(){
228
+	clearInterval(timer);
229
+	var errorNum=0
230
+	timer = setInterval(function() {
231
+		errorNum++;
232
+		if (errorNum>2) {
233
+			//$("#top-search li i").removeClass("active");
234
+			$(".hwzt").text('连接异常!');
235
+		}else{
236
+			LogoutBack();
237
+		}
238
+		reconnect();
239
+		$(".hwzt").text('连接异常!');
240
+	}, 15000);
241
+}
242
+noLine();
243
+clearInterval(recon);
244
+recon = setInterval(function () { 
245
+	if(loginOr){
246
+		noLine();
247
+		setTimeout(function () {
248
+			lineState();
249
+    	}, 2000);
250
+	}
251
+}, 1000*10);
252
+function lineState(){
253
+	if (reconnecTion) {
254
+		reconnecTion=false;
255
+	}else{
256
+		errorState=true;
257
+		LogoutBack();
258
+		errorFun();
259
+		var numEorr=0;
260
+		numEorr++;
261
+		if (numEorr>2) {
262
+			$("#top-search li i").removeClass("active");
263
+		}
264
+		$(".hwzt").text('网络异常!');
265
+	}
266
+}
267
+function noLine(){
268
+	$.ajax({
269
+		type: "get",
270
+		url: huayi.config.callcenter_url + 'UserAccount/GetNowUser',
271
+		async: true,
272
+		dataType: 'json',
273
+		data: {
274
+			"token": $.cookie("token")
275
+		},
276
+		success: function(data) {
277
+			reconnecTion = data.data.user.F_UserCode;
278
+		}
279
+	});
280
+}
281
+
213
 //发送
282
 //发送
214
 function Send() {
283
 function Send() {
215
 	if(ws.readyState != ws.OPEN) {
284
 	if(ws.readyState != ws.OPEN) {
216
-		reconnect();
285
+		
286
+		errorState=true;
287
+		LogoutBack();
288
+		errorFun();
289
+		$(".hwzt").text('连接异常!');
217
 	}
290
 	}
218
 	if(ws.readyState == ws.OPEN) {
291
 	if(ws.readyState == ws.OPEN) {
219
 		console.log(new Date() + "  send  " + JSON.stringify(obj));	
292
 		console.log(new Date() + "  send  " + JSON.stringify(obj));	
258
 
331
 
259
 //签入
332
 //签入
260
 function LoginBack() {
333
 function LoginBack() {
334
+	loginOr=true;
261
 	$("#top-search li i").removeClass("active");
335
 	$("#top-search li i").removeClass("active");
262
 	$(".Logout").addClass("active");
336
 	$(".Logout").addClass("active");
263
 	$(".SayBusy").addClass("active");
337
 	$(".SayBusy").addClass("active");
268
 }
342
 }
269
 //签出
343
 //签出
270
 function LogoutBack() {
344
 function LogoutBack() {
345
+	loginOr=false;
271
 	$("#top-search li i").removeClass("active");
346
 	$("#top-search li i").removeClass("active");
272
 	$(".Login").addClass("active");
347
 	$(".Login").addClass("active");
273
 	$(".zxzt").removeClass("bl").addClass("br");
348
 	$(".zxzt").removeClass("bl").addClass("br");
488
 		$(".SayFree").addClass("active");
563
 		$(".SayFree").addClass("active");
489
 		$(".zxzt").removeClass("bl").addClass("br");
564
 		$(".zxzt").removeClass("bl").addClass("br");
490
 		$(".hwzt").text('置忙');
565
 		$(".hwzt").text('置忙');
491
-
492
 	}
566
 	}
493
 	if(obj.State == '2') {
567
 	if(obj.State == '2') {
494
 		$(".SayBusy").addClass("active");
568
 		$(".SayBusy").addClass("active");
495
 		$(".SayFree").removeClass("active");
569
 		$(".SayFree").removeClass("active");
496
 		$(".zxzt").removeClass("br").addClass("bl");
570
 		$(".zxzt").removeClass("br").addClass("bl");
497
-
498
 		$(".hwzt").text('空闲');
571
 		$(".hwzt").text('空闲');
499
 	}
572
 	}
500
 }
573
 }

+ 2 - 6
CallCenterWeb.UI/login.html

36
 		 		margin: 0 auto;
36
 		 		margin: 0 auto;
37
 		 	}
37
 		 	}
38
 		 	.headCon{
38
 		 	.headCon{
39
-		 		/*padding: 20px 0 15px 0;*/
40
    				box-sizing: border-box;
39
    				box-sizing: border-box;
41
-   				    /*padding-top: 25px;*/
42
-   				   height: 100%;
40
+   				height: 100%;
43
 		 	}
41
 		 	}
44
 		 	.wrap{
42
 		 	.wrap{
45
 		 		height: 500px;
43
 		 		height: 500px;
130
 			    background: #1ab394;
128
 			    background: #1ab394;
131
 			    height: 49px!important;
129
 			    height: 49px!important;
132
 			    line-height: 49px!important;
130
 			    line-height: 49px!important;
133
-			        cursor: pointer;
131
+			    cursor: pointer;
134
 			}
132
 			}
135
 			.login_icon_user {
133
 			.login_icon_user {
136
 				    background: url(img/user-icon.png) no-repeat;
134
 				    background: url(img/user-icon.png) no-repeat;
182
 				<img src="img/logo.png" alt="" style="vertical-align: middle;" />
180
 				<img src="img/logo.png" alt="" style="vertical-align: middle;" />
183
 				<span  class="center"></span>
181
 				<span  class="center"></span>
184
 			</div>
182
 			</div>
185
-			
186
 		</div>
183
 		</div>
187
 		<div class="wrap">
184
 		<div class="wrap">
188
 			<div class="mainCon row">
185
 			<div class="mainCon row">
334
 										expires: 7
331
 										expires: 7
335
 									});
332
 									});
336
 									window.location.href = "index.html";
333
 									window.location.href = "index.html";
337
-                              
338
 								}else{
334
 								}else{
339
 									$(".zx_user").val('');
335
 									$(".zx_user").val('');
340
 									$(".zx_fj").val('');
336
 									$(".zx_fj").val('');