Parcourir la source

Merge branch 'master' of http://git.bocai108.com:10180/aqm/Customer-Service-Web

# Conflicts:
#	service/src/api/ports.js
#	service/src/pages/login.vue
blade il y a 6 ans
Parent
commit
b3a7fa5e2a

+ 1 - 1
service/config/index.js

@@ -9,7 +9,7 @@ module.exports = {
 
     // Paths
     assetsSubDirectory: 'static',
-    assetsPublicPath: '/',
+    assetsPublicPath: './',
     // proxyTable: {
     //   '/api': {
     //     target: 'http://103.108.43.176:8080', // 后台访问地址 http://kfadmin.bocai186.com

+ 8 - 2
service/src/App.vue

@@ -81,6 +81,9 @@
 			websocketonmessage(e){
 				this.heatBeat();//收到消息会刷新心跳检测,如果一直收到消息,就推迟心跳发送
 				const redata = JSON.parse(e.data);//接收数据源
+				if(!redata) {
+					return
+				}
 				//
 				if(redata.message_type == "ping"){
 					this.$websocket.send('{"type":"pong"}')
@@ -90,6 +93,9 @@
 				if(redata.type == "pong") return false;
 				if(redata.type != "pong" || redata.message_type != "ping"){
 					console.log(redata);
+					if(redata.message_type === 'connct') {
+						this.$store.dispatch("SET_SESSSION_USER", redata.data.user_info);
+					}
 				}
 				let getters = this.$store.getters;
 				//获取vuex数据
@@ -99,7 +105,6 @@
 				let dataIndex  = getters.get_num;//列表下标
 				let current_session  = getters.get_current;//当前会话
 				let session_name  = getters.get_session_name;//当前用户名
-
 				this.$store.dispatch("SET_SESSION_MESSAGE",JSON.parse(e.data));
 
 				// 用户接入数据
@@ -330,7 +335,8 @@
 		},
 		destroyed() {
 			this.lockReconnect = true;
-			this.websock.close()                   //离开路由之后断开websocket连接
+			this.$websocket.close();
+			// this.websock.close()                   //离开路由之后断开websocket连接
 			clearTimeout(this.reconnectData);      //离开清除 timeout
 			clearTimeout(this.timeoutObj);         //离开清除 timeout
 			clearTimeout(this.serverTimeoutObj);   //离开清除 timeout

+ 95 - 10
service/src/pages/TheCurrentSession.vue

@@ -15,7 +15,7 @@
 							</template>
 							<div :class="{session_choose:dataIndex ==index &&  sessionType ==1}"
 								 class="user session_style" @click="chooseDialogue(1,index)"
-								 v-for="(item,index) in sessionList">
+								 v-for="(item,index) in sessionList" :key="index">
 								<div class="row allAlignment item-center">
 									<span style="font-weight:bold;color:#666;font-size:14px;">{{item.name}}</span>
 									<span style="color:#999;font-size:.12px;">{{item.intime}}</span>
@@ -34,7 +34,7 @@
 							</template>
 							<div :class="{session_choose:dataIndex == index &&  sessionType ==2}"
 								 class="user session_style" @click="chooseDialogue(2,index)"
-								 v-for="(item,index) in offlineList">
+								 v-for="(item,index) in offlineList" :key="index">
 								<div class="row allAlignment item-center">
 									<span style="font-weight:bold;color:#999;font-size:14px;">{{item.name}}</span>
 									<span style="color:#999;font-size:12px;">{{item.intime}}</span>
@@ -95,6 +95,10 @@
 					</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'">
@@ -169,7 +173,7 @@
 						<textarea draggable="false" class="input scroll" id="input" v-model.trim="inputValue"
 								  @keyup.enter="listenEnter($event)" @keyup.ctrl.enter="lineFeed()"></textarea>
 						<div class="row rightAlignment" style="width: 100%;">
-							<div @click="sendMessage()" class="msgInputBtn row center">发送</div>
+							<div @click="sendMessage()" @keyup.enter="sendMessage" class="msgInputBtn row center">发送</div>
 						</div>
 					</div>
 					<!-- 发送消息音频提示 -->
@@ -333,6 +337,7 @@
 	import leftNav from "@/components/leftNav";
 	import hader from "@/components/hader";
 	import messageCenter from "@/components/messageCenter";
+	import historicalRecord from "@/components/historicalRecord";
 
 	export default {
 		name: "TheCurrentSession",
@@ -375,6 +380,9 @@
 				showHistoryList: false,
 				historyList: [],
 				historyTime:'',
+				historyLoading: false, // 历史记录加载
+				historyProcess: '更多历史记录', // 查看历史历史记录或者加载中
+				historyPage: 1 // 当前的历史记录页
 			}
 		},
 		methods: {
@@ -692,6 +700,7 @@
 			/***************关闭当前和用户聊天对话***************/
 			open() {
 				let _this = this;
+				console.log(this.sessionList)
 				if (this.sessionType == 1) {
 					if (this.sessionList.length < 1) return
 				} else {
@@ -708,7 +717,7 @@
 					let data = {
 						"type": "kfCloseUser",
 						data: {
-							to_id,
+							to_id: '',
 							kf_id: "KF" + _this.user_info.id,
 							group_id: _this.user_info.group_id,
 							conversationId: conversationId,
@@ -756,6 +765,11 @@
 
 			/*********************发送消息*********************/
 			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.sessionType == 2) {
@@ -805,7 +819,8 @@
 						type: 'service', content: {
 							text: this.$public.turnFace(this.inputValue, this.$frce),
 							img: '',
-						}, time: this.time[1]
+						}, 
+						// time: this.time[1]
 					});
 					//this.data = [];
 					//标记当前会话位置
@@ -824,7 +839,7 @@
 					//计算关键词次数
 					this.sensitiveNumber = this.sensitiveNumber + sensitive_data.num;
 				}
-
+				this.historyProcess = '更多历史消息' // 发送信息成功后改变说明
 
 			},
 
@@ -1123,7 +1138,9 @@
 			/****************访问信息和评价状态***************/
 			accessTerminal(data) {
 				if (this.sessionType == 1) {
+					console.log('dataIndex', this.dataIndex)
 					let List = this.sessionList[this.dataIndex];
+					console.log('list', List)
 					if (data == 'eva') {
 						if (!List) return false
 						// console.log(List,'对话信息');
@@ -1164,8 +1181,64 @@
 					}
 					// }
 				}
+			},
+			getHistoryInfo() { // 获取历史数据
+				let obj = {
+					headers: {
+						apiToken: this.$md5("userhistory" + "customer-service" + "history" + "service"),
+						// 'apiToken': this.$md5("historylist" + "customer-service" + "history" + "service"),
+						userToken: this.token
+					},
+					params: {
+						// user_name: this.user_info.account_name,
+						account_id: 'KF' + this.user_info.id,
+						currentPage: this.historyPage,
+						pageSize: 10
+					}
+				};
+				this.historyLoading = true
+				this.historyProcess = '加载中'
+				this.$http.get(this.$ports.history.userHistory,obj).then(res => {
+					if(res.data.code == 1) {
+						if(!res.data.data.total ) { // 历史记录总数
+							this.historyProcess = '没有更多历史记录'
+							this.historyLoading = false
+						} else {
+							// 遍历封装数据
+							if(this.historyPage > res.data.data.countPage) {
+								this.historyProcess = '没有更多历史记录'
+							    this.historyLoading = false
+							} else {
+								let list = res.data.data.list
+								if(list) {
+									for(let item of list) {
+										let historyItem = {
+											type: item.from_id.substr(0, 2) === 'KF' ? 'service' : 'user',
+											time: this.$public.customFormatDateTime(item.time_line),
+											content: JSON.parse(item.content)
+										}
+										this.data.unshift(historyItem)
+									}
+									this.historyPage ++ ;
+									this.historyProcess = '更多历史记录'
+									this.historyLoading = false;
+								} else {
+									this.historyProcess = '没有更多历史记录'
+							    	this.historyLoading = false
+								}
+							}
+						}
+					}
+				}).catch(err => {
+					this.$message.error(err.message)
+					this.historyLoading = false;
+					this.historyProcess = '更多历史记录'
+				})
 			}
 		},
+		created() {
+			this.get_vuex_info();
+		},
 		/**
 		 * 挂载前执行
 		 */
@@ -1206,8 +1279,14 @@
 				this.chatMessage(e)
 			},
 
