李昌恒 6 years ago
parent
commit
d00f491125

+ 3 - 3
service/config/index.js

@@ -12,8 +12,8 @@ module.exports = {
     assetsPublicPath: '/',
     proxyTable: {
       '/api': {
-         //target: 'http://103.108.43.176:8080', // 后台访问地址
-        target:'http://192.168.2.186:8090', // 后台访问地址http://192.168.2.186:8090
+        target: 'http://103.108.43.176:8080', // 后台访问地址 http://kfadmin.bocai186.com
+        //target:'http://192.168.2.186:8090', // 后台访问地址http://192.168.2.186:8090
         // changeOrigin: true,
         pathRewrite: {
           '^/api': ''
@@ -22,7 +22,7 @@ module.exports = {
     },
 
     // Various Dev Server settings
-    host: 'localhost', // can be overwritten by process.env.HOST //192.168.2.163 localhost
+    host: 'localhost', // can be overwritten by process.env.HOST //192.168.2.163 
     port: 8000, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
     autoOpenBrowser: false,
     errorOverlay: true,

+ 16 - 41
service/package-lock.json

@@ -256,8 +256,7 @@
     "assert-plus": {
       "version": "1.0.0",
       "resolved": "https://registry.npm.taobao.org/assert-plus/download/assert-plus-1.0.0.tgz",
-      "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=",
-      "optional": true
+      "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU="
     },
     "assign-symbols": {
       "version": "1.0.0",
@@ -1918,7 +1917,6 @@
       "version": "1.0.8",
       "resolved": "https://registry.npm.taobao.org/combined-stream/download/combined-stream-1.0.8.tgz",
       "integrity": "sha1-w9RaizT9cwYxoRCoolIGgrMdWn8=",
-      "optional": true,
       "requires": {
         "delayed-stream": "~1.0.0"
       }
@@ -3268,8 +3266,7 @@
     "delayed-stream": {
       "version": "1.0.0",
       "resolved": "https://registry.npm.taobao.org/delayed-stream/download/delayed-stream-1.0.0.tgz",
-      "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=",
-      "optional": true
+      "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk="
     },
     "depd": {
       "version": "1.1.2",
@@ -3945,8 +3942,7 @@
     "extsprintf": {
       "version": "1.3.0",
       "resolved": "https://registry.npm.taobao.org/extsprintf/download/extsprintf-1.3.0.tgz",
-      "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=",
-      "optional": true
+      "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU="
     },
     "fast-deep-equal": {
       "version": "1.1.0",
@@ -4256,8 +4252,7 @@
         "ansi-regex": {
           "version": "2.1.1",
           "bundled": true,
-          "dev": true,
-          "optional": true
+          "dev": true
         },
         "aproba": {
           "version": "1.2.0",
@@ -4278,14 +4273,12 @@
         "balanced-match": {
           "version": "1.0.0",
           "bundled": true,
-          "dev": true,
-          "optional": true
+          "dev": true
         },
         "brace-expansion": {
           "version": "1.1.11",
           "bundled": true,
           "dev": true,
-          "optional": true,
           "requires": {
             "balanced-match": "^1.0.0",
             "concat-map": "0.0.1"
@@ -4300,20 +4293,17 @@
         "code-point-at": {
           "version": "1.1.0",
           "bundled": true,
-          "dev": true,
-          "optional": true
+          "dev": true
         },
         "concat-map": {
           "version": "0.0.1",
           "bundled": true,
-          "dev": true,
-          "optional": true
+          "dev": true
         },
         "console-control-strings": {
           "version": "1.1.0",
           "bundled": true,
-          "dev": true,
-          "optional": true
+          "dev": true
         },
         "core-util-is": {
           "version": "1.0.2",
@@ -4430,8 +4420,7 @@
         "inherits": {
           "version": "2.0.3",
           "bundled": true,
-          "dev": true,
-          "optional": true
+          "dev": true
         },
         "ini": {
           "version": "1.3.5",
@@ -4443,7 +4432,6 @@
           "version": "1.0.0",
           "bundled": true,
           "dev": true,
-          "optional": true,
           "requires": {
             "number-is-nan": "^1.0.0"
           }
@@ -4458,7 +4446,6 @@
           "version": "3.0.4",
           "bundled": true,
           "dev": true,
-          "optional": true,
           "requires": {
             "brace-expansion": "^1.1.7"
           }
@@ -4466,14 +4453,12 @@
         "minimist": {
           "version": "0.0.8",
           "bundled": true,
-          "dev": true,
-          "optional": true
+          "dev": true
         },
         "minipass": {
           "version": "2.3.5",
           "bundled": true,
           "dev": true,
-          "optional": true,
           "requires": {
             "safe-buffer": "^5.1.2",
             "yallist": "^3.0.0"
@@ -4492,7 +4477,6 @@
           "version": "0.5.1",
           "bundled": true,
           "dev": true,
-          "optional": true,
           "requires": {
             "minimist": "0.0.8"
           }
@@ -4573,8 +4557,7 @@
         "number-is-nan": {
           "version": "1.0.1",
           "bundled": true,
-          "dev": true,
-          "optional": true
+          "dev": true
         },
         "object-assign": {
           "version": "4.1.1",
@@ -4586,7 +4569,6 @@
           "version": "1.4.0",
           "bundled": true,
           "dev": true,
-          "optional": true,
           "requires": {
             "wrappy": "1"
           }
@@ -4672,8 +4654,7 @@
         "safe-buffer": {
           "version": "5.1.2",
           "bundled": true,
-          "dev": true,
-          "optional": true
+          "dev": true
         },
         "safer-buffer": {
           "version": "2.1.2",
@@ -4709,7 +4690,6 @@
           "version": "1.0.2",
           "bundled": true,
           "dev": true,
-          "optional": true,
           "requires": {
             "code-point-at": "^1.0.0",
             "is-fullwidth-code-point": "^1.0.0",
@@ -4729,7 +4709,6 @@
           "version": "3.0.1",
           "bundled": true,
           "dev": true,
-          "optional": true,
           "requires": {
             "ansi-regex": "^2.0.0"
           }
@@ -4773,14 +4752,12 @@
         "wrappy": {
           "version": "1.0.2",
           "bundled": true,
-          "dev": true,
-          "optional": true
+          "dev": true
         },
         "yallist": {
           "version": "3.0.3",
           "bundled": true,
-          "dev": true,
-          "optional": true
+          "dev": true
         }
       }
     },
@@ -5727,8 +5704,7 @@
     "jsbn": {
       "version": "0.1.1",
       "resolved": "https://registry.npm.taobao.org/jsbn/download/jsbn-0.1.1.tgz",
-      "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=",
-      "optional": true
+      "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM="
     },
     "jsesc": {
       "version": "1.3.0",
@@ -10993,8 +10969,7 @@
     "tweetnacl": {
       "version": "0.14.5",
       "resolved": "https://registry.npm.taobao.org/tweetnacl/download/tweetnacl-0.14.5.tgz",
-      "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=",
-      "optional": true
+      "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q="
     },
     "type": {
       "version": "1.0.1",

+ 13 - 6
service/src/App.vue

@@ -27,8 +27,8 @@ export default {
     //初始化weosocket
     initWebSocket(apiToken) {
       // 书写接口信息
-      //const wsuri = "ws://103.108.43.176:9101?apiToken=" + apiToken;//www.service.com 线上
-      const wsuri = "ws://192.168.2.186:9101?apiToken=" + apiToken;//www.service.com //192.168.2.186 本地
+      const wsuri = "ws://103.108.43.176:9101?apiToken=" + apiToken;//www.service.com 线上
+      //const wsuri = "ws://192.168.2.186:9101?apiToken=" + apiToken;//www.service.com //192.168.2.186 本地
       // 创建websocket实例
       Vue.prototype.$websocket = new WebSocket(wsuri);
       this.$websocket.onopen = this.websocketonopen; //连接成功
@@ -56,9 +56,12 @@ export default {
     /******************************************/
     //数据接收
     websocketonmessage(e){
-      // console.log(JSON.parse(e.data));
+      this.heatBeat();//收到消息会刷新心跳检测,如果一直收到消息,就推迟心跳发送
+      console.log('消息',JSON.parse(e.data));
+      if(e.data.type == "pong" ) return
       this.$store.dispatch("SET_SESSION_MESSAGE",JSON.parse(e.data));
-      this.heatBeat();      //收到消息会刷新心跳检测,如果一直收到消息,就推迟心跳发送
+      
+
     },   
 
     /**************************************/
@@ -104,12 +107,16 @@ export default {
             this.$websocket.close(); //如果  5秒之后我们没有收到 后台返回的心跳检测数据 断开socket,断开后会启动重连机制
         }, 5000);
       }, this.timeout)
-    },   
+    }, 
+    
+    /******************************/
     
   },
   mounted() {
     // 获取系统时间
-    this.get('api'+this.$ports.TIME).then(res => {
+    let t = new Date().getTime();
+    // this.get('api'+this.$ports.TIME+'?t='+t).then(res => {
+    this.get('http://kfadmin.bocai186.com'+this.$ports.TIME+'?t='+t).then(res => {
       if (res.data.code == 1) {
         let time = res.data.data.time.split(' ');
         time[0] =(new Date( time[0].replace(/-/g,'/')).getTime()) /1000;

+ 131 - 210
service/src/pages/TheCurrentSession.vue

@@ -214,24 +214,24 @@
 					<div style="color:#666;font-weight:bold;font-size:14px;">用户信息</div>
 					<div style="margin-top:10px;color:#999;font-size:14px;" class="userData wrap">
 						<div class="user_info_box">
-							<span>姓名:</span>
-							<input class="user_text" v-model="session_user_info.name" type="text">
+							<span>昵称:</span>
+							<input class="user_text" v-model="session_user_info.nick_name"  readonly type="text">
 						</div>
 						<div class="user_info_box">
 							<span>手机:</span>
-							<input class="user_text" v-model="session_user_info.phone" type="text">
+							<input class="user_text" v-model="session_user_info.account_phone" type="text">
 						</div>
 						<div class="user_info_box">
 							<span>邮箱:</span>
-							<input class="user_text" v-model="session_user_info.email" type="text">
+							<input class="user_text" v-model="session_user_info.account_email" type="text">
 						</div>
 						<div class="user_info_box">
 							<span>地址:</span>
-							<input class="user_text" v-model="session_user_info.addres" type="text">
+							<input class="user_text" v-model="session_user_info.address" type="text">
 						</div>
 						<p>访客备注:</p>
 					</div>
-					<textarea draggable="false"  class="userDataInput"  v-model="session_user_info.remark"  style="margin-top:10px;" ></textarea>
+					<textarea draggable="false"  class="userDataInput"  v-model="session_user_info.remark"  style="margin-top:10px;color:#999;" ></textarea>
 					<div class="userBtn row center">保存</div>
 
 					<div style="color:#666;font-weight:bold;font-size:14px;margin-top:30px;">访问信息</div>
@@ -275,14 +275,15 @@
 				conversationId:'',//会话工单
 				sessionName:'',//当前会话用户名字
 				session_user_info:{},//当前会话用户信息
-				// img_http:'http://kfadmin.bocai186.com',//图片路径域
-				img_http:'http://192.168.2.186:8090',//图片路径域
+				img_http:'http://kfadmin.bocai186.com',//图片路径域
+				//img_http:'http://192.168.2.186:8090',//图片路径域
 				fit:'scale-down',//图片渲染样式
 				is_eva_btn:true,//
 				trigger_condition:0,//评价触发条件
 				webTime:'',//客服会话时间
 				session_marked:'',//客服当前会话标记
-				sensitive:[],//敏感词数据
+				sensitive:[],//客服敏感词数据
+				userSensitiveWords:[],//用户敏感词
 			};
 		},
 		/**
@@ -302,201 +303,127 @@
 			lineFeed(){
 				this.inputValue = this.inputValue + '\n'
 			},
+
 			/******************消息数据接收********************/
 			chatMessage(redata){
-				// console.log('列表',this.sessionList)
-				if(redata.type == "pong" ) return
-				console.log('消息',redata)
+
 				// 用户接入数据
 				if(redata.message_type == "connect"){
-					this.conversationId = redata.data.conversationId;
-					redata.data.user_info.conversationId = redata.data.conversationId;
-					let isTrue = true;
-					//匹配是否是离线用户上线
-					if(this.offlineList.length > 0){
-						for(let i = 0; i < this.offlineList.length ; i++){
-							//匹配离线列表是否有这个用户
-							if(this.offlineList[i].id == redata.data.user_info.id  ){
-								//匹配离线列表是否存会话工单未结束
-								if(this.offlineList[i].conversationId ==  redata.data.conversationId){
-									//工单号未结束的数据处理
-									if(this.sessionType == 2 && i == this.dataIndex){
-										this.data = [];
-										this.data = this.offlineList[i].data;
-									}
-									redata.data.user_info.data = this.offlineList[i].data
-								}else{
-									//工单号已结束数据处理
-									if(this.dataIndex == 0 && this.sessionList.length  == 0){
-										this.sessionName = redata.data.user_info.name;
-										this.data = [];
-									}
-									redata.data.user_info.data = [];
-								}
-								//将离线状态用户删除
-								this.offlineList.splice(i,1);
-								this.$store.dispatch("SET_OFFLINE",this.offlineList);
-								this.get_user_info(this.offlineList);
-								isTrue = false;
-								break;
-							}
+					let _this  = this;
+					let arr =[
+						redata.data,
+						this.offlineList,
+						this.sessionList,
+						this.sessionType,
+						this.dataIndex,
+						this.data,
+						this.sessionName
+					]
+					_this.$public.visitorsConnect(arr,function(data){
+						//离线匹配列表访客链接回调
+						_this.$store.dispatch("SET_OFFLINE",data);
+					},function(data,list,offline,type,num,dataList,name){
+						//新访客链接回调
+						_this.sessionType = type;
+						_this.dataIndex = num;
+						_this.data = [];
+						if( dataList.length >0 ){
+							_this.data = dataList;
 						}
-					}else{
-						this.sessionType = 1;
-						this.sessionName = '';
-						this.data = [];
-					}
-					if(isTrue){
-						if(this.dataIndex == 0 && this.sessionList.length  == 0){
-							this.sessionName = redata.data.user_info.name;
-							this.data = [];
-						}
-						redata.data.user_info.data = [];
-					}
-					redata.data.user_info.intime = this.time[1];
-					redata.data.user_info.num = 0;
-					this.sessionList.push(redata.data.user_info);
-					this.get_user_info(this.sessionList);
-					//将数据储存到vuex里面
-					this.$store.dispatch("SET_SESSION",this.sessionList);
-					// this.$store.getters.getLimit
+						_this.sessionName = name;
+						//将用户添加到会话列表中
+						_this.sessionList.push(data.user_info);
+						//获取接入的用户信息
+						_this.get_user_info(list);
+						//获取接入的用户信息写入vuex
+						_this.$store.dispatch("SET_SESSION",list);
+						_this.$store.dispatch("SET_OFFLINE",offline);
+					})
 				}
+				
 
 				//用户离线后会话窗口切换
 				if(redata.message_type == "userClose"){
-					for(let i = 0 ; i < this.sessionList.length; i++){
-						//匹配会话中离线用户
-						if(this.sessionList[i].id  == redata.data.id ){
-							//把数据添加到离线列表
-							this.offlineList.push(this.sessionList[i]);
-							this.$store.dispatch("SET_OFFLINE",this.offlineList);
-							//用户选中状态会话中处理
-							if(this.sessionType == 1){
-								//判断会话中列表长度
-								if(this.sessionList.length > 1){
-									//删除会话列表离线用户
-									this.sessionList.splice(i,1);
-									this.$store.dispatch("SET_SESSION",this.sessionList);
-									//获取会话中列表第一个会话消息
-									this.dataIndex = 0;
-									this.sessionName = this.sessionList[0].name;
-									this.data = [];
-									this.data = this.sessionList[0].data;
-								}else{
-									this.sessionType = 2;
-									this.dataIndex = 0;
-									// if(this.offlineList.length >0){
-									// }else{}
-									this.sessionName =this.offlineList[0].name;
-									this.data = this.offlineList[0].data;
-									//删除会话列表离线用户
-									this.sessionList.splice(i,1);
-									this.$store.dispatch("SET_SESSION",this.sessionList);
-								}
-							}else{
-								//删除会话列表离线用户
-								this.sessionList.splice(i,1);
-								this.$store.dispatch("SET_SESSION",this.sessionList);
-							}
-							break;
-						}
-					}
-					this.get_user_info(this.sessionList);
+					let _this =this;
+					let	arr= [
+						redata.data,
+						this.sessionList,
+						this.offlineList,
+						this.sessionType,
+						this.dataIndex,
+						this.sessionName,
+						this.data
+					]
+					_this.$public.userOffline(arr,function(session,offline,type,index,name,list,userInfo){
+						_this.sessionList =[];
+						_this.sessionList = session;
+						_this.offlineList = [];
+						_this.offlineList = offline;
+						_this.sessionType = type;
+						_this.dataIndex = index;
+						_this.sessionName = name;
+						_this.data = [];
+						_this.data = list;
+						_this.$store.dispatch("SET_NUM",index);
+						_this.$store.dispatch("SET_TYPE",type);
+						_this.$store.dispatch("SET_SESSION",session);
+						_this.$store.dispatch("SET_OFFLINE",offline);
+						_this.get_user_info(userInfo);
+					})
 				}
 
-				//用户断开链接会话窗口切换
+
+				//用户会话结束窗口切换
 				if(redata.message_type == "delUser"){
-					let isTrue = true;
-					//会话中列表匹配
-					for(let i = 0 ; i < this.sessionList.length; i++){
-						//判断会话中列表是否结束会话
-						if(this.sessionList[i].id ==  redata.data.id){
-							//删除会话列表断线关闭的用户信息
-							this.sessionList.splice(i,1);
-							this.$store.dispatch("SET_SESSION",this.sessionList);
-							if(this.sessionType == 1){
-								//处理会话显现状态
-								if(this.dataIndex == i){
-									if(this.sessionList.length >1){
-										this.sessionName = this.sessionList[0].name;
-										this.data = this.sessionList[0].data;
-										this.get_user_info(this.sessionList);
-									}else{
-										this.sessionName = '';
-										this.data = [];
-										this.get_user_info(this.offlineList);
-									}
-								}
-							}
-							isTrue = false;
-							break;
-						}
-					}
-					//离线列表匹配
-					if(isTrue){
-						for(let i = 0 ; i < this.offlineList.length; i++){
-							//判断离线列表是否结束会话
-							if(this.offlineList[i].id ==  redata.data.id){
-								console.log('离线列');
-								//删除离线列表中断线关闭的用户信息
-								this.offlineList.splice(i,1);
-								this.$store.dispatch("SET_OFFLINE",this.offlineList);
-								if(this.sessionType == 2){
-									if(this.dataIndex == i){
-										console.log('别乱动 大于1','来了吗');
-										if(this.offlineList.length > 1){
-											this.data = this.offlineList[0].data;
-											this.sessionName = this.offlineList[0].name;
-											this.get_user_info(this.offlineList);
-										}else{
-											console.log('别乱动 小于1','来了吗');
-											this.data = [];
-											this.sessionName = '';
-											this.get_user_info(this.sessionList);
-										}
-									}
-								}
-							}
-						}
-					}
+					let _this =this;
+					let	arr= [
+						redata.data,
+						this.sessionList,
+						this.offlineList,
+						this.sessionType,
+						this.dataIndex,
+						this.sessionName,
+						this.data
+					]
+					_this.$public.sessionEnd(arr,function(session,offline,type,index,name,list,userInfo){
+						_this.sessionList =[];
+						_this.sessionList = session;
+						_this.offlineList = [];
+						_this.offlineList = offline;
+						_this.sessionType = type;
+						_this.dataIndex = index;
+						_this.sessionName = name;
+						_this.data = [];
+						_this.$store.dispatch("SET_NUM",index);
+						_this.$store.dispatch("SET_TYPE",type);
+						_this.$store.dispatch("SET_SESSION",session);
+						_this.$store.dispatch("SET_OFFLINE",offline);
+						_this.get_user_info(userInfo);
+					})
 				}
 
 				//接收用户消息数据
 				if(redata.message_type == "chatMessage"){
-					let dataIndex = 0;
-					//匹配是那个用户回的消息
-					for(let i = 0 ; i < this.sessionList.length ; i++){
-						if(this.sessionList[i].id == redata.data.id ){
-							dataIndex = i;
-							break;
+					let _this =this;
+					this.$public.receivesMessage(redata.data,this.sessionList,this.$frce,
+					function(data,chatList,dataIndex){
+
+						//判断是否是当前对话信息
+						if(dataIndex == _this.dataIndex){
+						    _this.data =[];
+						    _this.data = chatList.data;
+						}else{
+						    let num = Number.isInteger(chatList.num) ? chatList.num : 0;
+						    _this.$set(chatList,'num',num+1)
 						}
-					}
-					//获取当前回复消息对象
-					let chatList = this.sessionList[dataIndex]
-					redata.data.type = 'user';
-					redata.data.content = JSON.parse(redata.data.content);
-					//这个地方转
-
-					redata.data.content.text = this.turnFace(redata.data.content.text);
-					//更新会话时间
-					this.$set(chatList,'intime',redata.data.time);
-
-					//更新会话列表中最新回复消息
-					if(redata.data.content.text){
-						this.$set(chatList,'text',redata.data.content.text)
-					}
-
-					//将消息添加对应的会话列表中
-					chatList.data.push(redata.data);
-					//判断是否是当前对话信息
-					if(dataIndex == this.dataIndex){
-						this.data =[];
-						this.data = chatList.data;
-					}else{
-						let num = chatList.num;
-						//console.log(chatList.num);
-						this.$set(chatList,'num',num+1)
-					}
+						//更新会话时间
+						_this.$set(chatList,'intime',data.time);
+				
+						//更新会话列表中最新回复消息
+						if(data.content.text){
+							_this.$set(chatList,'text',data.content.text)
+						}
+					})
 				}
 
 				//接收系统操作信息状态在线客服列表
@@ -505,7 +432,7 @@
 					this.transferList = this.transferList.concat(redata.data);
 				}
 
-				//
+				//接收会话时间
 				if(redata.message_type == "webTime"){
 					// this.webTime = redata.data.webTime
 					this.$set(this.data[this.session_marked],'time',redata.data.webTime);
@@ -520,6 +447,7 @@
 					});
 					if(this.sessionList.length >1 ){
 						this.dataIndex =0;
+						this.$store.dispatch("SET_NUM",0);
 						// this.data = []
 
 					}else{
@@ -536,23 +464,7 @@
 				}
 				this.automaticRolling();
 			},
-			/******************文字信息转表情******************/
-			turnFace(data){
-				let str = data.match(/\#\[.*?\]\//g);
-				let arr =Array.from(new Set(str));
-				arr.forEach(e=>{
-					let imgsrc = '';
-					for(let i = 0 ; i < this.$frce.length ; i++){
-						let expText = e.slice(1,e.length-1);
-						if(expText == this.$frce[i]){
-							imgsrc = '<img class="hover" src="'+require(`@/assets/img/${i}.gif`)+'"/>'
-							break;
-						}
-					}
-					data = data.replace(new RegExp(`\\#\\[${e.substring(2,e.length-2)}\\]\\/`,'g'),imgsrc);
-				})
-				return data;
-			},
+
 
 			/*********************图片发送*********************/
 			uploadIMG(e) {
@@ -657,7 +569,9 @@
 			chooseDialogue(type,index){
 				let data =[];
 				this.sessionType = type;
+				this.$store.dispatch("SET_TYPE",type);
 				this.dataIndex = index;
+				this.$store.dispatch("SET_NUM",index);
 				if(type == 1){
 					data = this.sessionList[index].data;
 					this.session_user_info = this.sessionList[index];
@@ -768,13 +682,13 @@
 				}
 				let chatList = this.sessionList[this.dataIndex];
 				//检测发送信息是否含有敏感词
-				let  sensitive_data= this.$public.shieldingKeyword(this.turnFace(this.inputValue),this.sensitive);
+				let  sensitive_data= this.$public.shieldingKeyword(this.$public.turnFace(this.inputValue,this.$frce),this.sensitive);
 
 				//有敏感词提示并且禁止发送
 				if(sensitive_data.num == 0 ){
 					// 本地储存
 					chatList.data.push({type:'service', content:{
-							text:this.turnFace(this.inputValue),
+							text:this.$public.turnFace(this.inputValue,this.$frce),
 							img:'',
 							type:false,
 						} ,time:this.time[1]});
@@ -859,10 +773,12 @@
 			get_user_info(type){
 				if(type.length > 0 ){
 					this. session_user_info  = {};
-					this.session_user_info = type[this.dataIndex];
+					if(this.dataIndex !=100){
+						this.session_user_info = type[this.dataIndex];
+					}
 					// console.log(this.session_user_info);
 				}else{
-					this.session_user_info = '';
+					this.session_user_info = {};
 				}
 			},
 
@@ -890,7 +806,7 @@
 				})
 			},
 
-			/**************获取敏感词**************** */
+			/**************获取敏感词*****************/
 			getSensitive() {
 				let obj = {
 					headers: {
@@ -903,6 +819,9 @@
 						res.data.data.serverSensitive.forEach(res => {
 							this.sensitive.push(res.sensitivewords_word)
 						})
+						res.data.data.userSensitive.forEach(res => {
+							this.userSensitiveWords.push(res.sensitivewords_word)
+						})
 					}
 				})
 			},
@@ -918,6 +837,8 @@
 			this.offlineList = getters.get_offline ? getters.get_offline :[] ;
 			this.token =getters.get_user_info.token ;
 			this.user_info = getters.get_user_info;
+			this.dataIndex =100; //getters.get_num;
+			this.sessionType = getters.get_type;
 			this.time =JSON.parse(sessionStorage.getItem("time"));
 			let _this = this;
 			this.get_config_info();

+ 10 - 0
service/src/store/index.js

@@ -11,6 +11,7 @@ const state = {
 	user_info: '', //用户信息
 	sessionList: [],//会话列表
 	offlineList: [],//离线列表
+	current_session:{},//当前会话详情信息
 	sessionType: 1,//选择列表状态默认未1(1是会话中,2是离线)
 	data_num: 0,//定位当前会话,默认是0
 	navState: 'TheCurrentSession',//导航状态
@@ -33,6 +34,9 @@ const getters = {
 	get_offline(state) {
 		return state.offlineList;
 	},
+	get_current(state) {
+		return state.current_session;
+	},
 	get_type(state) {
 		return state.sessionType;
 	},
@@ -69,6 +73,9 @@ const mutations = {
 	new_offline(state, val) {
 		state.offlineList = val;
 	},
+	new_current(state, val) {
+		state.current_session = val;
+	},
 	new_type(state, val) {
 		state.sessionType = val;
 	},
@@ -105,6 +112,9 @@ const actions = {
 	SET_OFFLINE(context, val) {
 		context.commit('new_offline', val);
 	},
+	SET_CURRENT(context, val) {
+		context.commit('new_current', val);
+	},
 	SET_TYPE(context, val) {
 		context.commit('new_type', val);
 	},

+ 297 - 0
service/static/publicMethods.js

@@ -128,4 +128,301 @@ export default {
             num
         }
     },
+
+    /*****************用户屏蔽关键字******************/
+    /**
+     * 
+     * @param {*} data 
+     * @param {*} sensitive 
+     * @param {*} 
+     */
+    userShieldingKeyword(data,sensitive) {
+        //将敏感词组用|转换字符串
+        let snstive = sensitive.join('|');
+        let num = 0,text='';
+        //匹配出会话中的敏感词
+        return data.replace(eval('/' + snstive + '/g'), (res) => {
+            var str = '';
+            for (var i = 0; i < res.length; i++) {
+                str += '*';
+            }
+            return str;
+        })
+    },
+
+
+    /******************访客接入*********************/
+   /**
+    * 
+    * @param {object} redata  接收消息源
+    * @param {Array} offlineList  访客离线列表
+    * @param {Array} sessionList  访客会话列表
+    * @param {int} sessionType 选择列表状态默认未1(1是会话中,2是离线)
+    * @param {int} dataIndex  定位当前会话,默认是0
+    * @param {Array} dataList 当前会话信息列表
+    * @param {string} user_name 当前会话访客名
+    * @param {function} callback   访客匹配离线列表处理后链接回调方法
+    * @param {function} callback1   访客正常链接回调方法
+    */
+   visitorsConnect([redata,offlineList,sessionList,sessionType,dataIndex,dataList,user_name],callback,callback1){
+        //将会话工单写入访客信息
+        redata.user_info.conversationId = redata.conversationId;
+        //默认离线列表没有访客信息
+        let isTrue = true;
+
+        //匹配是否是离线用户上线
+        if(offlineList.length > 0){
+            for(let i = 0; i < offlineList.length; i++){
+                //匹配离线列表是否有这个用户
+                if(offlineList[i].id == redata.user_info.id  ){
+                    //查询离线列表是否有此用户会话工单未结束
+                    if(offlineList[i].conversationId  ==  redata.conversationId){
+                        //工单号未结束的数据获取历史聊天消息和对象名字
+                        if(sessionType == 2 && i == dataIndex){//客服选中离线重新链接访客
+                            dataList = [];
+                            dataList = offlineList[i].data;
+                            user_name  = offlineList[i].name;
+                            sessionType = 1;
+                            dataIndex = sessionList.length == 0 ? 0 : sessionList.length-1;
+                        }else if(sessionType == 2 && i < dataIndex){//客服选中离线列表重新链接访客后面的访客
+                            if(i > 0){
+                                dataList = offlineList[i].data;
+                                user_name  = offlineList[i].name;
+                            }
+                        }
+                        //将掉线前聊天消息写入到用户对象里面
+                        redata.user_info.data = offlineList[i].data;
+                    }else{
+                        //工单号已结束数据处理
+                        if(dataIndex == 0 && sessionList.length  == 0){
+                            user_name = redata.user_info.name;
+                            dataList = [];
+                        }
+                        redata.user_info.data = [];
+                    }
+                    //将离线状态用户删除
+                    offlineList.splice(i,1);
+
+                    //回调
+                    callback && callback(offlineList);
+                    isTrue = false;
+                    break;
+                }
+            }
+        }
+
+        //新访客链接
+        if(isTrue){
+            if(sessionList.length  == 0){
+                //判断是否选离线用户列表
+                if(offlineList.length > 0 && sessionType ==2){
+                //不做处理
+                }else{
+                    dataIndex = 0
+                    sessionType = 1
+                    user_name = redata.user_info.name;
+                    dataList = [];
+                }
+            }else{
+                for(let i = 0; i < sessionList.length; i++){
+                    //匹配离线列表是否有这个用户
+                    if(sessionList[i].id == redata.user_info.id  ){
+                        sessionList.splice(i,1);
+                        break;
+                    }
+                }
+            }
+            redata.user_info.data = [];
+        }
+        //回调
+        callback1 && callback1(redata,sessionList,offlineList,sessionType,dataIndex,dataList,user_name);
+    },
+
+    /*****************用户会话离线及相关数据*********************/
+    /**
+     * @param {object} redata  接收消息源
+     * @param {Array} sessionList  访客会话列表
+     * @param {Array} offlineList  访客离线列表
+     * @param {int} sessionType 选择列表状态默认未1(1是会话中,2是离线)
+     * @param {int} dataIndex  定位当前会话,默认是0
+     * @param {string} user_name 当前会话访客名
+     * @param {Array} dataList 当前会话信息列表
+     * @param {*} callback  回调函数
+     */
+    userOffline([redata,sessionList,offlineList,sessionType,dataIndex,user_name,dataList],callback){
+        let userInfo = [];
+        for(let i = 0 ; i < sessionList.length; i++){
+            //匹配会话中离线用户
+            if(sessionList[i].id  == redata.id ){
+                //把数据添加到离线列表
+                offlineList.push(sessionList[i]);
+                //用户选中状态会话中处理
+                if(sessionType == 1){
+                    //判断会话中列表长度
+                    if(sessionList.length > 1){
+                        //判断是否离线用户是当前选中状态
+                        if( dataIndex == i){
+                            dataIndex = 0;
+                            user_name = sessionList[0].name;
+                            dataList = sessionList[0].data;
+                            userInfo = sessionList;
+                        }
+                        //删除会话列表离线用户
+                        sessionList.splice(i,1);
+                    }else{
+                        sessionType = 2;
+                        dataIndex = 0;
+                        user_name =offlineList[0].name;
+                        dataList = offlineList[0].data;
+                        userInfo = offlineList ;
+                        sessionList.splice(i,1);
+                    }
+                }
+                callback && callback(sessionList,offlineList,sessionType,dataIndex,user_name,dataList,userInfo);     
+                break;
+            }
+        }
+    },
+
+    /**************删除会话中离线用户及相关数据**************/
+    /**
+     * @param {object} redata  接收消息源
+     * @param {Array} sessionList  访客会话列表
+     * @param {Array} offlineList  访客离线列表
+     * @param {int} sessionType 选择列表状态默认未1(1是会话中,2是离线)
+     * @param {int} dataIndex  定位当前会话,默认是0
+     * @param {string} user_name 当前会话访客名
+     * @param {Array} dataList 当前会话信息列表
+     * @param {*} callback  回调函数
+     */
+
+    sessionEnd([redata,sessionList,offlineList,sessionType,dataIndex,user_name,dataList],callback){
+        let isTrue = true;
+        let userInfo = [];
+        //会话中列表匹配
+        if(sessionList.length > 0){
+            for(let i = 0 ; i < sessionList.length; i++){
+                //检测会话列表中是否有结束的会话对象
+                if(sessionList[i].id  ==  redata.id){
+                    //删除会话列表中结束的会话对象用户信息
+                    sessionList.splice(i,1);
+                    // this.$store.dispatch("SET_SESSION",sessionList);
+                    if(sessionType == 1){
+                        if(sessionList.length >1){
+                            //处理会话显现状态
+                            if(dataIndex == i){
+                                user_name = sessionList[0].name;
+                                dataList = sessionList[0].data;
+                                userInfo = sessionList;
+                            }
+                        }else{
+                            if(offlineList.length > 0 ){
+                                sessionType = 2;
+                                dataIndex = 0;
+                                userInfo = offlineList;
+                            }else{
+                                user_name = '';
+                                dataList = [];
+                                userInfo = '';
+                            }
+                        }
+                    }
+                    isTrue = false;
+                    break;
+                }
+            }
+        }
+        //离线列表查询
+        if(isTrue){
+            for(let i = 0 ; i < offlineList.length; i++){
+                //判断离线列表是否结束会话
+                if(offlineList[i].id ==  redata.id){
+                    //删除离线列表中结束会话的用户信息
+                    offlineList.splice(i,1);
+                    // this.$store.dispatch("SET_OFFLINE",offlineList);
+                    if(sessionType == 2){
+                        if(dataIndex == i){
+                            if(offlineList.length > 1){
+                                if(sessionList.length >0){
+                                    dataList = sessionList[0].data;
+                                    user_name = sessionList[0].name;
+                                    userInfo = sessionList;
+                                }else{
+                                    dataList = offlineList[0].data;
+                                    user_name = offlineList[0].name;
+                                    userInfo = offlineList;
+                                }
+                            }else{
+                                if(sessionList.length >0){
+                                    dataList = sessionList[0].data;
+                                    user_name = sessionList[0].name;
+                                    userInfo = sessionList;
+                                }else{
+                                    dataList = [];
+                                    user_name = '';
+                                    userInfo = '';
+                                }
+                            }
+                        }
+                    }
+                    break;
+                }
+            }
+        }
+        //回调
+        callback && callback(sessionList,offlineList,sessionType,dataIndex,user_name,dataList,userInfo);
+        
+    },
+
+
+    /*****************接收用户会话消息***************/
+    /**
+     * 
+     * @param {*} redata 数据源
+     * @param {*} sessionList 会话列表
+     * @param {*} frce 表情数据源
+     * @param {*} callback  回调
+     */
+    receivesMessage(redata,sessionList,frce,callback){
+        let dataIndex = 0;
+        //匹配是那个用户回的消息
+        for(let i = 0 ; i < sessionList.length ; i++){
+            if(sessionList[i].id == redata.id ){
+                dataIndex = i;
+                break;
+            }
+        }
+        
+        //获取当前回复消息对象
+        let chatList = sessionList[dataIndex]
+        redata.type = 'user';
+        redata.content = JSON.parse(redata.content);
+        //这个地方转
+        redata.content.text = this.turnFace(redata.content.text,frce);
+        //将消息添加对应的会话列表中
+        chatList.data.push(redata);
+        callback && callback(redata,chatList,dataIndex);
+    },
+
+    /******************文字信息转表情******************/
+    /**
+     * @param {*} data 
+     * @param {*} frce 
+     */
+    turnFace(data,frce){
+        let str = data.match(/\#\[.*?\]\//g);
+        let arr =Array.from(new Set(str));
+        arr.forEach(e=>{
+            let imgsrc = '';
+            for(let i = 0 ; i < frce.length ; i++){
+                let expText = e.slice(1,e.length-1);
+                if(expText == frce[i]){
+                    imgsrc = '<img class="hover" src="'+require(`@/assets/img/${i}.gif`)+'"/>'
+                    break;
+                }
+            }
+            data = data.replace(new RegExp(`\\#\\[${e.substring(2,e.length-2)}\\]\\/`,'g'),imgsrc);
+        })
+        return data;
+    },
 }