Selaa lähdekoodia

在线客服官网样式修改,发送人图标

lihai 5 vuotta sitten
vanhempi
commit
94de48809c

+ 259 - 221
WebSite/css/chat.css

@@ -1,222 +1,260 @@
1
-		body{
2
-				color: #4d4d4d;
3
-			    font: 14px/1.4em 'Helvetica Neue', Helvetica, 'Microsoft Yahei', Arial, sans-serif;
4
-			    background: #f5f5f5 url(img/chat_bg.jpg) no-repeat center;
5
-			    background-size: cover;
6
-			
7
-			}
8
-			ul,li{
9
-				list-style: none;
10
-				margin: 0;
11
-				padding: 0;
12
-			}
13
-			
14
-			#chat{
15
-				/*margin: 20px auto;*/
16
-			    width: 100%;
17
-			    /*width: 900px;*/
18
-			    /*height: 100%;*/
19
-			    height: 450px;
20
-			    overflow: hidden;
21
-    			border-radius: 3px;
22
-			}
23
-			.chat_left,.chat_sidebar{
24
-					float: left;
25
-			}
26
-			.chat_left ul li{
27
-				    /*padding: 9pt 15px;*/
28
-				   padding: 10px 10px;
29
-				    border-bottom: 1px solid #292c33;
30
-				    cursor: pointer;
31
-				    color: #f4f4f4;
32
-			}
33
-			.chat_left ul li .chat_name{
34
-				margin: 0;
35
-			}
36
-			.chat_sidebar{
37
-			    width: 200px;
38
-			    color: #f4f4f4;
39
-			    background-color: #2e3238;
40
-			}
41
-			#chat .chat_left,#chat .chat_main, #chat .chat_sidebar,.message_mincon{
42
-				    height: 100%;
43
-			}
44
-			#chat .chat_main ,.message_mincon{
45
-			    position: relative;
46
-			    /*overflow: hidden;*/
47
-			    background-color: #eee;
48
-			    height: 100%;
49
-			}
50
-			.ver_middle{
51
-				vertical-align: middle;
52
-			}
53
-			#chat .chat_left{
54
-				width: 70px;
55
-			    background: #2f3339;
56
-			    border-right: 1px solid #292c33;
57
-			}
58
-			
59
-			/*chat_sidebar开始*/
60
-			.pic_card{
61
-			    padding: 9pt;
62
-			    border-bottom: 1px solid #24272c;
63
-			}
64
-			.chat_name{
65
-				display: inline-block;
66
-			    margin: 0 0 0 15px;
67
-			    font-size: 1pc;
68
-			    vertical-align: middle;
69
-			    font-size: 14px;
70
-			}
71
-			.chat_sidebar_foot{
72
-				margin-top: 10px;
73
-			}
74
-			.sidebar_foot_seach{
75
-				padding: 0 10px;
76
-			    width: 100%;
77
-			    font-size: 9pt;
78
-			    color: #fff;
79
-			    height: 30px;
80
-			    line-height: 30px;
81
-			    border: 1px solid #3a3a3a;
82
-			    border-radius: 4px;
83
-			    outline: 0;
84
-			    background-color: #26292e;
85
-			}
86
-			.chat_sidebar_list{
87
-				height: 495px;
88
-   				overflow-y: auto;
89
-			}
90
-			.chat_sidebar_list li{
91
-				/*padding: 9pt 15px;*/
92
-				padding: 4pt 15px;
93
-			    border-bottom: 1px solid #292c33;
94
-			    cursor: pointer;
95
-			    -webkit-transition: background-color .1s;
96
-			    transition: background-color .1s;
97
-			        position: relative;
98
-			}
99
-			.chat_sidebar_list li.actives ,.chat_left li.actives{
100
-			    background-color: hsla(0,0%,100%,.1);
101
-			}
102
-			.chat_sidebar_list li.actives:hover ,.chat_left li.actives:hover{
103
-			    background-color: hsla(0,0%,100%,.1);
104
-			}
105
-			.chat_sidebar_list li:hover ,.chat_left li:hover{
106
-				    background-color: hsla(0,0%,100%,.03);
107
-				}
108
-		/*chat_sidebar结束*/
109
-		/*聊天区域开始*/
110
-		.message_count{
111
-			display: inline-block;
112
-			position: absolute;
113
-			right: 0;
114
-			border-radius: 50%;
115
-			background: red;
116
-			color: #fff;
117
-		}
118
-		.disnone{
119
-			display: none;
120
-		}
121
-		.main_message{
122
-		    /*overflow-y: scroll;*/
123
-		    /*height: calc(100% - 195px);*/
124
-		    height: 300px;
125
-		    /*margin-top: 2pc;*/
126
-		   /*padding-top: 35px;*/
127
-		}
128
-		.chat_person{
129
-			      position: absolute;
130
-			    width: 100%;
131
-			    top: 0;
132
-			    left: 0;
133
-			    height: 35px;
134
-    			line-height: 35px;
135
-			    border-bottom: 1px solid #ddd;
136
-			    background: #fff;
137
-			        z-index: 1000;
138
-		}
139
-		.main_message li{
140
-			margin-bottom: 15px;
141
-		}
142
-		.main_message .message_time{
143
-			    margin: 7px 0;
144
-   			 text-align: center;
145
-		}
146
-		.main_message .ver_middle{
147
-			    float: left;
148
-			    margin: 0 10px 0 0;
149
-			    border-radius: 3px;
150
-		}
151
-		.main_message .message_text{
152
-			    display: inline-block;
153
-			    position: relative;
154
-			    padding: 0 10px;
155
-			    max-width: calc(100% - 108px);
156
-			    min-height: 30px;
157
-			    line-height: 2.5;
158
-			    font-size: 9pt;
159
-			    text-align: left;
160
-			    word-break: break-all;
161
-			    background-color: #fafafa;
162
-			    border-radius: 4px;
163
-		}
164
-		.main_message .message_text:before{
165
-			content: " ";
166
-		    position: absolute;
167
-		    top: 9px;
168
-		    right: 100%;
169
-		    border: 6px solid transparent;
170
-		    border-right-color: #fafafa;
171
-		}
172
-		.main_message .self {
173
-			    text-align: right;
174
-			    }
175
-	   .main_message .self .ver_middle {
176
-	    	float: right;
177
-			margin: 0 0 0 10px;
178
-	    }
179
-		.main_message .self .message_text {
180
-			    background-color: #b2e281;
181
-				}
182
-		.main_message .self .message_text:before {
183
-			    right: inherit;
184
-			    left: 100%;
185
-			    border-right-color: transparent;
186
-			    border-left-color: #b2e281;
187
-			    }
188
-		
189
-		.main_sendMessage{
190
-			    /*position: absolute;*/
191
-			    width: 100%;
192
-			    /*bottom: 0;
1
+body {
2
+    color: #4d4d4d;
3
+    font: 14px/1.4em 'Helvetica Neue', Helvetica, 'Microsoft Yahei', Arial, sans-serif;
4
+    background: #f5f5f5 url(img/chat_bg.jpg) no-repeat center;
5
+    background-size: cover;
6
+}
7
+
8
+ul, li {
9
+    list-style: none;
10
+    margin: 0;
11
+    padding: 0;
12
+}
13
+
14
+#chat {
15
+    /*margin: 20px auto;*/
16
+    width: 100%;
17
+    /*width: 900px;*/
18
+    /*height: 100%;*/
19
+    height: 450px;
20
+    overflow: hidden;
21
+    border-radius: 3px;
22
+}
23
+
24
+.chat_left, .chat_sidebar {
25
+    float: left;
26
+}
27
+
28
+    .chat_left ul li {
29
+        /*padding: 9pt 15px;*/
30
+        padding: 10px 10px;
31
+        border-bottom: 1px solid #292c33;
32
+        cursor: pointer;
33
+        color: #f4f4f4;
34
+    }
35
+
36
+        .chat_left ul li .chat_name {
37
+            margin: 0;
38
+        }
39
+
40
+.chat_sidebar {
41
+    width: 200px;
42
+    color: #f4f4f4;
43
+    background-color: #2e3238;
44
+}
45
+
46
+#chat .chat_left, #chat .chat_main, #chat .chat_sidebar, .message_mincon {
47
+    height: 100%;
48
+}
49
+
50
+#chat .chat_main, .message_mincon {
51
+    position: relative;
52
+    /*overflow: hidden;*/
53
+    background-color: #eee;
54
+    height: 100%;
55
+}
56
+
57
+.ver_middle {
58
+    vertical-align: middle;
59
+}
60
+
61
+#chat .chat_left {
62
+    width: 70px;
63
+    background: #2f3339;
64
+    border-right: 1px solid #292c33;
65
+}
66
+
67
+/*chat_sidebar开始*/
68
+.pic_card {
69
+    padding: 9pt;
70
+    border-bottom: 1px solid #24272c;
71
+}
72
+
73
+.chat_name {
74
+    display: inline-block;
75
+    margin: 0 0 0 15px;
76
+    font-size: 1pc;
77
+    vertical-align: middle;
78
+    font-size: 14px;
79
+}
80
+
81
+.chat_sidebar_foot {
82
+    margin-top: 10px;
83
+}
84
+
85
+.sidebar_foot_seach {
86
+    padding: 0 10px;
87
+    width: 100%;
88
+    font-size: 9pt;
89
+    color: #fff;
90
+    height: 30px;
91
+    line-height: 30px;
92
+    border: 1px solid #3a3a3a;
93
+    border-radius: 4px;
94
+    outline: 0;
95
+    background-color: #26292e;
96
+}
97
+
98
+.chat_sidebar_list {
99
+    height: 495px;
100
+    overflow-y: auto;
101
+}
102
+
103
+    .chat_sidebar_list li {
104
+        /*padding: 9pt 15px;*/
105
+        padding: 4pt 15px;
106
+        border-bottom: 1px solid #292c33;
107
+        cursor: pointer;
108
+        -webkit-transition: background-color .1s;
109
+        transition: background-color .1s;
110
+        position: relative;
111
+    }
112
+
113
+        .chat_sidebar_list li.actives, .chat_left li.actives {
114
+            background-color: hsla(0,0%,100%,.1);
115
+        }
116
+
117
+            .chat_sidebar_list li.actives:hover, .chat_left li.actives:hover {
118
+                background-color: hsla(0,0%,100%,.1);
119
+            }
120
+
121
+        .chat_sidebar_list li:hover, .chat_left li:hover {
122
+            background-color: hsla(0,0%,100%,.03);
123
+        }
124
+/*chat_sidebar结束*/
125
+/*聊天区域开始*/
126
+.message_count {
127
+    display: inline-block;
128
+    position: absolute;
129
+    right: 0;
130
+    border-radius: 50%;
131
+    background: red;
132
+    color: #fff;
133
+}
134
+
135
+.disnone {
136
+    display: none;
137
+}
138
+
139
+.main_message {
140
+    /*overflow-y: scroll;*/
141
+    /*height: calc(100% - 195px);*/
142
+    height: 300px;
143
+    /*margin-top: 2pc;*/
144
+    /*padding-top: 35px;*/
145
+}
146
+
147
+.chat_person {
148
+    position: absolute;
149
+    width: 100%;
150
+    top: 0;
151
+    left: 0;
152
+    height: 35px;
153
+    line-height: 35px;
154
+    border-bottom: 1px solid #ddd;
155
+    background: #fff;
156
+    z-index: 1000;
157
+}
158
+
159
+.main_message li {
160
+    margin-bottom: 15px;
161
+}
162
+
163
+.main_message .message_time {
164
+    margin: 7px 0;
165
+    text-align: center;
166
+}
167
+
168
+.main_message .ver_middle {
169
+    float: left;
170
+    margin: 0 10px 0 0;
171
+    border-radius: 3px;
172
+}
173
+
174
+.main_message .message_text {
175
+    display: inline-block;
176
+    position: relative;
177
+    padding: 5px 10px 0 10px;
178
+    max-width: calc(100% - 108px);
179
+    min-height: 28px;
180
+    line-height: 2;
181
+    font-size: 9pt;
182
+    text-align: left;
183
+    word-break: break-all;
184
+    background-color: #fafafa;
185
+    border-radius: 4px;
186
+}
187
+
188
+    .main_message .message_text:before {
189
+        content: " ";
190
+        position: absolute;
191
+        top: 9px;
192
+        right: 100%;
193
+        border: 6px solid transparent;
194
+        border-right-color: #fafafa;
195
+    }
196
+
197
+    .main_message .message_text p {
198
+        margin: 2px 0 10px 0;
199
+        line-height: 2;
200
+    }
201
+
202
+.main_message .self {
203
+    text-align: right;
204
+}
205
+
206
+    .main_message .self .ver_middle {
207
+        float: right;
208
+        margin: 0 0 0 10px;
209
+    }
210
+
211
+    .main_message .self .message_text {
212
+        background-color: #b2e281;
213
+    }
214
+
215
+        .main_message .self .message_text:before {
216
+            right: inherit;
217
+            left: 100%;
218
+            border-right-color: transparent;
219
+            border-left-color: #b2e281;
220
+        }
221
+
222
+
223
+.main_sendMessage {
224
+    /*position: absolute;*/
225
+    width: 100%;
226
+    /*bottom: 0;
193 227
 			    left: 0;*/
194
-			         height: 150px; 
195
-  				 border-top: 1px solid #ddd;
196
-  				 background: #fff;
197
-		}
198
-		.main_sendMessage textarea{
199
-			    padding: 10px;
200
-			    height: 55%;
201
-			    width: 98%;
202
-			    border: none;
203
-			    outline: 0;
204
-			    font-family: Micrsofot Yahei;
205
-			    resize: none;
206
-		}
207
-		.main_sendMessage .send_btn{
208
-			height: 20%;
209
-			text-align: right;
210
-			color: #4d4d4d;
211
-			    padding-right: 20px;
212
-		}
213
-		.main_sendMessage .send_btn button{
214
-			border: 1px solid #ccc;
215
-			background: #fff;
216
-			outline: none;
217
-		}
218
-		.main_sendMessage .send_btn button:hover{
219
-			background: #b2e281;
220
-		}
221
-		
222
-		/*聊天区域结束*/
228
+    height: 150px;
229
+    border-top: 1px solid #ddd;
230
+    background: #fff;
231
+}
232
+
233
+    .main_sendMessage textarea {
234
+        padding: 10px;
235
+        height: 55%;
236
+        width: 98%;
237
+        border: none;
238
+        outline: 0;
239
+        font-family: Micrsofot Yahei;
240
+        resize: none;
241
+    }
242
+
243
+    .main_sendMessage .send_btn {
244
+        height: 20%;
245
+        text-align: right;
246
+        color: #4d4d4d;
247
+        padding-right: 20px;
248
+    }
249
+
250
+        .main_sendMessage .send_btn button {
251
+            border: 1px solid #ccc;
252
+            background: #fff;
253
+            outline: none;
254
+        }
255
+
256
+            .main_sendMessage .send_btn button:hover {
257
+                background: #b2e281;
258
+            }
259
+
260
+/*聊天区域结束*/

