Harley 6 年之前
父节点
当前提交
0dbc726e73

+ 2 - 2
service/build/webpack.base.conf.js

@@ -18,8 +18,8 @@ module.exports = {
 		path: config.build.assetsRoot,
 		filename: '[name].js',
 		publicPath: process.env.NODE_ENV === 'production'
-			? config.build.assetsPublicPath
-			: config.dev.assetsPublicPath
+			? "./" +config.build.assetsPublicPath
+			: "./" +config.dev.assetsPublicPath
 	},
 	resolve: {
 		extensions: ['.js', '.vue', '.json'],

+ 3 - 1
service/build/webpack.prod.conf.js

@@ -25,7 +25,9 @@ const webpackConfig = merge(baseWebpackConfig, {
   output: {
     path: config.build.assetsRoot,
     filename: utils.assetsPath('js/[name].[chunkhash].js'),
-    chunkFilename: utils.assetsPath('js/[id].[chunkhash].js')
+    chunkFilename: utils.assetsPath('js/[id].[chunkhash].js'),
+    //打包添加
+    publicPath:'./'
   },
   plugins: [
     // http://vuejs.github.io/vue-loader/en/workflow/production.html

+ 10 - 10
service/config/index.js

@@ -10,16 +10,16 @@ module.exports = {
     // Paths
     assetsSubDirectory: 'static',
     assetsPublicPath: '/',
-    proxyTable: {
-      '/api': {
-        target: 'http://103.108.43.176:8080', // 后台访问地址 http://kfadmin.bocai186.com
-        //target:'http://192.168.2.187:8090', // 后台访问地址http://192.168.2.186:8090
-        // changeOrigin: true,
-        pathRewrite: {
-          '^/api': ''
-        }
-      }
-    },
+    // proxyTable: {
+    //   '/api': {
+    //     target: 'http://103.108.43.176:8080', // 后台访问地址 http://kfadmin.bocai186.com
+    //     //target:'http://192.168.2.187:8090', // 后台访问地址http://192.168.2.186:8090
+    //     // changeOrigin: true,
+    //     pathRewrite: {
+    //       '^/api': ''
+    //     }
+    //   }
+    // },
 
     // Various Dev Server settings
     host: 'localhost', // can be overwritten by process.env.HOST //192.168.2.163 localhost

+ 9 - 8
service/index.html

@@ -3,7 +3,8 @@
   <head>
     <meta charset="utf-8">
     <meta name="viewport" content="width=device-width,initial-scale=1.0">
-    <title>service</title>
+    <link rel ="shortcut icon" type="image/x-icon" href="static/logo.gif">
+	  <title>大博集团--客服</title>
   </head>
   <body>
     <div id="app"></div>
@@ -11,13 +12,13 @@
   </body>
   <script>
   	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 = "无效访问地址";
-    }
+    // 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);

+ 14 - 11
service/src/App.vue

@@ -299,19 +299,20 @@
 		},
 		mounted() {
 			Vue.prototype.$socket_open = false;
+			this.apiToken = this.$md5('customer-service'+window.location.origin)
+			this.initWebSocket(this.apiToken);
 			// 获取系统时间
-			let t = new Date().getTime();
+			//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;
-					sessionStorage.setItem("time",JSON.stringify(time));
-					sessionStorage.setItem("logo",res.data.data.logo);
-					this.apiToken = this.$md5('customer-service'+window.location.origin)
-					this.initWebSocket(this.apiToken);
-				}
-			});
+			// this.$http.get(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;
+			// 		sessionStorage.setItem("time",JSON.stringify(time));
+			// 		sessionStorage.setItem("logo",res.data.data.logo);
+					
+			// 	}
+			// });
 		},
 		destroyed() {
 			this.lockReconnect = true;
@@ -319,6 +320,8 @@
 			clearTimeout(this.reconnectData);      //离开清除 timeout
 			clearTimeout(this.timeoutObj);         //离开清除 timeout
 			clearTimeout(this.serverTimeoutObj);   //离开清除 timeout
+			localStorage.removeItem('user');
+			// console.log(123) 
 		}
 	}
 </script>

