Harley 6 years ago
parent
commit
6b7c2b64c4

+ 20 - 1
service/index.html

@@ -6,7 +6,26 @@
     <title>service</title>
   </head>
   <body>
-    <div id="app"></div>
+    <div id="app">
+    </div>
     <!-- built files will be auto injected -->
   </body>
+  <script type="text/javascript">
+  	let name = getQueryString('pid');
+    if(unescape(name) != "这就是一个编码没有什么用啊"){
+      document.getElementById("app").remove();
+      var parent = document.body;
+      var div = document.createElement("div");
+      parent.appendChild(div)
+      div.innerHTML = "无效访问地址";
+    }
+    function getQueryString(name) {
+      var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
+      var r = window.location.search.substr(1).match(reg);
+      if (r != null) {
+        return unescape(r[2]);
+      }
+      return null;
+    }
+  </script>
 </html>

+ 19 - 6
service/src/App.vue

@@ -10,8 +10,6 @@
 	import Vue from 'vue';
 	export default {
 		name: 'App',
-		// apiToken:'',//WebSocket链接凭证
-		// time:'',
 		data(){
 			return{
 				reconnectData:null,
@@ -21,7 +19,6 @@
 				serverTimeoutObj:null,
 				apiToken:'',
 				linkfailure:true,
-
 			}
 		},
 		methods:{
@@ -39,12 +36,18 @@
 				this.$websocket.onclose = this.socket_close;//链接断开提示
 			},
 
-
 			/**************************************/
 			//连接成功
 			websocketonopen() {
 				console.log('已经链接');
-				let user_info = this.$store.getters.get_user_info;
+				let user_info = '';
+				// console.log(this.$store.getters.get_user_info != "");
+				if(typeof this.$store.getters.get_user_info  != 'string'){
+					user_info = this.$store.getters.get_user_info;
+				}else if(this.$store.getters.get_user_info!= ""){
+					user_info =  JSON.parse(this.$store.getters.get_user_info);
+				}
+
 				if(user_info){
 					this.$websocket.send(JSON.stringify({
 						type: 'init',
@@ -57,6 +60,8 @@
 						}
 					}));
 				}
+		
+			
 				this.$store.dispatch("SET_SOCKET_OPEN",true);//列表下标  
 				this.heatBeat();
 			},
@@ -105,7 +110,7 @@
 						sessionType,
 						dataIndex,
 						current_session,
-						session_name
+						session_name,
 					]
 					_this.$public.visitorsConnect(arr,function(data){
 						//离线匹配列表访客链接回调
@@ -132,6 +137,13 @@
 					})
 				}
 
+				//登录验证失败跳转登录页面
+				if(redata.message_type == 'checkfalse'){
+					// this.$router.push({
+					// 	path:'/login',
+					// 	query: { pid:escape("这就是一个编码没有什么用啊") }
+					// })
+				}
 
 				//用户离线后会话窗口切换
 				if(redata.message_type == "userClose"){
@@ -237,6 +249,7 @@
 				this.$store.dispatch("SET_CURRENT",[]);//当前会话数据
 				this.$store.dispatch("SET_SESSION_NAME",'');//当前会话对象名
 				this.$store.dispatch("SET_SESSION_MESSAGE",{});
+				this.$store.dispatch("SET_NAVSTATE",'TheCurrentSession');
 				this.$store.dispatch("SET_IS_INIT",false);
 				this.$token = '';
 				this.$router.push('/login')

+ 6 - 2
service/src/components/hader.vue

@@ -112,7 +112,7 @@
 				
 				// console.log(this.$socket_open)
 				this.$token = '';
-				this.$router.push({path:'/login',query: { pid:escape("~!@#¥%……&*()——+,./;'[]") }})
+				this.$router.push({path:'/login',query: { pid:escape("这就是一个编码没有什么用啊") }})
 			},
 
 			/**************************************/
@@ -144,7 +144,11 @@
 			if (this.$store.getters.get_stateValue) {
 				this.value = this.$store.getters.get_stateValue;
 			}
-			this.user_info = this.$store.getters.get_user_info;
+			if(typeof this.$store.getters.get_user_info  != 'string'){
+				this.user_info = this.$store.getters.get_user_info
+			}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.unreadnotice();
 			let _this = this;

+ 5 - 1
service/src/components/historicalRecord.vue

