Harley 6 年之前
父節點
當前提交
664de334fb

+ 5 - 11
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",
@@ -1927,7 +1926,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"
       }
@@ -3277,8 +3275,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="
     },
     "delegate": {
       "version": "3.2.0",
@@ -3959,8 +3956,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",
@@ -5201,8 +5197,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",
@@ -10470,8 +10465,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",

+ 3 - 6
service/src/App.vue

@@ -114,10 +114,10 @@
 						this.$store.dispatch("SET_SESSSION_USER", redata.data.user_info);
 					}
 				}
-				this.getVisitorList();
+				// this.getVisitorList();
 				console.log(redata);
 				let getters = this.$store.getters;
-				console.log({'getters':this.$store})
+				// console.log({'getters':this.$store})
 				//获取vuex数据
 				let session = getters.get_session;//会话列表
 				let offline  = getters.get_offline;//离线列表
@@ -218,8 +218,6 @@
 						current_session,
 					]
 					_this.$public.sessionEnd(arr,function(session,offline,type,index,name,list,userInfo){
-						console.log('session',session);
-						console.log('offline',offline);
 						_this.$store.dispatch("SET_CURRENT",list);//当前会话数据
 						_this.$store.dispatch("SET_SESSION_NAME",name);//当前会话对象名
 						_this.$store.dispatch("SET_NUM",index);
@@ -357,12 +355,11 @@
 		destroyed() {
 			this.lockReconnect = true;
 			this.$websocket.close();
-			// this.websock.close()                   //离开路由之后断开websocket连接
+			// this.websock.close()                //离开路由之后断开websocket连接
 			clearTimeout(this.reconnectData);      //离开清除 timeout
 			clearTimeout(this.timeoutObj);         //离开清除 timeout
 			clearTimeout(this.serverTimeoutObj);   //离开清除 timeout
 			localStorage.removeItem('user');
-			// console.log(123) 
 		}
 	}
 </script>

+ 28 - 10
service/src/components/hader.vue

@@ -146,7 +146,7 @@
 <script>
 	import Vue from 'vue';
 	import '@/css/index.css'
-
+	import { Loading } from 'element-ui';
 	export default {
 		name: 'hader',
 		data() {
@@ -182,6 +182,7 @@
 				dialogImageUrl: '', // 放大的图片
 
 				serverList:[],
+				get_num:'',
 			}
 		},
 
@@ -194,15 +195,19 @@
 			}else if(this.$store.getters.get_user_info!= ""){
 				this.user_info = JSON.parse(this.$store.getters.get_user_info)
 			}
-			this.userID = this.$store.getters.get_user_info.id;
+			this.userID = this.user_info.id;
+			// console.log(this.userID);
 			this.unreadnotice();
 			let _this = this;
-			let get = setTimeout(function(){
+			this.get_num = setInterval(function(){
 				_this.unreadnotice();
-			},1000)
+			},5000)
 
 
 
+		},
+		beforeDestroy() {
+			clearInterval(this.get_num);
 		},
 
 		computed: {
@@ -257,10 +262,13 @@
 				this.$store.dispatch("SET_SESSION_MESSAGE",{});
 				this.$store.dispatch("SET_SOCKET_OPEN",false);//列表下标 
 				this.$store.dispatch("SET_NAVSTATE", 'TheCurrentSession'); 
+				this.websocketsend(JSON.stringify({
+					type:'kfzdclose',
+					data: {
+						uid: 'KF' + this.user_info.id,
+					}
+				}));
 				this.$websocket.close();
-				// this.$socket_open = false;
-				
-				// console.log(this.$socket_open)
 				this.$token = '';
 				this.$router.push({path:'/login',query: { pid:escape("这就是一个编码没有什么用啊") }})
 			},
@@ -286,7 +294,7 @@
 				},obj).then(res => {
 					if(res.data.code === 1){
 						// console.log(res.data.data)
-						 this.unreadNum =  res.data.data.length;
+						this.unreadNum =  res.data.data.length;
 					}
 				});
 			},
@@ -301,7 +309,8 @@
 					this.init();
 					this.get_session_lise();
 					this.ession_int = setInterval(()=>{
-						this.get_session_lise(this.newTime);
+						Loading.service({text:'拼命加载中',background:'rgba(0, 0, 0, 0.8)'});
+						this.get_session_lise(this.newTime,10000);
 					},1000*5)
 				}
 			},