+ 11 - 14
service/src/api/http.js

@@ -21,18 +21,15 @@ export default {
      * @returns {Promise}
      */
     get (url, params) {
-
-    return new Promise((resolve, reject) => {
-        axios.get(headerUrl(url), {
-        params
-        })
-        .then(res => {
-            resolve(res)
+        return new Promise((resolve, reject) => {
+            axios.get(headerUrl(url),params)
+            .then(res => {
+                resolve(res)
+            })
+            .catch(err => {
+                reject(err)
+            })
         })
-        .catch(err => {
-            reject(err)
-        })
-    })
     },
     /**
      * post方法对应post请求
@@ -40,9 +37,9 @@ export default {
      * @param {Object} params 携带参数
      * @returns {Promise}
      */
-    post (url, params) {
-    return new Promise((resolve, reject) => {
-        axios.post(headerUrl(url), qs.stringify(params))
+    post (url, params,headers) {
+    return new Promise((resolve, reject) => { 
+        axios.post(headerUrl(url), params ?qs.stringify(params):'',headers)
         .then(res => {
             resolve(res)
         })

+ 25 - 2
service/src/api/ports.js

@@ -17,7 +17,7 @@ export default {
   },
 
   //图片上传
-  uploadImg:'index/upload/uploadImg',
+  uploadImg:'/index/upload/uploadImg',
 
   //获取配置信息
   minRound:'/index/evaluate/minRound',
@@ -31,7 +31,30 @@ export default {
     updatepwd:'/service/Services/updatepwd',
     update:'/service/services/update',//客服编辑用户信息
     accountInfo:'/service/services/accountInfo'
+  },
+
+  //历史会话消息
+  history:{
+    historyList:'/service/history/historyList',
+    historyInfo:"/service/history/historyInfo",
+  },
 
+  //留言 
+  Message:{
+    dealmessage:'/service/Message/dealmessage',
+    index:'/service/Message/index',
+  },
+  //消息中心
+  center:{
+    readnotice:"/service/index/readnotice",
+    unreadnotice:"/service/index/unreadnotice",
+    updatenotice:"/service/index/updatenotice",//读取信息
+    
+  },
+  //会话总览
+  overview:{
+    allConversation:"/service/history/allConversation",
+    chatByTime:'/service/history/chatByTime',
   }
-  
+
 }

+ 14 - 15
service/src/components/hader.vue

@@ -280,9 +280,10 @@
 						apiToken: this.$md5(str),
 						userToken: this.user_info.token
 					},
-					user_id: this.userID
 				};
-				this.post("api/service/index/unreadnotice", obj).then(res => {
+				this.$http.post(this.$ports.center.unreadnotice,{
+					user_id: this.userID
+				},obj).then(res => {
 					if(res.data.code === 1){
 						// console.log(res.data.data)
 						 this.unreadNum =  res.data.data.length;
@@ -325,13 +326,12 @@
 						userToken: this.user_info.token
 					}
 				};
-				this.post("api/service/history/allConversation",'',obj).then(res => {
+				this.$http.post(this.$ports.overview.allConversation,'',obj).then(res => {
 					if(res.data.code === 1){
 						// console.log('会话',res.data)
 						this.dataTree = res.data.data;
-						 //this.unreadNum =  res.data.data.length;
 						this.interval =  setInterval(()=>{
-							this.post("api/service/history/allConversation",'',obj).then(res => {
+							this.$http.post(this.$ports.overview.allConversation,'',obj).then(res => {
 								if(res.data.code === 1){
 									this.serverList = res.data.serverList;
 									this.dataTree = res.data.data;
@@ -360,16 +360,15 @@
 			get_session_lise(time){
 				// if() return false
 				let str ="chatbytime" + "customer-service" + "history" + "service";
-				this.get("api/service/history/chatByTime",{
-				params:{
-					servicelog_id:this.servicelog.servicelog_id,
-					lastTime:time,
-				},
-				headers:{
-					'X-Requested-With': 'XMLHttpRequest',
-					'apiToken': this.$md5(str),
-					'userToken':  this.user_info.token
-				}
+				this.$http.get(this.$ports.overview.chatByTime,{
+					params:{
+						servicelog_id:this.servicelog.servicelog_id,
+						lastTime:time,
+					},
+					headers:{
+						'apiToken': this.$md5(str),
+						'userToken':  this.user_info.token
+					}
 				}).then(res => {
 					if(res.data.code == 1){
 						res.data.data.list = res.data.data.list.reverse();

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

@@ -165,7 +165,7 @@ export default {
         //获取会话详情列表
         getRecordList(page,size = 10){
             let str ="historyinfo" + "customer-service" + "history" + "service";
-            this.get("api/service/history/historyInfo",{
+            this.$http.get(this.$ports.history.historyInfo,{
             params:{
                 servicelog_id:this.uid,
                 currentPage: page,

+ 11 - 8
service/src/components/messageCenter.vue

@@ -142,9 +142,10 @@
 						apiToken: this.$md5(str),
 						userToken: this.token
 					},
-					user_id: this.userID
 				};
-				this.post("api/service/index/readnotice", obj).then(res => {
+				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)
@@ -164,9 +165,10 @@
 						apiToken: this.$md5(str),
 						userToken: this.token
 					},
-					user_id: this.userID
 				};
-				this.post("api/service/index/unreadnotice", obj).then(res => {
+				this.$http.post(this.$ports.center.unreadnotice,{
+					user_id: this.userID
+				},obj).then(res => {
 					// console.log(res)
 					if(res.data.code === 1){
 						console.log("未读",res.data.data)
@@ -192,14 +194,15 @@
 						apiToken: this.$md5(str),
 						userToken: this.token
 					},
-					servicenotice_id: id
 				};
-				this.post("api/service/index/updatenotice", obj).then(res => {
-					console.log(res)
+				this.$http.post(this.$ports.center.updatenotice,{
+					servicenotice_id: id
+				},obj).then(res => {
+					// console.log(res)
 					if(res.data.code === 1){
 						console.log("已读",res.data.data)
 					}
-				});
+				})
 			},
 			
 

+ 1 - 5
service/src/main.js

@@ -14,9 +14,7 @@ import ports from './api/ports.js'; //api接口文档
 import publicMethods from '../static/publicMethods.js';
 import md5 from 'js-md5';
 Vue.use(ElementUI);
-axios.defaults.headers.post['Content-Type'] = 'Content-Type: application/json';
-// post请求头
-axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8';
+
 Vue.config.productionTip = false;
 // 注册表情包数组
 Vue.prototype.$frce = frce.frce;
@@ -25,8 +23,6 @@ Vue.prototype.$md5 = md5;
 // 公共方法
 Vue.prototype.$ports = ports;
 Vue.prototype.$http = http;
-Vue.prototype.post = axios.post;
-Vue.prototype.get = axios.get;
 Vue.prototype.$public = publicMethods;
 /* eslint-disable no-new */
 new Vue({

+ 4 - 4
service/src/pages/FastReply.vue

@@ -304,7 +304,7 @@
 					}
 				};
 				// this.popUp.status =  1;
-				this.post("api" + this.$ports.FastReply.addWords, this.popUp, obj).then(res => {
+				this.$http.post(this.$ports.FastReply.addWords, this.popUp, obj).then(res => {
 					if (res.data.code == 1) {
 						this.succeed(1);
 						this.ReplyArr.push({
@@ -329,7 +329,7 @@
 						userToken: this.token
 					}
 				};
-				this.get("api" + this.$ports.FastReply.userWords, obj).then(res => {
+				this.$http.get(this.$ports.FastReply.userWords,'',obj).then(res => {
 					// console.log(res);
 					if (res.data.code == 1) {
 						//私有库
@@ -348,7 +348,7 @@
 				};
 				// console.log(this.deleteArr);
 				if (this.deleteArr.length > 0) {
-					this.post("api" + this.$ports.FastReply.deleteWords, this.deleteArr, obj).then(
+					this.$http.post(this.$ports.FastReply.deleteWords, this.deleteArr, obj).then(
 						res => {
 							if (res.data.code) {
 								this.succeed(1);
@@ -395,7 +395,7 @@
 						userToken: this.token
 					}
 				};
-				this.post('api' + this.$ports.FastReply.updateWords, {
+				this.$http.post(this.$ports.FastReply.updateWords, {
 					id: this.changePopUp.id,
 					content: this.changePopUp.content,
 					status: 1,

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

@@ -117,7 +117,7 @@
 										</el-col>
 										<el-col>
 											<el-upload style="margin:10px;"
-													action="/api/index/upload/uploadImg"
+													action="http://kfadmin.bocai186.com/index/upload/uploadImg"
 													:before-upload="beforeAvatarUpload"
 													:on-change='uploadChange'
 													:on-success='uploadSuccess'
@@ -360,7 +360,7 @@
 							"reply_content":this.leaveInfor,
 							"images":this.imgUrl,
 						}
-						this.post('/api/service/Message/dealmessage', parmas).then(res => {
+						this.$http.post(this.$ports.Message.dealmessage, parmas).then(res => {
 							this.$message.success(res.data.msg);
 							this.leaveInfor = '';
 							this.drawer = false;
@@ -381,10 +381,11 @@
 						"apiToken": this.$md5('accountInfo' + "customer-service" + 'service' + 'service'),
 						'userToken': this.token
 					},
-					account_id: id
 				};
 
-				this.post('api' + this.$ports.userInfo.accountInfo, obj).then(res => {
+				this.$http.post(this.$ports.userInfo.accountInfo, {
+					account_id: id
+				},obj).then(res => {
 					if (res.data.code == 1) {
 						this.userInfo = res.data.data;
 					}
@@ -429,8 +430,8 @@
 			// 获取列表数据
 			getSessionList(page, size=10) {
 				let searchText =this.input3
-				let str = "index" + "customer-service" + "Message" + "service";
-				this.get("api/service/Message/index", {params:{
+				let str = "index" + "customer-service" + "message" + "service";
+				this.$http.get(this.$ports.Message.index, {params:{
 						start_time: this.startTime,
 						end_time: this.endTime,
 						pageSize: size,

+ 2 - 2
service/src/pages/PersonalInformation.vue

@@ -168,7 +168,7 @@ export default {
           userToken: this.token
         }
       };
-      this.post("api"+ this.$ports.userInfo.updatepwd, {
+      this.$http.post(this.$ports.userInfo.updatepwd,{
         token:this.token,
         password:this.originalPwd,
         new_password:this.password,
@@ -198,7 +198,7 @@ export default {
           userToken: this.token
         }
       };
-      this.post("api"+ this.$ports.userInfo.updateinfo, {
+      this.$http.post(this.$ports.userInfo.updateinfo, {
         token:this.token,
         user_name:this.user_info.user_name,
         user_email:this.user_info.user_email,

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

@@ -59,12 +59,12 @@
 					</div>
 					<div v-show="pages > 9 " style=" padding: 10px;">
 						<el-pagination background layout="prev, pager, next" prev-text='上一页' next-text='下一页'
-									   @prev-click='upData' @next-click="downData" @current-change="current_page"
-									   :total="pages"></el-pagination>
+							@prev-click='upData' @next-click="downData" @current-change="current_page"
+							:total="pages"></el-pagination>
 					</div>
 					<div class="right_box" v-show="isShow">
 						<historicalRecord :show="isShow" :uid="uid" :user_name="user_name"
-										  v-on:childValue="childValue"/>
+							v-on:childValue="childValue"/>
 					</div>
 				</div>
 			</div>
@@ -219,7 +219,7 @@
 					}
 				}
 				this.loading = true;
-				this.post("api/service/history/historyList", {
+				this.$http.post(this.$ports.history.historyList, {
 					currentPage: page,
 					pageSize: size,
 					start: this.startTime,

+ 16 - 15
service/src/pages/TheCurrentSession.vue

@@ -511,7 +511,7 @@
 				// 转接历史信息
 				if (redata.message_type == "connect") {
 					if (redata.data.history.length > 0) {
-						//console.log(redata, '转接历史消息');
+						console.log(redata, '转接历史消息');
 						this.showHistoryList = true;
 						redata.data.history.forEach(res => {
 							let content = JSON.parse(res.content)
@@ -562,7 +562,7 @@
 			upImg(formData) {
 				let self = this;
 				// 数据结构请求
-				self.post('api/' + self.$ports.uploadImg, formData).then(res => {
+				self.$http.post(self.$ports.uploadImg, formData).then(res => {
 					//console.log(res.data.data.src)
 					if (res.data.code == 1) {
 						let isFirst = true;
@@ -883,15 +883,14 @@
 
 			/*****************获取当前聊天用户信息****************/
 			get_user(id,type,index) {
-				// console.log(id,type,index)
 				let obj = {
-					headers: {
-						"apiToken": this.$md5('accountInfo' + "customer-service" + 'service' + 'service'),
-						'userToken': this.token
-					},
 					account_id: id
 				};
-				this.post('api' + this.$ports.userInfo.accountInfo, obj).then(res => {
+				let headers ={	headers: {
+						"apiToken": this.$md5('accountInfo' + "customer-service" + 'service' + 'service'),
+						'userToken': this.token
+					},}
+				this.$http.post(this.$ports.userInfo.accountInfo,obj,headers).then(res => {
 					if (res.data.code == 1) {
 						this.session_user_info = res.data.data;
 						this.value = res.data.data.label
@@ -922,7 +921,7 @@
 						userToken: this.token
 					}
 				};
-				this.get("api/" + this.$ports.minRound, obj).then(res => {
+				this.$http.get( this.$ports.minRound,obj).then(res => {
 					if (res.data.code == 1) {
 						this.trigger_condition = res.data.data.systemconfig_data;
 					}
@@ -946,7 +945,7 @@
 						'userToken': this.token
 					}
 				};
-				this.post('api' + this.$ports.sensitiveWords, '', obj).then(res => {
+				this.$http.post(this.$ports.sensitiveWords, '', obj).then(res => {
 					if (res.data.code == 1) {
 						res.data.data.serverSensitive.forEach(res => {
 							this.sensitive.push(res.sensitivewords_word)
@@ -976,10 +975,6 @@
 				if (!this.isTrue) return false;
 				this.isTrue = false;
 				let obj = {
-					headers: {
-						"apiToken": this.$md5('update' + "customer-service" + 'service' + 'service'),
-						'userToken': this.token
-					},
 					account_id: this.session_user_info.id,
 					nick_name: this.session_user_info.nick_name,
 					account_email: this.session_user_info.account_email,
@@ -989,8 +984,14 @@
 					label_id: this.label_id
 
 				};
+				let headers={
+					headers: {
+						"apiToken": this.$md5('update' + "customer-service" + 'service' + 'service'),
+						'userToken': this.token
+					},
+				}	
 
-				this.post('api' + this.$ports.userInfo.update, obj).then(res => {
+				this.$http.post(this.$ports.userInfo.update, obj,headers).then(res => {
 					if (res.data.code == 1) {
 						this.websocketsend(JSON.stringify({"type":"updateusercache","data":{"userid":this.session_user_info.id}}))
 						this.$message({

+ 12 - 1
service/src/pages/login.vue

@@ -134,7 +134,18 @@
 			},
 		},
 		mounted(){
-			this.logo = sessionStorage.getItem('logo');
+
+			this.$http.get(this.$ports.TIME).then(res => {
+				if (res.data.code == 1) {
+					let time = res.data.data.time.split(' ');
+					time[0] =(new Date( time[0].replace(/-/g,'/')).getTime()) /1000;
+					sessionStorage.setItem("time",JSON.stringify(time));
+					this.logo = res.data.data.logo;
+					sessionStorage.setItem("logo",res.data.data.logo);
+					
+				}
+			});
+			// this.logo = sessionStorage.getItem('logo');
 			//console.log(this.logo, '========logo')
 		}
 	};

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

@@ -3,7 +3,7 @@ import Router from 'vue-router'
 
 Vue.use(Router)
 const routers = new Router({
-  mode: 'history',
+  // mode: 'history',
   routes: [
     {
       path: '/',

二进制
service/static/logo.gif