-			sessionList(e) {
-				this.accessTerminal(e)
+			// sessionList(e) {
+			// 	this.accessTerminal(e)
+			// },
+			sessionList: {
+				handler(val) {
+					this.accessTerminal(val)
+				},
+				deep: true
 			},
 			offlineList(e) {
 				this.accessTerminal(e)
@@ -1229,7 +1308,7 @@
 				offlineList: 'get_offline',
 				dataIndex: 'get_num',
 				sessionType: 'get_type',
-				get_user_info: 'get_session_user',
+				get_user_info: 'get_session_user', // 会话人详细信息
 				// is_eva_btn:'get_is_eva_btn',
 			}),
 
@@ -1247,7 +1326,8 @@
 		components: {
 			leftNav,
 			hader,
-			messageCenter
+			messageCenter,
+			historicalRecord
 		}
 	};
 </script>
@@ -1680,4 +1760,9 @@
 	.rightAlignment .el-button {
 		border: none;
 	}
+	.history-info {
+		color: #5399f5;
+		text-align: center;
+		margin-top: 5px;
+	}
 </style>

+ 1 - 1
service/src/store/index.js

@@ -8,7 +8,7 @@ Vue.use(Vuex);
  store
  */
 const state = {
-	user_info: localStorage.getItem('user'), //用户信息
+	user_info: localStorage.getItem('user'), //用户(客服)信息
 	sessionList: [],//会话列表
 	offlineList: [],//离线列表
 	current_session: [],//当前会话详情信息