luke 6 vuotta sitten
vanhempi
commit
ffb105629a
1 muutettua tiedostoa jossa 21 lisäystä ja 21 poistoa
  1. 21 21
      pc_chat/src/components/chat.vue

+ 21 - 21
pc_chat/src/components/chat.vue

@@ -265,7 +265,7 @@
 							<!-- 客服会话超时 -->
 							<div class="promptBox" v-if="willOverTime">
 								<div class="prompt help">
-									<span>您好,未能收到您的回复,稍后将自动结束本次会话</span>
+									<span>{{overTimeMsg}}</span>
 								</div>
 							</div>
 
@@ -300,14 +300,14 @@
 
 							<div class="row center allAlignment chattingBox">
 								<div style="height:44px;width:300px;">
-									<textarea  name=""
+									<textarea name=""
 											   id="information"
 											   v-model.trim="information"
 											   cols="30"
 											   rows="1"
+											   autofocus
 											   placeholder="请输入你的问题:"
-											   @keyup.enter.exact="listenEnter($event)"
-											   @keyup.ctrl.enter="lineFeed()"
+											   @keyup.enter="listenEnter($event)"
 									>
 									</textarea>
 								</div>
@@ -496,6 +496,7 @@
 				closeByServer: false, //客服关闭会话
 				serverNotOnlin: false, //客服掉线
 				willOverTime: false, //超时关闭会话
+				overTimeMsg:'', // 超时提示内容
 				allLoading: true, //整个页面加载中
 				webTime: '',//网络时间
 				changeKeFu:false, //客服转接
@@ -515,23 +516,19 @@
 		methods: {
 			// 回车提交
 			listenEnter(event){
-				console.log(event);
-				if (event.keyCode === 13) {
-					// 判断如果是内容是空 清空内容
+				let text = document.getElementById('information');
+				if(event.keyCode == 13 && event.ctrlKey == true){
+					text.value = text.value + '\n'
+				}else if(event.keyCode == 13){
 					if(this.information == ""){
-						document.getElementById('information').value = '';
+						text.value = '';
 						return false
+					}else {
+						this.sendInfo();
+						event.preventDefault()
 					}
-					this.sendInfo();
-					// 阻止浏览器默认换行操作
-					event.preventDefault()
-					return false
 				}
 			},
-			// ctrl+center 换行
-			lineFeed(){
-				this.information = this.information + '\n'
-			},
 			// 切换留言板返回
 			back(){
 				this.$emit('value',100)
@@ -1016,6 +1013,7 @@
 					this.willOverTime = true;
 					this.automaticRolling();
 					// this.goBack();
+					this.overTimeMsg = redata.data.content;
 				}
 
 
@@ -1068,12 +1066,14 @@
 
 			/******************消息发送数据处理********************/
 			sendMessage() {
+				let str = this.information;
+			    let formatStr = str.replace(/\n/g,'<br/>');
 				// 给机器人发送文本消息
 				if (this.machineAndAtl == 10) {
 					//给机器人发送文本消息-本地储存
 					let datas = {
 						time: '',
-						chat: this.turnFace(this.shieldingKeyword(this.information)),
+						chat: this.turnFace(this.shieldingKeyword(formatStr)),
 						imgUrl: this.img,
 						type: 'user'
 					}
@@ -1083,7 +1083,7 @@
 						type: 'toRobot',
 						data: {
 							groups_id: '1',
-							robot_name: this.shieldingKeyword(this.information),
+							robot_name: this.shieldingKeyword(formatStr),
 							webTime: this.webTime,
 							robotgroups_id: '1',
 						}
@@ -1094,7 +1094,7 @@
 					//发送给客服消息-本地储存
 					this.customerSviceChat.push({
 						time: '',
-						content: this.turnFace(this.shieldingKeyword(this.information)),
+						content: this.turnFace(this.shieldingKeyword(formatStr)),
 						imgUrl: this.img,
 						type: 'user',
 					});
@@ -1107,7 +1107,7 @@
 							from_avatar: this.user_info.avatar,
 							from_id: this.user_info.id,
 							content: JSON.stringify({
-								text: this.information,
+								text: formatStr,
 								img: this.img,
 								type: 'user'
 							}),
@@ -1567,7 +1567,7 @@
 	}
 
 	.help {
-		width: 300px;
+		width: 80%;
 	}
 
 	.help .prompt {