@@ -318,6 +327,11 @@
 
 			/*************获取会话总览数据************/
 			getInnerDrawer(){
+				// setTimeout(()=>{})
+				// Loading.service({text:'拼命加载中',background:'rgba(0, 0, 0, 0.8)'});
+				setTimeout(()=>{
+					Loading.service({text:'拼命加载中',background:'rgba(0, 0, 0, 0.8)'});
+				},200)
 				if(this.innerDrawer) return false;
 				this.innerDrawer = true;
 				let obj = {
@@ -352,12 +366,13 @@
 								}
 							});
 						},1000*60);
+						Loading.service().close()
 					}
 				});
 			},
 
 			/******************会话详情列表******************/
-			get_session_lise(time){
+			get_session_lise(time,type){
 				// if() return false
 				let str ="chatbytime" + "customer-service" + "history" + "service";
 				this.$http.get(this.$ports.overview.chatByTime,{
@@ -393,6 +408,9 @@
 							e.content.text = this.$public.turnFace(e.content.text,this.$frce);
 							this.dataList.push(e)
 						});
+						if( type ==10000){
+							Loading.service().close()
+						}
 					}
 				});
 			},

+ 3 - 0
service/src/components/historicalRecord.vue

@@ -119,6 +119,7 @@
 </template>
 <script>
 import '@/css/index.css';
+import { Loading } from 'element-ui';
 export default {
     props:['show','uid','user_name'],
     name:'historicalRecord',
@@ -164,6 +165,7 @@ export default {
         /*****************************************/
         //获取会话详情列表
         getRecordList(page,size = 10){
+            Loading.service({text:'拼命加载中',background:'rgba(0, 0, 0, 0.8)'});
             let str ="historyinfo" + "customer-service" + "history" + "service";
             
             this.$http.get(this.$ports.history.historyInfo,{
@@ -191,6 +193,7 @@ export default {
                         e.content.text = this.turnFace(e.content.text);
                         this.dataList.push(e)
                     });
+                    Loading.service().close()
                 }
             });
         },

+ 1 - 1
service/src/components/leftNav.vue

@@ -14,7 +14,7 @@
 				>
 					<img style="margin-right:10px;" :src="titleActive == item.type?item.imgsrcA:item.imgsrc"/>
 					{{item.title}}
-					<el-badge :value="megnum" class="item" v-if="index == 0 && showMeg">
+					<el-badge :value="megnum" class="item" v-if="index == 0 && titleActive != 'TheCurrentSession'">
 						<i style="font-size:14px; color:#5399F5;   margin-left: 10px;"
 						   class="el-icon-chat-dot-square"> </i>
 					</el-badge>

+ 36 - 23
service/src/components/messageCenter.vue

@@ -75,16 +75,13 @@
 </template>
 
 <script>
-
+	import { Loading } from 'element-ui';
 	export default {
 		name: "messageCenter",
 		data() {
 			return {
 				drawer: false,
 				switchMessageType: "unread",
-
-				nomessage:true,
-
 				userID:null,
 				userName:null,
 				//已读列表
@@ -94,11 +91,13 @@
 				//未读第一个
 				unreadListOne:{},
 				//未读数量
-				unreadNum:null,
+				unreadNum:0,
+				readNum:0,//读取数量
 				// 详情
 				messageBox:{},
 				//标记代码
 				markupCode:0,
+				loading: false,
 
 			}
 		},
@@ -110,16 +109,22 @@
 		},
 		watch: {
 			get_drawer(data) {
-				// console.log('22',data)
 				this.drawer = data;
-				this.userID =  JSON.parse(localStorage.getItem('user')).id;
-				this.userName =  JSON.parse(localStorage.getItem('user')).user_name;
 				if(data){
-					this.readnotice();
-					this.unreadnotice();
+					setTimeout(()=>{
+						Loading.service({text:'拼命加载中',background:'rgba(0, 0, 0, 0.8)'});
+						this.unreadnotice();
+					},500)
 				}
 			},
 		},