@@ -144,7 +144,11 @@ export default {
         }
     },
     mounted() {
-        this.token = this.$store.getters.get_user_info.token;
+        if(typeof this.$store.getters.get_user_info  != 'string'){
+            this.token = this.$store.getters.get_user_info.token;
+        }else if(this.$store.getters.get_user_info!= ""){
+            this.token = JSON.parse(this.$store.getters.get_user_info).token;
+        }
         this.time = JSON.parse(sessionStorage.getItem("time"));
     },
     computed:{

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

@@ -74,7 +74,7 @@
 
 				this.$store.dispatch("SET_NAVSTATE", str);
 				// this.$store.dispatch("SET_DRAWER",false);
-				this.$router.push({path,query: { pid:escape("~!@#¥%……&*()——+,./;'[]") }});
+				this.$router.push({path,query: { pid:escape("这就是一个编码没有什么用啊") }});
 			}
 		},
 		// computed: {
@@ -91,15 +91,6 @@
 		mounted() {
 			this.titleActive = this.$store.getters.get_navState;
 			this.logo = sessionStorage.getItem('logo');
-			// console.log(this.logo, '========logo')
-			// // // 获取系统时间
-			// this.get('api'+this.$ports.TIME).then(res => {
-			//   if (res.data.data.time) {
-			//     sessionStorage.setItem("time", res.data.data.time);
-			//     let apiToken = this.$md5('customer-service'+res.data.data.time+window.location.origin)
-			//     sessionStorage.setItem('apiToken',apiToken)
-			//   }
-			// });
 		},
 	};
 </script>

+ 0 - 5
service/src/components/messageCenter.vue

@@ -198,11 +198,6 @@
 					console.log(res)
 					if(res.data.code === 1){
 						console.log("已读",res.data.data)
-						// this.unreadList = res.data.data;
-						// this.unreadListOne = res.data.data[0];
-						// // console.log(this.unreadListOne,'第一个')
-						// this.unreadNum =  res.data.data.length;
-
 					}
 				});
 			},

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

@@ -392,7 +392,13 @@
 			}
 		},
 		mounted() {
-			this.token = this.$store.getters.get_user_info.token ;
+			if(typeof this.$store.getters.get_user_info  != 'string'){
+				this.token = this.$store.getters.get_user_info.token;
+			}else if(this.$store.getters.get_user_info!= ""){
+				this.token = JSON.parse(this.$store.getters.get_user_info).token;
+			}
+
+
 			this.time = JSON.parse(sessionStorage.getItem("time"));
 			this.getFastReply();
 			//this.showFastReply();

+ 7 - 4
service/src/pages/LeaveMessage.vue

@@ -257,7 +257,11 @@
 		mounted() {
 			this.frceArr = frce.frce;
 			this.value = this.options[2].value;
-			this.users = this.$store.getters.get_user_info
+			if(typeof this.$store.getters.get_user_info  != 'string'){
+				this.users = this.$store.getters.get_user_info;
+			}else if(this.$store.getters.get_user_info!= ""){
+				this.users = JSON.parse(this.$store.getters.get_user_info);
+			}
 			this.getStartEndAjaxTime(this.value)
 		},
 		computed: {
@@ -316,8 +320,7 @@
 			},
 			// 每次改变图片状态返回的回调
 			uploadChange(file, fileList) {
-
-				console.log(file)
+				// console.log(file)
 				const isJPG = file.raw.type == 'image/jpeg' || 'image/jpg' || 'image/png' || 'image/svg';
 				const isLt1M = file.size / 1024 / 1024 < 0.5;
 				if (!isJPG) {
@@ -475,7 +478,7 @@
 						}
 					}
 				}