BIN
WebSite/img/robot.png


+ 211 - 190
WebSite/js/chat.js

@@ -1,198 +1,219 @@
1
- 		  var uid = localStorage.getItem("uid");
2
- 		  var ws, obj = {},
3
- 		  	lockReconnect = false;
4
- 		  CreateWebSocket();
1
+var uid = localStorage.getItem("uid");
2
+var ws, obj = {},
3
+lockReconnect = false;
4
+CreateWebSocket();
5
+$(".send_content").focus();
5 6
 
6
- 		  function CreateWebSocket() {
7
- 		  	try {
8
- 		  		Connect();
9
- 		  	} catch(e) {
10
- 		  		ReConnect();
11
- 		  	}
12
- 		  }
13
- 		  //连接
14
- 		  function Connect() {
15
- 		  	//ws = new WebSocket("ws://192.168.4.18:4006");
16
- 		  	//ws = new WebSocket("ws://192.168.1.21:2021");
17
- 		  	ws = new WebSocket("ws://117.158.196.116:4006");
7
+function CreateWebSocket() {
8
+    try {
9
+        Connect();
10
+    } catch (e) {
11
+        ReConnect();
12
+    }
13
+}
14
+//连接
15
+function Connect() {
16
+    //ws = new WebSocket("ws://192.168.4.18:4006");
17
+    ws = new WebSocket("ws://192.168.8.10:2022");
18
+    //ws = new WebSocket("ws://117.158.196.116:4006");
18 19
 
19
- 		  	ws.onopen = function() {
20
- 		  		console.log(new Date() + "    " + "建立连接");
21
- 		  		lockReconnect = false;
22
- 		  		obj.action = "cusconn";
23
- 		  		obj.code = uid;
24
- 		  		Send();
25
- 		  	};
26
- 		  	//接收到消息的回调方法
27
- 		  	ws.onmessage = function(evt) {
28
- 		  		console.log(new Date() + "  receive  " + evt.data);
29
- 		  		var data = JSON.parse(evt.data);
30
- 		  		if(data) {
31
- 		  			var type = data.action;
32
- 		  			switch(type.toLowerCase()) {
33
- 		  				case "cusconn":
34
- 		  					$(".main_message .chatlist_con").find("li").remove();
35
- 		  					if(data.state) {
36
- 		  						localStorage.setItem("uid", data.code);
37
- 		  					} else {
38
-// 		  						$('.notice').html('');
39
-   		  						notice("notice", data.msg);
40
- 		  					}
41
- 		  					if(data.code) {
42
- 		  						obj.action = "loglist";
43
- 		  						obj.code = data.code;
44
- 		  						obj.msg = "";
45
- 		  						Send();
46
- 		  					}
47
- 		  					break;
48
- 		  					//case "servicerson":
49
- 		  					//    append("notice", data.msg);
50
- 		  					//    break; //通知客服上线
51
- 		  				case "cussend":
52
- 		  					if(data.state) {
53
- 		  						append("self", data.msg,data.time);
54
-// 		  						document.getElementById("msg").value = "";
55
- 		  						$('.send_content').val('');
56
- 		  					} else {
57
-   		  						   notice("notice", data.msg);
58
-// 		  							$('.notice').html(data.msg);
59
- 		  					}
60
- 		  					break
61
- 		  				case "cusreceive":
62
- 		  					append("left", data.msg,data.time)
63
- 		  					break; //收到消息
64
- 		  				case "loglist":
65
- 		  					var list = data.data.rows;
66
- 		  					$(list).each(function(i, n) {
67
- 		  						var classname = "left";
68
- 		  						if(n.F_FromUser == uid) {
69
- 		  							classname = "self";
70
- 		  						}
71
- 		  						insert(classname, n.F_Message, $(".hidnum").val());
72
- 		  					})
73
- 		  					if(!data.data.isfirst) {
74
- 		  						$(".more").css("display", "block");
75
- 		  						$(".hidnum").val(data.data.num);
76
- 		  					} else {
77
- 		  						$(".more").css("display", "none");
78
- 		  					}
79
- 		  					break; //聊天记录
80
- 		  			}
81
- 		  		}
82
- 		  	};
83
- 		  	//连接关闭的回调方法
84
- 		  	ws.onclose = function(evt) {
85
- 		  		console.log(new Date() + "    " + "连接关闭");
86
- 		  		console.log(new Date() + "    " + "开始重连");
87
- 		  		ReConnect();
88
- 		  	};
89
- 		  	//连接发生错误的回调方法
90
- 		  	ws.onerror = function(evt) {
91
- 		  		console.log(new Date() + "    " + "连接关闭");
92
- 		  		console.log(new Date() + "    " + "开始重连");
93
- 		  		ReConnect();
94
- 		  	};
95
- 		  }
96
- 		  //重连
97
- 		  function ReConnect() {
98
- 		  	if(!lockReconnect) {
99
- 		  		lockReconnect = true;
100
- 		  		//没连接上会一直重连,设置延迟避免请求过多
101
- 		  		setTimeout(function() {
102
- 		  			console.log(new Date() + "    " + "重连中……");
103
- 		  			lockReconnect = false;
104
- 		  			CreateWebSocket();
105
- 		  		}, 2000);
106
- 		  	}
107
- 		  }
108
-
109
- 		  //发送
110
- 		  function Send() {
111
- 		  	if(ws.readyState != ws.OPEN) {
112
- 		  		ReConnect();
113
- 		  	}
114
- 		  	if(ws.readyState == ws.OPEN) {
115
- 		  		console.log(new Date() + "  send  " + JSON.stringify(obj));
116
- 		  		ws.send(JSON.stringify(obj));
117
- 		  	}
118
- 		  }
119
- 		  //查看更多
120
- 		  function getmore() {
121
- 		  	obj.action = "loglist";
122
- 		  	obj.code = localStorage.getItem("uid");
123
- 		  	obj.msg = $(".hidnum").val();
124
- 		  	Send();
125
- 		  }
126
- 		  //发送消息
127
- 		  function sendinfo() {
128
- 		  	//      var msg = document.getElementById("msg").value;
129
- 		  	var msg = $('.send_content').val();
130
- 		  	if($.trim(msg)) {
131
- 		  		obj.action = "cussend";
132
- 		  		obj.msg = msg;
133
- 		  		Send();
134
- 		  		$(".error").text("");
135
- 		  	} else {
136
- 		  		 $('.send_content').val('');
137
- 		  		$(".error").text("请输入内容");
138
- 		  	}
139
- 		  }
140
-
141
- 		  function append(cname, msg,dates) {
142
- 		  	var html='<li>' +
143
-						'<p class="message_time"><span>' + dates + '</span></p>'+
144
-						'<div class="message_mincon ' + cname + '">'
145
-  						if(cname=='self'){
146
-  							html +='<img class="ver_middle chat_yhtx" src="img/kefuTx.png" alt="" width="30" height="30" />' 
147
-  						}else{
148
-  							html +='<img class="ver_middle" src="img/youkeTx.png" alt="" width="30" height="30"/>' 
149
-  						}
150
-  						html +='<div class="message_text">' + msg + '</div>' +
151
-  						'</div>' +
152
-  					'</li>'
153
- 		  	$(html).appendTo($(".chatlist_con")[0]);
154
- 		  	console.log($(".chatlist_con")[0].scrollHeight);
155
- 		  	$(".chatlist_con").scrollTop($(".chatlist_con")[0].scrollHeight);
156
- 		  }
157
-		 function insert(cname, msg, nodown) {
158
-            var html='<li>' +
159
-//						'<p class="message_time"><span>' + n.CreateDate + '</span></p>' +
160
-  						'<div class="message_mincon ' + cname + '">' 
161
-  						if(cname=='self'){
162
-  							html +='<img class="ver_middle chat_yhtx" src="img/kefuTx.png" alt="" width="30" height="30" />' 
163
-  						}else{
164
-  							html +='<img class="ver_middle" src="img/youkeTx.png" alt="" width="30" height="30"/>' 
165
-  						}
166
-  						html +='<div class="message_text">' + msg + '</div>' +
167
-  						'</div>' +
168
-  					'</li>'
169
-            var list=$(".chatlist_con").find("li");
170
-            if (list.length) {
171
-                $(html).insertBefore(list[0]);
172
-            }
173
-            else {
174
-                $(html).appendTo($(".chatlist_con")[0]);
175
-            }
176
-            if (!nodown) {
177
-                $(".chatlist_con").scrollTop($(".chatlist_con")[0].scrollHeight);
20
+    ws.onopen = function () {
21
+        console.log(new Date() + "    " + "建立连接");
22
+        lockReconnect = false;
23
+        obj.action = "cusconn";
24
+        obj.code = uid;
25
+        Send();
26
+    };
27
+    //接收到消息的回调方法
28
+    ws.onmessage = function (evt) {
29
+        console.log(new Date() + "  receive  " + evt.data);
30
+        var data = JSON.parse(evt.data);
31
+        if (data) {
32
+            var type = data.action;
33
+            switch (type.toLowerCase()) {
34
+                case "cusconn":
35
+                    // $(".main_message .chatlist_con").find("li").remove();
36
+                    if (data.state) {
37
+                        localStorage.setItem("uid", data.code);
38
+                    } else {
39
+                        // $('.notice').html('');
40
+                        notice("notice", data.msg);
41
+                    }
42
+                    if (data.code) {
43
+                        obj.action = "loglist";
44
+                        obj.code = data.code;
45
+                        obj.msg = "";
46
+                        Send();
47
+                    }
48
+                    break;
49
+                    //case "servicerson":
50
+                    //    append("notice", data.msg);
51
+                    //    break; //通知客服上线
52
+                case "cussend":
53
+                    if (data.state) {
54
+                        append("self", data.msg, data.time, data.humanclass);
55
+                        // document.getElementById("msg").value = "";
56
+                        $('.send_content').val('');
57
+                    } else {
58
+                        notice("notice", data.msg);
59
+                        // $('.notice').html(data.msg);
60
+                    }
61
+                    break
62
+                case "cusreceive":
63
+                    append("left", data.msg, data.time, data.humanclass)
64
+                    break; //收到消息
65
+                case "loglist":
66
+                    var list = data.data.rows;
67
+                    $(list).each(function (i, n) {
68
+                        var classname = "left";
69
+                        if (n.F_FromUser == uid) {
70
+                            classname = "self";
71
+                        }
72
+                        insert(classname, n.F_Message, $(".hidnum").val(), n.F_HumanClass);
73
+                    })
74
+                    if (!data.data.isfirst) {
75
+                        $(".more").css("display", "block");
76
+                        $(".hidnum").val(data.data.num);
77
+                    } else {
78
+                        $(".more").css("display", "none");
79
+                    }
80
+                    break; //聊天记录
178 81
             }
179 82
         }
83
+    };
84
+    //连接关闭的回调方法
85
+    ws.onclose = function (evt) {
86
+        console.log(new Date() + "    " + "连接关闭");
87
+        console.log(new Date() + "    " + "开始重连");
88
+        ReConnect();
89
+    };
90
+    //连接发生错误的回调方法
91
+    ws.onerror = function (evt) {
92
+        console.log(new Date() + "    " + "连接关闭");
93
+        console.log(new Date() + "    " + "开始重连");
94
+        ReConnect();
95
+    };
96
+}
97
+//重连
98
+function ReConnect() {
99
+    if (!lockReconnect) {
100
+        lockReconnect = true;
101
+        //没连接上会一直重连,设置延迟避免请求过多
102
+        setTimeout(function () {
103
+            console.log(new Date() + "    " + "重连中……");
104
+            lockReconnect = false;
105
+            CreateWebSocket();
106
+        }, 2000);
107
+    }
108
+}
180 109
 
181
- 		  //键盘发送事件
182
- 		  $(document).keydown(function(event) {
183
- 		  		 event = event || window.event; 
184
-					if($(".send_content").is(":focus")==true){
185
-						if(event.keyCode == 13) {
186
-		   		  		$(".sendTo").click();
187
-		   		  		 event.returnValue = false;    
188
-						return false
189
-		   		  	}
190
-					}
191
- 		  });
192
- 		   function notice(cname, msg){
193
-            var html = '<li><span class="' + cname + '">' + msg + '</span></li>';
194
-            $(html).appendTo($(".chatlist_con")[0]);
110
+//发送
111
+function Send() {
112
+    if (ws.readyState != ws.OPEN) {
113
+        ReConnect();
114
+    }
115
+    if (ws.readyState == ws.OPEN) {
116
+        console.log(new Date() + "  send  " + JSON.stringify(obj));
117
+        ws.send(JSON.stringify(obj));
118
+    }
119
+}
120
+//查看更多
121
+function getmore() {
122
+    obj.action = "loglist";
123
+    obj.code = localStorage.getItem("uid");
124
+    obj.msg = $(".hidnum").val();
125
+    Send();
126
+}
127
+//发送消息
128
+function sendinfo() {
129
+    //      var msg = document.getElementById("msg").value;
130
+    var msg = $('.send_content').val();
131
+    if ($.trim(msg)) {
132
+        obj.action = "cussend";
133
+        obj.msg = msg;
134
+        Send();
135
+        $(".error").text("");
136
+    } else {
137
+        $('.send_content').val('');
138
+        $(".error").text("请输入内容");
139
+    }
140
+}
195 141
 
196
-            $(".chatlist_con").scrollTop($(".chatlist_con")[0].scrollHeight);
142
+function append(cname, msg, dates, humanclass) {
143
+    var html = '<li>' +
144
+                '<p class="message_time"><span>' + dates + '</span></p>' +
145
+                '<div class="message_mincon ' + cname + '">'
146
+    if (humanclass) {
147
+        if (humanclass == 1)
148
+            html += '<img class="ver_middle chat_yhtx" src="img/kefuTx.png" alt="" width="30" height="30" />'
149
+        else if (humanclass == 2)
150
+            html += '<img class="ver_middle chat_yhtx" src="img/youkeTx.png" alt="" width="30" height="30" />'
151
+        else
152
+            html += '<img class="ver_middle chat_yhtx" src="img/robot.png" alt="" width="30" height="30" />'
153
+    }
154
+    else {
155
+        if (cname == 'self') {
156
+            html += '<img class="ver_middle chat_yhtx" src="img/kefuTx.png" alt="" width="30" height="30" />'
157
+        } else {
158
+            html += '<img class="ver_middle" src="img/youkeTx.png" alt="" width="30" height="30"/>'
197 159
         }
160
+    }
161
+    html += '<div class="message_text">' + msg + '</div>' +
162
+    '</div>' +
163
+    '</li>'
164
+    $(html).appendTo($(".chatlist_con")[0]);
165
+    console.log($(".chatlist_con")[0].scrollHeight);
166
+    $(".chatlist_con").scrollTop($(".chatlist_con")[0].scrollHeight);
167
+}
168
+function insert(cname, msg, nodown, humanclass) {
169
+    var html = '<li>' +
170
+//				'<p class="message_time"><span>' + n.CreateDate + '</span></p>' +
171
+                '<div class="message_mincon ' + cname + '">'
172
+    if (humanclass) {
173
+        if (humanclass == 1)
174
+            html += '<img class="ver_middle chat_yhtx" src="img/kefuTx.png" alt="" width="30" height="30" />'
175
+        else if (humanclass == 2)
176
+            html += '<img class="ver_middle chat_yhtx" src="img/youkeTx.png" alt="" width="30" height="30" />'
177
+        else
178
+            html += '<img class="ver_middle chat_yhtx" src="img/robot.png" alt="" width="30" height="30" />'
179
+    }
180
+    else {
181
+        if (cname == 'self') {
182
+            html += '<img class="ver_middle chat_yhtx" src="img/kefuTx.png" alt="" width="30" height="30" />'
183
+        } else {
184
+            html += '<img class="ver_middle" src="img/youkeTx.png" alt="" width="30" height="30"/>'
185
+        }
186
+    }
187
+    html += '<div class="message_text">' + msg + '</div>' +
188
+    '</div>' +
189
+    '</li>'
190
+    var list = $(".chatlist_con").find("li");
191
+    if (list.length) {
192
+        $(html).insertBefore(list[0]);
193
+    }
194
+    else {
195
+        $(html).appendTo($(".chatlist_con")[0]);
196
+    }
197
+    if (!nodown) {
198
+        $(".chatlist_con").scrollTop($(".chatlist_con")[0].scrollHeight);
199
+    }
200
+}
201
+
202
+//键盘发送事件
203
+$(document).keydown(function (event) {
204
+    event = event || window.event;
205
+    if ($(".send_content").is(":focus") == true) {
206
+        if (event.keyCode == 13) {
207
+            $(".sendTo").click();
208
+            event.returnValue = false;
209
+            return false
210
+        }
211
+    }
212
+});
213
+function notice(cname, msg) {
214
+    var html = '<li><span class="' + cname + '">' + msg + '</span></li>';
215
+    $(html).appendTo($(".chatlist_con")[0]);
216
+
217
+    $(".chatlist_con").scrollTop($(".chatlist_con")[0].scrollHeight);
218
+}
198 219
 

+ 1 - 1
WebSite/layer/skin/default/layer.css

@@ -593,7 +593,7 @@ html #layuicss-skinlayercss {
593 593
 
594 594
 .layui-layer-iframe iframe {
595 595
 	display: block;
596
-	width: 100%
596
+	width: 100%;
597 597
 }
598 598
 
599 599
 .layui-layer-loading {

+ 1 - 1
WebUI/.vs/config/applicationhost.config

@@ -162,7 +162,7 @@
162 162
             </site>
163 163
             <site name="CallCenterWeb.UI" id="2">
164 164
                 <application path="/" applicationPool="Clr4IntegratedAppPool">
165
-                    <virtualDirectory path="/" physicalPath="E:\2017\商丘12345\SQ12345_Web\WebUI\CallCenterWeb.UI" />
165
+                    <virtualDirectory path="/" physicalPath="E:\2017\IM在线客服\IM12345_Web\WebUI\CallCenterWeb.UI" />
166 166
                 </application>
167 167
                 <bindings>
168 168
                     <binding protocol="http" bindingInformation="*:60628:localhost" />