luke 6 rokov pred
rodič
commit
147a1db88f
1 zmenil súbory, kde vykonal 42 pridanie a 53 odobranie
  1. 42 53
      pc_chat/src/components/chat.vue

+ 42 - 53
pc_chat/src/components/chat.vue

@@ -168,25 +168,15 @@
 							</div>
 
 							<!--············· 各种消息提示框 ··············-->
-							<!-- 转接客服 -->
-							<div class="promptBox" v-if="artAndLeave == 10">
-								<div class="prompt">
-									<span>已转接人工客服</span>
-								</div>
-							</div>
-							<!-- 客服关闭会话 -->
-							<div class="promptBox" v-if="closeByServer">
-								<div class="prompt" style="width: 150px">
-									<span>已重新连接</span>
-								</div>
-							</div>
+
 							<!-- 客服不在线帮助提示框 -->
-							<div class="promptBox " v-if="artAndLeave == 100">
+							<div class="promptBox" v-if="artAndLeave == 100">
 								<div class="prompt help">
 									<span>当前客服不在线,如需帮助请</span>
 									<span class="colE5 ly pointer" @click="leaveMsg()">留言</span>
 								</div>
 							</div>
+
 						</div>
 
 						<!--············ 和人工会话聊天模块 ··············-->
@@ -251,30 +241,12 @@
 								<span>欢迎你的咨询,请对我们的服务做出评价</span>
 								<span class="btn seek">评价</span>
 							</div>
+
 							<div class="promptBox " v-if="comtSuccess">
 								<div class="prompt help">
 									<span>您对我们的服务评价为: {{comtCount}}。非常感谢!</span>
 								</div>
 							</div>
-							<!-- 系统即将结束会话
-							<div class="promptBoxH " v-if="willOverTime">
-							  <div class="prompt help" style="width: 280px; height: 35px;">
-								<span>{{willOverTime}}</span>
-							  </div>
-							</div> -->
-							<!-- 客服关闭会话 -->
-							<div class="promptBox " v-if="closeByServer">
-								<div class="prompt help" style="width: 280px;">
-									<span>会话已关闭,如需继续咨询请</span>
-									<span class="colE5 ly pointer" @click="goBack()">重新连接</span>
-								</div>
-							</div>
-							<!-- 客服关闭会话 -->
-							<div class="promptBox " v-if="serverNotOnlin">
-								<div class="prompt help" style="width: 280px;">
-									<span>客服掉线</span>
-								</div>
-							</div>
 						</div>
 					</el-row>
 
@@ -487,9 +459,14 @@
 				timeout: 10000,          //10s一次心跳检测
 				timeoutObj: null,
 				serverTimeoutObj: null,
+
 			}
 		},
 		methods: {
+			// 切换留言板返回
+			back(){
+				this.$emit('value',100)
+			},
 			/******************文字信息转表情******************/
 			turnFace(data) {
 				let str = data.match(/\#\[.*?\]\//g);
@@ -600,19 +577,21 @@
 				this.$emit('value', 100)
 			},
 			//回到初始页面
-			goBack() {
-				this.artAndLeave = 0;
-				this.machineAndAtl = 10;
-				this.macNotPro = false;
-				this.jumpArtl = false;
-				this.time = '';
-				this.returnTimer = '';
-				// this.automaticRolling();
-				this.initWebSocket();
-				this.chatCont = [];
-				this.customerSviceChat = [];
-				this.reconnect();
-				//this.questionShow = true;
+			goBack(type) {
+				if (type === 1) {
+					this.artAndLeave = 0;
+					this.chatCont = [];
+				}else {
+					this.machineAndAtl = 10;
+					this.macNotPro = false;
+					this.jumpArtl = false;
+					this.time = '';
+					this.returnTimer = '';
+					// this.automaticRolling();
+					this.initWebSocket();
+					this.customerSviceChat = [];
+					this.reconnect();
+				}
 			},
 
 
@@ -801,13 +780,15 @@
 			/*************连接建立失败重连***************** */
 			websocketonerror() {
 				console.log('连接建立失败重连');
-				this.goBack();
-
+				this.goBack(1);
 			},
 
 			/**************数据接收***************** */
 			websocketonmessage(e) {
-				const redata = JSON.parse(e.data);
+				let redata = e
+				if(e.data){
+					redata = JSON.parse(e.data);
+				}
 				//心跳检测
 				this.heatBeat()
 				console.log(redata)
@@ -823,7 +804,6 @@
 				if (redata.message_type == 'getEvaluate') {
 					this.consult = true;
 				}
-
 				//返回的会话时间
 				if (redata.message_type == 'webTime') {
 					//处理会话时间大于两分钟显示会话时间并且储存本次会话时间
@@ -840,12 +820,10 @@
 					}
 
 				}
-
 				//会话超时提示
 				if (redata.message_type == 'overtime') {
 					console.log('接收会话超时');
 				}
-
 				// 链接客服信息
 				if (redata.message_type == 'connect') {
 					this.artAndLeave = 10;
@@ -933,11 +911,20 @@
 					this.machineAndAtl = 10;
 					this.jumpArtl = false;
 					this.initWebSocket();
-					//this.noServer();
+
+					// const loading = this.$loading({
+					// 	lock: true,
+					// 	text: 'Loading',
+					// 	spinner: 'el-icon-loading',
+					// 	background: 'rgba(0, 0, 0, 0.7)'
+					// });
+					// setTimeout(() => {
+					// 	loading.close();
+					// }, 2000);
 				}
 				// 客服关闭会话.
 				if (redata.message_type == 'closeBysever') {
-					this.goBack();
+					this.goBack(1);
 					// this.closeByServer = true;
 					// this.automaticRolling();
 				}
@@ -952,6 +939,8 @@
 					this.willOverTime = redata.data.content;
 					this.automaticRolling();
 				}
+
+
 			},