-				console.log(this.getUserItem.images);
+				// console.log(this.getUserItem.images);
 				this.get_user(row.account_id)
 			},
 			childValue(e) {

+ 5 - 1
service/src/pages/PersonalInformation.vue

@@ -237,7 +237,11 @@ export default {
   },
   mounted() {
     this.user_info = this.$store.getters.get_user_info;
-    // console.log(this.user_info);
+    if(typeof this.$store.getters.get_user_info  != 'string'){
+      this.user_info = this.$store.getters.get_user_info;
+    }else if(this.$store.getters.get_user_info!= ""){
+      this.user_info = JSON.parse(this.$store.getters.get_user_info);
+    }
     this.token = this.user_info.token;
     this.time = sessionStorage.getItem("time");
   },

+ 5 - 5
service/src/pages/SessionHistory.vue

@@ -128,15 +128,15 @@
 		},
 		mounted() {
 			this.value = this.options[2].value;
-			this.token = this.$store.getters.get_user_info.token;
+			if(typeof this.$store.getters.get_user_info  != 'string'){
+				this.token = this.$store.getters.get_user_info.token;
+			}else if(this.$store.getters.get_user_info!= ""){
+				this.token = JSON.parse(this.$store.getters.get_user_info).token;
+			}
 			this.time = JSON.parse(sessionStorage.getItem("time"));
 			this.getSessionHistory(1);
 		},
 		methods: {
-			// filterEndTime(row, column){
-			// 	console.log(row)
-			// },
-
 			evaluateId(row, column) {
 				// console.log(row.evaluate_id)
 				if (row.evaluate_id == 0) {

+ 31 - 69
service/src/pages/TheCurrentSession.vue

@@ -374,46 +374,11 @@
 				pasteUrl: '',//截屏图片
 				userSwitching: true,//是否切换完成
 				terminal_IP: {},//访客设备信息
-
 				showHistoryList: false,
 				historyList: [],
 				historyTime:'',
 			}
 		},
-		// filters: {
-		// 	/**
-		// 	 * 时间戳转日期自定义时间格式
-		// 	 * timeStamp:时间戳
-		// 	 * custom:转换日期时定义年月日用是什么符号隔开
-		// 	 * isDtae:0=月份、1=日期、3=时间
-		// 	 */
-
-		// 	formatDate: function (value, custom = '', isDtae = 3) {
-		// 		let timeStamp = value;
-		// 		var date = new Date();
-		// 		date.setTime(timeStamp * 1000);
-		// 		var y = date.getFullYear();
-		// 		var m = date.getMonth() + 1;
-		// 		m = m < 10 ? ('0' + m) : m;
-		// 		var d = date.getDate();
-		// 		d = d < 10 ? ('0' + d) : d;
-		// 		var h = date.getHours();
-		// 		h = h < 10 ? ('0' + h) : h;
-		// 		var minute = date.getMinutes();
-		// 		var second = date.getSeconds();
-		// 		minute = minute < 10 ? ('0' + minute) : minute;
-		// 		second = second < 10 ? ('0' + second) : second;
-		// 		if (isDtae == 0) {
-		// 			return y + custom + m //+'student';
-		// 		} else if (isDtae == 1) {
-		// 			return y + custom + m + custom + d;
-		// 		} else if (isDtae == 3) {
-		// 			return h + ':' + minute;
-		// 		} else {
-		// 			return y + '-' + m + '-' + d + ' ' + h + ':' + minute //+ ':' + second;
-		// 		}
-		// 	}
-		// },
 		methods: {
 			/****************************/
 			validation_user_info(type) {
@@ -443,7 +408,6 @@
 				this.dialogVisible = true;
 			},
 
-
 			/************回车提交************/
 			listenEnter(event) {
 				if (event.keyCode === 13) {
@@ -476,14 +440,14 @@
 
 				//用户离线后会话窗口切换
 				if (redata.message_type == "userClose") {
-					console.log(redata)
+					// console.log(redata)
 					return false
 				}
 
 				// //用户会话结束窗口切换
 				if (redata.message_type == "delUser") {
 					redata.data;
-					console.log(redata.data, this.session_user_info)
+					// console.log(redata.data, this.session_user_info)
 					if (redata.data.id == this.session_user_info.id) {
 						this.session_user_info = {};
 						this.value = '请选择';
@@ -685,7 +649,6 @@
 
 			/*****************切换用户会话对象******************/
 			chooseDialogue(type, index) {
-				//console.log(this.sessionList);
 				if (this.userSwitching) {
 					let data = [];
 					let order_id = '';
@@ -695,13 +658,21 @@
 						data = this.sessionList[index].data;
 						order_id = this.sessionList[index].id;
 						this.$set(this.sessionList[index], 'num', 0);
+						this.terminal_IP = {
+							system: this.sessionList[index].system + '-' + this.sessionList[index].browse,
+							ip: this.sessionList[index].ip
+						}
 					} else if (type == 2) {
 						data = this.offlineList[index].data;
 						order_id = this.offlineList[index].id;
+						this.terminal_IP = {
+							system: this.offlineList[index].system + '-' + this.offlineList[index].browse,
+							ip: this.offlineList[index].ip
+						}
 					}
 					this.$store.dispatch("SET_CURRENT", data);//当前会话数据
 					this.userSwitching = false;
-					this.get_user(order_id,type,index)
+					this.get_user(order_id,type,index);
 				} else {
 					// this.$message({
 					// 	message: '警告!,操作太频繁',
@@ -777,6 +748,8 @@
 
 			/*********************发送消息*********************/
 			sendMessage() {
+				console.log(this.sessionList);
+
 				if (!this.inputValue) return;
 				if (this.sessionType == 2) {
 					this.$message({
@@ -911,6 +884,7 @@
 
 			/*****************获取当前聊天用户信息****************/
 			get_user(id,type,index) {
+				// console.log(id,type,index)
 				let obj = {
 					headers: {
 						"apiToken": this.$md5('accountInfo' + "customer-service" + 'service' + 'service'),
@@ -925,12 +899,16 @@
 						if(this.session_user_info.nick_name){
 							this.$store.dispatch("SET_SESSION_NAME", this.session_user_info.nick_name);
 						}
-						if(type ==1){
-							this.sessionList[index].name = this.session_user_info.nick_name
-							this.$store.dispatch("SET_SESSION",this.sessionList)
+						if(type == 1){
+							if(this.session_user_info.nick_name){
+								this.sessionList[index].name = this.session_user_info.nick_name;
+							}
+							this.$store.dispatch("SET_SESSION",this.sessionList);
 						}else if(type == 2){
-							this.offlineList[index].name = this.session_user_info.nick_name 
-							this.$store.dispatch("SET_SESSION", this.offlineList);
+							if(this.session_user_info.nick_name){
+								this.offlineList[index].name = this.session_user_info.nick_name; 
+							}
+							//this.$store.dispatch("SET_SESSION", this.offlineList);
 						}
 					}
 					this.userSwitching = true;
@@ -983,9 +961,14 @@
 
 			/********************获取vuex数据***********************/
 			get_vuex_info() {
-				let getters = this.$store.getters
-				this.token = getters.get_user_info.token;//token
-				this.user_info = getters.get_user_info;//用户消息
+				let getters = this.$store.getters;
+				if(typeof getters.get_user_info  != 'string' ){
+					this.user_info = getters.get_user_info;//用户消息
+				}else{
+					// console.log('vule',JSON.parse(getters.get_user_info));
+					this.user_info = JSON.parse(getters.get_user_info);
+				}
+				this.token = this.user_info.token;//token
 				this.time = JSON.parse(sessionStorage.getItem("time"));
 			},
 
@@ -1135,11 +1118,6 @@
 					}
 				} else if (this.sessionType == 2) {
 					let List = this.offlineList[this.dataIndex];
-					// if(data == 'eva'){
-					// 	if (this.data.length > this.trigger_condition){
-					// 		List.isEva = 100;
-					// 	}
-					// }else{
 					if (List) {
 						this.terminal_IP = {
 							system: List.system + '-' + List.browse,
@@ -1151,7 +1129,6 @@
 					// }
 				}
 			}
-
 		},
 		/**
 		 * 挂载前执行
@@ -1162,21 +1139,6 @@
 			let _this = this;
 			this.get_config_info();
 
-			//客服人员登陆会话
-			if (this.$store.getters.get_is_init) {
-				// this.$websocket.onmessage = this.;
-				_this.websocketsend(JSON.stringify({
-					type: 'init',
-					data: {
-						uid: 'KF' + _this.user_info.id,
-						group: _this.user_info.group_id,
-						token: this.token,
-						name: _this.user_info.user_name,
-						avatar: _this.user_info.user_avatar,
-					}
-				}));
-				this.$store.dispatch("SET_IS_INIT", false);
-			}
 			//获取客服快捷语
 			this.quickReplyInfo();
 			//获取敏感词

+ 25 - 13
service/src/pages/login.vue

@@ -72,10 +72,32 @@
 							if(res.data.code == 1){
 								this.$store.dispatch("SET_USER",res.data.data.user);
 								this.$store.dispatch("SET_IS_INIT",true);
-								Vue.prototype.$token = res.data.data.user.token;
+
+								// console.log({
+								// 	type: 'init',
+								// 	data: {
+								// 		uid: 'KF' + res.data.data.user.id,
+								// 		group: res.data.data.user.group_id,
+								// 		token:res.data.data.user.token,
+								// 		name: res.data.data.user.user_name,
+								// 		avatar:res.data.data.user.user_avatar,
+								// 	}
+								// })
+
+								this.$websocket.send( JSON.stringify({
+									type: 'init',
+									data: {
+										uid: 'KF' + res.data.data.user.id,
+										group: res.data.data.user.group_id,
+										token:res.data.data.user.token,
+										name: res.data.data.user.user_name,
+										avatar:res.data.data.user.user_avatar,
+									}
+								}))
+								
 								this.$router.push({
 									path:'/',
-									query: { pid:escape("~!@#¥%……&*()——+,./;'[]") }
+									query: { pid:escape("这就是一个编码没有什么用啊") }
 								})
 							}else{
 								this.$notify({
@@ -112,17 +134,7 @@
 			},
 		},
 		mounted(){
-			
-			if(!sessionStorage.getItem('logo')){
-				this.get('http://kfadmin.bocai186.com'+this.$ports.TIME).then(res => {
-					if (res.data.code == 1) {
-						console.log(res);
-						this.logo = res.data.data.logo;
-					}
-				});
-			}else{
-				this.logo = sessionStorage.getItem('logo');
-			}
+			this.logo = sessionStorage.getItem('logo');
 			//console.log(this.logo, '========logo')
 		}
 	};

+ 7 - 2
service/src/router/index.js

@@ -53,12 +53,17 @@ const routers = new Router({
 
 //路由守卫
 routers.beforeEach((to, from, next) => { 
-  let token = Vue.prototype.$token;
+  let token = '';
+  if(JSON.parse(localStorage.getItem('user'))){
+    token = JSON.parse(localStorage.getItem('user')).token;
+  }else{
+    token = '';
+  }
   if(to.path !='/login'){
     if(!token){
       routers.push({
         path:'/login',
-        query: { pid:escape("~!@#¥%……&*()——+,./;'[]") }
+        query: { pid:escape("这就是一个编码没有什么用啊") }
       })
     }
   }

+ 17 - 5
service/src/store/index.js

@@ -8,13 +8,13 @@ Vue.use(Vuex);
  store
  */
 const state = {
-	user_info: '', //用户信息
+	user_info: localStorage.getItem('user'), //用户信息
 	sessionList: [],//会话列表
 	offlineList: [],//离线列表
 	current_session:[],//当前会话详情信息
 	sessionType: 1,//选择列表状态默认未1(1是会话中,2是离线)
 	data_num: 0,//定位当前会话,默认是0
-	navState: 'TheCurrentSession',//导航状态
+	navState: localStorage.getItem('titleActive'),//导航状态
 	session_name: '',//当前会话用户名
 	session_message:'',//接收会话信息
 	stateValue: '',//状态值
@@ -22,6 +22,7 @@ const state = {
 	new_drawer: false, //显示消息中心
 	session_user_info:{},//当前会话用户信息
 	socket_open:false,// socket链接状态
+	evaluate_id:0,//访客接入是否评价状态
 }
 
 /**
@@ -29,7 +30,8 @@ const state = {
  */
 const getters = {
 	get_user_info(state) {
-		return state.user_info;
+		// console.log(state.user_info);
+		return state.user_info ? state.user_info : '';
 	},
 	get_session(state) {
 		return state.sessionList;
@@ -69,6 +71,9 @@ const getters = {
 	},
 	get_socket_open(state){
 		return state.socket_open;
+	},
+	get_evaluate_id(state){
+		return state.evaluate_id;
 	}
 }
 /**
@@ -77,7 +82,7 @@ const getters = {
 const mutations = {
 	new_user_info(state, val) {
 		state.user_info = val;
-		//console.log(val);
+		localStorage.setItem('user',JSON.stringify(val));
 	},
 	new_session(state, val) {
 		state.sessionList = val;
@@ -96,6 +101,7 @@ const mutations = {
 	},
 	new_navState(state, val) {
 		state.navState = val;
+		localStorage.setItem('titleActive',val);
 	},
 	new_session_name(state, val) {
 		state.session_name = val;
@@ -118,6 +124,9 @@ const mutations = {
 	new_socket_open(state, val) {
 		state.socket_open = val;
 	},
+	new_evaluate_id(state, val) {
+		state.evaluate_id = val;
+	},
 
 }
 
@@ -126,7 +135,7 @@ const mutations = {
  */
 const actions = {
 	SET_USER(context, val) {
-		context.commit('new_user_info', val);
+		context.commit('new_user_info',val)
 	},
 	SET_SESSION(context, val) {
 		context.commit('new_session', val);
@@ -167,6 +176,9 @@ const actions = {
 	SET_SOCKET_OPEN(context, val) {
 		context.commit('new_socket_open', val);
 	},
+	SET_EVALUATE_ID(context, val) {
+		context.commit('new_evaluate_id', val);
+	},
 }
 const store = new Vuex.Store({
 	state,