|
|
@@ -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();
|