Ver código fonte

update pc_chat

luke 6 anos atrás
pai
commit
f1a5969bdc
2 arquivos alterados com 44 adições e 16 exclusões
  1. 44 14
      pc_chat/src/components/chat.vue
  2. 0 2
      pc_chat/src/components/leaveMsg.vue

+ 44 - 14
pc_chat/src/components/chat.vue

@@ -46,7 +46,6 @@
 
 						<!-------------------机器人聊天板块 ----------------------->
 						<div v-if="machineAndAtl == 10">
-
 							<!--··············· 欢迎语 ············-->
 							<div class="conversationBox">
 								<div class="row" v-for="(item,index) in machine" :key="index">
@@ -386,7 +385,7 @@
 								<div class="infor">
 									<div>
 										<span>姓名:</span>
-										<span v-if="service">{{ service.serverInfo.name ? service.serverInfo.name : '001客服' }}</span>
+										<span v-if="service.serverInfo">{{ service.serverInfo.name ? service.serverInfo.name : '001客服' }}</span>
 									</div>
 
 									<div>
@@ -426,7 +425,7 @@
 			</div>
 			<!-- 评价框 -->
 			<el-card class="box-card" v-if="evlShow">
-				<div class="close"><i  @click="closeEvl()"></i></div>
+				<div class="close"><i @click="closeEvl()"></i></div>
 				<div class="tit">
 					<span>感谢您的咨询,请对我们的服务做出评价</span>
 				</div>
@@ -456,7 +455,7 @@
 <script>
 	import '../css/index.css';
 	import frce from '../assets/frce.js';
-
+	import fk from '../assets/st-img/kf.png'
 	export default {
 		data() {
 			return {
@@ -516,6 +515,7 @@
 				timerVote: '', //存储上一次时间
 				curtTimer: '',//当前时间
 				returnTimer: '',//返回当前时间
+
 				// isConnection:true,//人工分组列表开关
 				chatNum: '', // 会话数量
 				comtSuccess: false, // 评论发送成功显示
@@ -526,7 +526,7 @@
 				sensitiveNumber: 0,//敏感词次数
 				doubSensitive: [],//重复的敏感词
 				senInfo: '', //敏感词数据
-				// sensitiveWordsNumber:0,
+
 				hourse: '', //返回时间,小时
 				closeByServer: false, //客服关闭会话
 				serverNotOnlin: false, //客服掉线
@@ -550,6 +550,7 @@
 				waitingText: "", // 等待内容
 
 				service_on:true, // 现在状态
+				avatarImg: fk
 			}
 		},
 		methods: {
@@ -956,16 +957,34 @@
 				}
 				// 链接客服信息
 				if (redata.message_type == 'connect') {
+					let serverInfo = {};
+					if (redata.data) {
+						serverInfo = redata.data
+					} else {
+						serverInfo = {
+							avatar: this.avatarImg,
+							client_id:"",
+							group:"",
+							id: "",
+							intime:"",
+							job_name: "",
+							name: "tank",
+							signature: "",
+							status: 0,
+							task: 0,
+						}
+					}
 					this.artAndLeave = 10;
 					this.machineAndAtl = 100;
-					this.service = redata.data;
-					// console.log(this.service, '============客服信息')
+					this.service = serverInfo;
+					console.log(this.service, '============客服信息')
 					this.serviceImg = redata.data.serverInfo.avatar;
 					this.consult = false;
 					this.evlShow = false;
 					this.comtSuccess = false;
 					this.showleaveIcon = false;
 					this.waitingMsg = false;
+
 				}
 				// 暂无客服
 				if (redata.message_type == 'wait') {
@@ -1104,7 +1123,7 @@
 
 			/************关闭会话*******************/
 			websocketclose(e) {
-				console.log('websocket 断开: ' + e.code + ' ' + e.reason + ' ', e)
+				console.log('websocket 关闭会话: ' + e.code, e)
 				this.goBack();
 			},
 
@@ -1124,7 +1143,7 @@
 				this.reconnectData && clearTimeout(this.reconnectData);
 				this.reconnectData = setTimeout(() => {
 					this.initWebSocket();
-					console.log('-----lail-----');
+					console.log('-----socket重连-----');
 					this.lockReconnect = false;
 				}, 5000)
 			},
@@ -1138,7 +1157,7 @@
 					// console.log('发送', {type: 'ping'});
 					this.websocketsend(JSON.stringify({type: 'ping'}))   //根据后台要求发送
 					this.serverTimeoutObj = setTimeout(() => {
-						console.log('------close-------')
+						// console.log('------心跳检测close-------')
 						this.websock.close(); //如果 5秒之后我们没有收到 后台返回的心跳检测数据 断开socket,断开后会启动重连机制
 
 					}, 5000);
@@ -1201,7 +1220,7 @@
 						}
 					}))
 					this.tokNum++;
-					console.log(this.tokNum,"我发的消息");
+					// console.log(this.tokNum,"我发的消息");
 
 				}
 				// 发送之后清空发送数据
@@ -1252,11 +1271,20 @@
 			/**************匿名注册**************** */
 			registered() {
 				let token = localStorage.getItem('token');
+				let appuid = this.$public.getQueryString('appuid');
+				// 有会员账号
+				// if (appuid) {
+				// 	token = localStorage.setItem('xx');
+				//
+				// }else {
+				// 无会员账号
+				// 	token = localStorage.setItem('xx');
+				// }
 
 				let data = {
-					token: token != null ? token : '',//
-					appid: this.$public.getQueryString('appid'),//
-					appuid: this.$public.getQueryString('appuid'),//
+					token: token != null ? token : '',
+					appid: this.$public.getQueryString('appid'),
+					appuid: this.$public.getQueryString('appuid'),
 				}
 				let obj = {
 					headers: {
@@ -1266,6 +1294,8 @@
 				this.$axios.post('/api/index/register/autoReg', data, obj).then(res => {
 					if (res.data.code == 1) {
 						this.user_info = res.data.data;
+						console.log(this.user_info,"用户信息")
+						// 游客 token
 						localStorage.setItem("token", res.data.data.token);
 						setTimeout(() => {
 							//关闭加载条

+ 0 - 2
pc_chat/src/components/leaveMsg.vue

@@ -6,8 +6,6 @@
 					<span @click="back()" class="back pointer"></span>
 					<span>我要留言</span>
 				</el-col>
-				<el-col>
-				</el-col>
 			</el-row>
 		</el-header>
 		<div class="cationer">