Bläddra i källkod

Merge branch 'master' of http://git.bocai108.com:10180/Ethan/Customer-Service-Web

李昌恒 6 år sedan
förälder
incheckning
80888c4d33
3 ändrade filer med 40 tillägg och 18 borttagningar
  1. 0 2
      .idea/.gitignore
  2. 0 5
      .idea/codeStyles/codeStyleConfig.xml
  3. 40 11
      pc_chat/src/components/chat.vue

+ 0 - 2
.idea/.gitignore

@@ -1,2 +0,0 @@
-# Default ignored files
-/workspace.xml

+ 0 - 5
.idea/codeStyles/codeStyleConfig.xml

@@ -1,5 +0,0 @@
-<component name="ProjectCodeStyleConfiguration">
-  <state>
-    <option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
-  </state>
-</component>

+ 40 - 11
pc_chat/src/components/chat.vue

@@ -246,6 +246,20 @@
 									<span>您对我们的服务评价为: {{comtCount}}。非常感谢!</span>
 								</div>
 							</div>
+
+							<!-- 客服会话转接 -->
+							<div class="promptBox" v-if="changeKeFu">
+								<div class="prompt help">
+									<span>会话转接成功</span>
+								</div>
+							</div>
+
+							<!-- 客服会话超时 -->
+							<div class="promptBox" v-if="willOverTime">
+								<div class="prompt help">
+									<span>您好,未能收到您的回复,稍后将自动结束本次会话</span>
+								</div>
+							</div>
 						</div>
 					</el-row>
 
@@ -283,7 +297,7 @@
 											   cols="30"
 											   rows="1"
 											   placeholder="请输入你的问题:"
-											   @keyup.enter.exact="listenEnter"
+											   @keyup.enter.exact="listenEnter($event)"
 											   @keyup.ctrl.enter="lineFeed()"
 									>
 									</textarea>
@@ -457,9 +471,10 @@
 				hourse: '', //返回时间,小时
 				closeByServer: false, //客服关闭会话
 				serverNotOnlin: false, //客服掉线
-				willOverTime: '', //超时关闭会话
+				willOverTime: false, //超时关闭会话
 				allLoading: true, //整个页面加载中
 				webTime: '',//网络时间
+				changeKeFu:false, //客服转接
 				/*****************websockt心跳变量*******************/
 				reconnectData: null,
 				lockReconnect: false,    //避免重复连接,因为onerror之后会立即触发 onclose
@@ -470,8 +485,13 @@
 		},
 		methods: {
 			// 回车提交
-			listenEnter(){
-				this.sendInfo();
+			listenEnter(event){
+				console.log(event);
+				if (event.keyCode === 13) {
+					this.sendInfo();
+					event.preventDefault() // 阻止浏览器默认换行操作
+					return false
+				}
 			},
 			// ctrl+center 换行
 			lineFeed(){
@@ -793,7 +813,7 @@
 
 			/*************连接建立失败重连***************** */
 			websocketonerror(e) {
-				console.log('连接建立失败重连: ' + e.code + ' ' + e.reason + ' ', e)
+				console.log('连接建立失败重连:', e)
 				this.goBack(1);
 			},
 
@@ -804,8 +824,11 @@
 					redata = JSON.parse(e.data);
 				}
 				//心跳检测
-				this.heatBeat()
-				console.log(redata)
+				this.heatBeat();
+
+				if(redata.type != 'pong'){
+					console.log(redata)
+				}
 				// 欢迎语
 				if (redata.message_type == 'helloMessage') {
 					this.machine = redata.data;
@@ -938,9 +961,14 @@
 					this.closeByServer = true;
 					this.automaticRolling();
 				}
-				// 超时.
+				// 客服转接
+				if(redata.message_type == 'changeKeFuSuccess'){
+					console.log('======转接成功========')
+					this.changeKeFu = true;
+				}
+				// 客服会话超时
 				if (redata.message_type == 'overtime') {
-					this.willOverTime = redata.data.content;
+					this.willOverTime = true;
 					this.automaticRolling();
 				}
 
@@ -963,7 +991,6 @@
 			/***************************************/
 			//socket重连
 			reconnect() {
-				console.log('=========重连==============')
 				if (this.lockReconnect) {       //这里很关键,因为连接失败之后之后会相继触发 连接关闭,不然会连接上两个 WebSocket
 					return
 				}
@@ -982,7 +1009,7 @@
 				this.timeoutObj && clearTimeout(this.timeoutObj);
 				this.serverTimeoutObj && clearTimeout(this.serverTimeoutObj);
 				this.timeoutObj = setTimeout(() => {
-					console.log('发送', {type: 'ping'});
+					// console.log('发送', {type: 'ping'});
 					this.websocketsend(JSON.stringify({type: 'ping'}))   //根据后台要求发送
 					this.serverTimeoutObj = setTimeout(() => {
 						console.log('------close-------')
@@ -1016,6 +1043,8 @@
 						}
 					}))
 				} else if (this.machineAndAtl == 100) { //人工聊天
+					// 人工聊天超时隐藏
+					this.willOverTime = false;
 					//发送给客服消息-本地储存
 					this.customerSviceChat.push({
 						time: '',