+		/**
+		 * 挂载前执行
+		 */
+		mounted(){
+			this.userID =  JSON.parse(localStorage.getItem('user')).id;
+			this.userName =  JSON.parse(localStorage.getItem('user')).user_name;
+		},
 		methods: {
 			handleClose() {
 				this.$store.dispatch("SET_DRAWER", false);
@@ -127,6 +132,7 @@
 			switchMessage(num) {
 				this.switchMessageType = num;
 				this.markupCode = 0 ;
+				Loading.service({text:'拼命加载中',background:'rgba(0, 0, 0, 0.8)'});
 				if(this.switchMessageType == 'unread'){
 					this.unreadnotice();
 				}else if(this.switchMessageType=='read'){
@@ -135,6 +141,7 @@
 			},
 			// 已读信息
 			readnotice(){
+			
 				let str = "readnotice" + "customer-service" + "index" + this.time + "service";
 				let obj = {
 					headers: {
@@ -146,12 +153,13 @@
 				this.$http.post(this.$ports.center.readnotice,{
 					user_id: this.userID
 				},obj).then(res => {
-					// console.log(res)
 					if(res.data.code === 1){
-						console.log("已读",res.data.data)
 						this.readList =  res.data.data;
 						if(res.data.data.length > 0){
 							this.messageBox = res.data.data[0];
+							Loading.service().close()
+						}else{
+							this.unreadListOne = {}
 						}
 					}
 				});
@@ -171,14 +179,16 @@
 				},obj).then(res => {
 					// console.log(res)
 					if(res.data.code === 1){
-						console.log("未读",res.data.data)
+						// console.log("未读",res.data.data);
 						this.unreadList = res.data.data;
-						// console.log(this.unreadListOne,'第一个')
-						this.unreadNum =res.data.data.length >0 ? res.data.data.length-1 : 0;
+
+						this.unreadNum = this.unreadList.length;
 						if(res.data.data.length > 0){
 							this.unreadListOne = res.data.data[0];
-							this.readInfo(res.data.data[0].id)
+							this.readInfo(res.data.data[0].id);
+							// this.loading = false;
 						}
+						Loading.service().close()
 
 					}
 				});
@@ -186,7 +196,6 @@
 
 			//读取信息
 			readInfo(id){
-				//this.messageBox.id
 				let str = "updatenotice" + "customer-service" + "index" + this.time + "service";
 				let obj = {
 					headers: {
@@ -200,7 +209,8 @@
 				},obj).then(res => {
 					// console.log(res)
 					if(res.data.code === 1){
-						console.log("已读",res.data.data)
+						if(this.unreadNum == 0) return
+						this.unreadNum --;
 					}
 				})
 			},
@@ -208,13 +218,13 @@
 
 			// 点击显示当前详细内容
 			toReading(item,index){
-				// console.log(item,index);
 				if( this.markupCode == index) return
 				this.markupCode = index;
-				this.nomessage = false;
-				this.messageBox = item;
 				if(this.switchMessageType == 'unread'){
-					this.readInfo(item.id)
+					this.unreadListOne = item;
+					this.readInfo(this.unreadList[index].id)
+				}else{
+					this.messageBox = item;
 				}
 			}
 		},
@@ -248,6 +258,8 @@
 
 	.message-list {
 		margin: 0;
+		overflow-y:scroll;
+		height: 80vh;
 		// /* 奇数背景色 */
 		// .list-item:nth-of-type(odd) {
 		// 	background: #F6F8FF;
@@ -264,7 +276,7 @@
 
 			p {
 				color: #666;
-				font-size: 14px;
+				font-size: 12px;
 				overflow: hidden;
 				text-overflow:ellipsis;
 				white-space: nowrap;
@@ -278,6 +290,7 @@
 
 			span {
 				font-size: 14px;
+				font-weight: bold;
 				color: #666;
 			}
 

+ 3 - 1
service/src/pages/FastReply.vue

@@ -199,7 +199,7 @@
 	import leftNav from "@/components/leftNav";
 	import hader from "@/components/hader";
 	import messageCenter from "@/components/messageCenter";
-
+	import { Loading } from 'element-ui';
 	export default {
 		name: "FastReply",
 		data() {
@@ -323,6 +323,7 @@
 
 			/**************查询快捷回复语列表***************/
 			getFastReply() {
+				Loading.service({text:'拼命加载中',background:'rgba(0, 0, 0, 0.8)'});
 				let obj = {
 					headers: {
 						apiToken: this.$md5("userwords" + "customer-service" + "index" + "service"),
@@ -334,6 +335,7 @@
 					if (res.data.code == 1) {
 						//私有库
 						this.ReplyArr = res.data.data.userWords; // res.data.data.sysWords
+						Loading.service().close();
 					}
 				});
 			},

+ 80 - 28
service/src/pages/TheCurrentSession.vue

@@ -93,12 +93,11 @@
 							</p>
 						</div>
 					</div>
-
+					<div class="history-info">
+						<el-button type="text" size="small" :loading="historyLoading" 
+						@click="getHistoryInfo">{{historyProcess}}</el-button>
+					</div>
 					<div class="chat-box scroll" id='chat_box'>
-						<div class="history-info">
-							<el-button type="text" size="small" :loading="historyLoading" 
-							@click="getHistoryInfo">{{historyProcess}}</el-button>
-						</div>
 						<div v-for="(item,index) in data" :key="index">
 							<!-- 系统转接 -->
 							<!-- <div class="row center" v-if="item.type == 'system'">
@@ -522,13 +521,14 @@
 						this.showHistoryList = true;
 						redata.data.history.forEach(res => {
 							let content = JSON.parse(res.content)
-							res.content = content;
+							// res.content = content;
 							if (content.text) {
 								content.text = this.$public.turnFace(content.text,this.$frce)
-								res.content = content
 							}
+							res.content = content
 							this.historyList.push(res)
 						})
+						this.automaticRolling();
 					}
 				}
 			},
@@ -656,13 +656,15 @@
 			},
 			getPlatformCN(name){
 				let platforms={'android':'安卓','ios':'苹果','pc':'电脑'};
-				
 				return platforms[name];
 			},
 
 			/*****************切换用户会话对象******************/
-			chooseDialogue(type, index) {
-				this.inputValue = '' // 清除会话内容
+			chooseDialogue(type,index,system) {
+				if(!system){
+					this.inputValue = '' // 清除会话内容
+				}
+				console.log(type, index);
 				if (this.userSwitching) {
 					let data = [];
 					let order_id = '';
@@ -763,21 +765,31 @@
 				send.play()
 			},
 
+			//判断是否选中访客
+			visitor_info(){
+				if(this.sessionType == 1 && this.sessionList.length <= 0 ){
+					return  '-1';
+				}else if(this.sessionType == 2 && this.offlineList <= 0 ){
+					return ' -1';
+				}
+				//this.sessionList.length >0 && this.sessionType == 1
+			},
+			
 			/*********************发送消息*********************/
 			sendMessage() {
-				console.log('websocket',this.$websocket.readyState)
-				console.log('sessionType', this.sessionType)
-				if(this.sessionType == 1) {
-					console.log("???")
-				}
-				console.log(this.inputValue);
-				if (!this.inputValue) return;
+				if (!this.inputValue ) return;
 				if (this.sessionType == 2) {
 					this.$message({
 						message: '只能给在线用户发送消息哦...',
 						type: 'warning'
 					});
 					return false;
+				}else if(this.sessionType == 1 && this.sessionList.length <= 0){
+					this.$message({
+						message: '只能给在线用户发送消息哦...',
+						type: 'warning'
+					});
+					return false;
 				}
 				// if(this.offlineList.length <= 0 ) return
 				let isFirst = true, sensitiveNumber = 0;
@@ -906,6 +918,7 @@
 
 			/*****************获取当前聊天用户信息****************/
 			get_user(id,type,index) {
+				// console.log(id,type,index)
 				let obj = {
 					account_id: id
 				};
@@ -925,6 +938,7 @@
 								this.sessionList[index].name = this.session_user_info.nick_name;
 							}
 							this.$store.dispatch("SET_SESSION",this.sessionList);
+				
 							this.$store.dispatch("SET_SESSION_NAME",this.sessionList[index].name);
 						}else if(type == 2){
 							if(this.session_user_info.nick_name){
@@ -962,6 +976,15 @@
 				})
 			},
 
+			/*****************************/
+			automaticScrollTop(){
+				this.$nextTick(() => {
+					let msg = document.getElementById('chat_box') // 获取对象
+					console.log(msg.scrollHeight);
+					msg.scrollTop = '0px'
+				})
+			},
+
 			/**************获取敏感词*****************/
 			getSensitive() {
 				let obj = {
@@ -1138,9 +1161,9 @@
 			/****************访问信息和评价状态***************/
 			accessTerminal(data) {
 				if (this.sessionType == 1) {
-					console.log('dataIndex', this.dataIndex)
+					// console.log('dataIndex', this.dataIndex)
 					let List = this.sessionList[this.dataIndex];
-					console.log('list', List)
+					// console.log('list', List)
 					if (data == 'eva') {
 						if (!List) return false
 						// console.log(List,'对话信息');
@@ -1164,8 +1187,12 @@
 								source:List.ipinfo
 
 							}
+							if(this.sessionList.length == 1 &&  this.dataIndex ==0){
+								this.get_user(List.id,1,this.dataIndex);
+							}
 						} else {
 							this.terminal_IP = {}
+
 						}
 					}
 				} else if (this.sessionType == 2) {
@@ -1182,7 +1209,25 @@
 					// }
 				}
 			},
-			getHistoryInfo() { // 获取历史数据
+			/****************** 获取历史数据 *******************/
+			getHistoryInfo() { // 
+				let visitors_id = '';
+				let conversationId = '';
+				if(this.sessionType == 1){
+					visitors_id = this.sessionList[this.dataIndex] ? this.sessionList[this.dataIndex].id: '';
+					conversationId =this.sessionList[this.dataIndex] ? this.sessionList[this.dataIndex].conversationId : '';
+				}else if(this.sessionType == 2){
+					visitors_id = this.offlineList[this.dataIndex] ? this.offlineList[this.dataIndex].id :'';
+					conversationId = this.offlineList[this.dataIndex] ? this.offlineList[this.dataIndex].conversationId : '';
+				}
+				if(visitors_id == ''){
+					this.$message({
+						message:'没有对应的访客',
+						type: 'warning'
+					});
+					return false;
+				}
+
 				let obj = {
 					headers: {
 						apiToken: this.$md5("userhistory" + "customer-service" + "history" + "service"),
@@ -1190,8 +1235,9 @@
 						userToken: this.token
 					},
 					params: {
-						// user_name: this.user_info.account_name,
+						account_user_id: visitors_id,
 						account_id: 'KF' + this.user_info.id,
+						conversationId,
 						currentPage: this.historyPage,
 						pageSize: 10
 					}
@@ -1212,12 +1258,18 @@
 								let list = res.data.data.list
 								if(list) {
 									for(let item of list) {
+										let content =  JSON.parse(item.content)
+										if (content.text) {
+											content.text = this.$public.turnFace(content.text,this.$frce)
+										}
 										let historyItem = {
 											type: item.from_id.substr(0, 2) === 'KF' ? 'service' : 'user',
 											time: this.$public.customFormatDateTime(item.time_line),
-											content: JSON.parse(item.content)
+											content: content
+											
 										}
-										this.data.unshift(historyItem)
+										this.data.unshift(historyItem);
+										this.automaticScrollTop()
 									}
 									this.historyPage ++ ;
 									this.historyProcess = '更多历史记录'
@@ -1284,11 +1336,13 @@
 			// },
 			sessionList: {
 				handler(val) {
+					console.log(val,'事件监听sessionList');
 					this.accessTerminal(val)
 				},
 				deep: true
 			},
 			offlineList(e) {
+				console.log(e,'事件监听offlineList')
 				this.accessTerminal(e)
 			},
 
@@ -1309,7 +1363,7 @@
 				dataIndex: 'get_num',
 				sessionType: 'get_type',
 				get_user_info: 'get_session_user', // 会话人详细信息
-				// is_eva_btn:'get_is_eva_btn',
+		
 			}),
 
 			get_session_message() {
@@ -1455,9 +1509,7 @@
 	}
 
 	.chat-box {
-		height: 62vh;
-		/* background: red; */
-		/* padding: 40px 0; */
+		height: 56vh;
 		padding-bottom: 10px;
 		border-bottom: 1px solid #d5e5ff;
 		overflow-x: hidden;
@@ -1574,7 +1626,7 @@
 
 	.FastReplyBox {
 		padding: 0.4rem 0;
-		height: 80vh;
+		height: 75vh;
 		overflow-x: hidden;
 		overflow-y: auto;
 	}