Harley 6 years ago
parent
commit
59b0ae466a

+ 57 - 57
service/config/index.js

@@ -5,74 +5,74 @@
 const path = require('path')
 
 module.exports = {
-	dev: {
+  dev: {
 
-		// 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': ''
-				}
-			}
-		},
+    // 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': ''
+        }
+      }
+    },
 
-		// Various Dev Server settings
-		host: 'localhost', // can be overwritten by process.env.HOST //192.168.2.163
-		port: 8000, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
-		autoOpenBrowser: false,
-		errorOverlay: true,
-		notifyOnErrors: true,
-		poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions-
+    // Various Dev Server settings
+    host: 'localhost', // can be overwritten by process.env.HOST //192.168.2.163 localhost
+    port: 8000, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
+    autoOpenBrowser: false,
+    errorOverlay: true,
+    notifyOnErrors: true,
+    poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions-
 
 
-		/**
-		 * Source Maps
-		 */
+    /**
+     * Source Maps
+     */
 
-		// https://webpack.js.org/configuration/devtool/#development
-		devtool: 'cheap-module-eval-source-map',
+    // https://webpack.js.org/configuration/devtool/#development
+    devtool: 'cheap-module-eval-source-map',
 
-		// If you have problems debugging vue-files in devtools,
-		// set this to false - it *may* help
-		// https://vue-loader.vuejs.org/en/options.html#cachebusting
-		cacheBusting: true,
+    // If you have problems debugging vue-files in devtools,
+    // set this to false - it *may* help
+    // https://vue-loader.vuejs.org/en/options.html#cachebusting
+    cacheBusting: true,
 
-		cssSourceMap: true
-	},
+    cssSourceMap: true
+  },
 
-	build: {
-		// Template for index.html
-		index: path.resolve(__dirname, '../dist/index.html'),
+  build: {
+    // Template for index.html
+    index: path.resolve(__dirname, '../dist/index.html'),
 
-		// Paths
-		assetsRoot: path.resolve(__dirname, '../dist'),
-		assetsSubDirectory: 'static',
-		assetsPublicPath: './',
+    // Paths
+    assetsRoot: path.resolve(__dirname, '../dist'),
+    assetsSubDirectory: 'static',
+    assetsPublicPath: './',
 
-		/**
-		 * Source Maps
-		 */
+    /**
+     * Source Maps
+     */
 
-		productionSourceMap: true,
-		// https://webpack.js.org/configuration/devtool/#production
-		devtool: '#source-map',
+    productionSourceMap: true,
+    // https://webpack.js.org/configuration/devtool/#production
+    devtool: '#source-map',
 
-		// Gzip off by default as many popular static hosts such as
-		// Surge or Netlify already gzip all static assets for you.
-		// Before setting to `true`, make sure to:
-		// npm install --save-dev compression-webpack-plugin
-		productionGzip: false,
-		productionGzipExtensions: ['js', 'css'],
+    // Gzip off by default as many popular static hosts such as
+    // Surge or Netlify already gzip all static assets for you.
+    // Before setting to `true`, make sure to:
+    // npm install --save-dev compression-webpack-plugin
+    productionGzip: false,
+    productionGzipExtensions: ['js', 'css'],
 
-		// Run the build command with an extra argument to
-		// View the bundle analyzer report after build finishes:
-		// `npm run build --report`
-		// Set to `true` or `false` to always turn it on or off
-		bundleAnalyzerReport: process.env.npm_config_report
-	}
+    // Run the build command with an extra argument to
+    // View the bundle analyzer report after build finishes:
+    // `npm run build --report`
+    // Set to `true` or `false` to always turn it on or off
+    bundleAnalyzerReport: process.env.npm_config_report
+  }
 }

+ 3 - 3
service/index.html

@@ -6,11 +6,10 @@
     <title>service</title>
   </head>
   <body>
-    <div id="app">
-    </div>
+    <div id="app"></div>
     <!-- built files will be auto injected -->
   </body>
-  <script type="text/javascript">
+  <script>
   	let name = getQueryString('pid');
     if(unescape(name) != "这就是一个编码没有什么用啊"){
       document.getElementById("app").remove();
@@ -28,4 +27,5 @@
       return null;
     }
   </script>
+
 </html>

+ 16 - 41
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",
@@ -1928,7 +1927,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"
       }
@@ -3278,8 +3276,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",
@@ -3960,8 +3957,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",
@@ -4271,8 +4267,7 @@
         "ansi-regex": {
           "version": "2.1.1",
           "bundled": true,
-          "dev": true,
-          "optional": true
+          "dev": true
         },
         "aproba": {
           "version": "1.2.0",
@@ -4293,14 +4288,12 @@
         "balanced-match": {
           "version": "1.0.0",
           "bundled": true,
-          "dev": true,
-          "optional": true
+          "dev": true
         },
         "brace-expansion": {
           "version": "1.1.11",
           "bundled": true,
           "dev": true,
-          "optional": true,
           "requires": {
             "balanced-match": "^1.0.0",
             "concat-map": "0.0.1"
@@ -4315,20 +4308,17 @@
         "code-point-at": {
           "version": "1.1.0",
           "bundled": true,
-          "dev": true,
-          "optional": true
+          "dev": true
         },
         "concat-map": {
           "version": "0.0.1",
           "bundled": true,
-          "dev": true,
-          "optional": true
+          "dev": true
         },
         "console-control-strings": {
           "version": "1.1.0",
           "bundled": true,
-          "dev": true,
-          "optional": true
+          "dev": true
         },
         "core-util-is": {
           "version": "1.0.2",
@@ -4445,8 +4435,7 @@
         "inherits": {
           "version": "2.0.3",
           "bundled": true,
-          "dev": true,
-          "optional": true
+          "dev": true
         },
         "ini": {
           "version": "1.3.5",
@@ -4458,7 +4447,6 @@
           "version": "1.0.0",
           "bundled": true,
           "dev": true,
-          "optional": true,
           "requires": {
             "number-is-nan": "^1.0.0"
           }
@@ -4473,7 +4461,6 @@
           "version": "3.0.4",
           "bundled": true,
           "dev": true,
-          "optional": true,
           "requires": {
             "brace-expansion": "^1.1.7"
           }
@@ -4481,14 +4468,12 @@
         "minimist": {
           "version": "0.0.8",
           "bundled": true,
-          "dev": true,
-          "optional": true
+          "dev": true
         },
         "minipass": {
           "version": "2.3.5",
           "bundled": true,
           "dev": true,
-          "optional": true,
           "requires": {
             "safe-buffer": "^5.1.2",
             "yallist": "^3.0.0"
@@ -4507,7 +4492,6 @@
           "version": "0.5.1",
           "bundled": true,
           "dev": true,
-          "optional": true,
           "requires": {
             "minimist": "0.0.8"
           }
@@ -4588,8 +4572,7 @@
         "number-is-nan": {
           "version": "1.0.1",
           "bundled": true,
-          "dev": true,
-          "optional": true
+          "dev": true
         },
         "object-assign": {
           "version": "4.1.1",
@@ -4601,7 +4584,6 @@
           "version": "1.4.0",
           "bundled": true,
           "dev": true,
-          "optional": true,
           "requires": {
             "wrappy": "1"
           }
@@ -4687,8 +4669,7 @@
         "safe-buffer": {
           "version": "5.1.2",
           "bundled": true,
-          "dev": true,
-          "optional": true
+          "dev": true
         },
         "safer-buffer": {
           "version": "2.1.2",
@@ -4724,7 +4705,6 @@
           "version": "1.0.2",
           "bundled": true,
           "dev": true,
-          "optional": true,
           "requires": {
             "code-point-at": "^1.0.0",
             "is-fullwidth-code-point": "^1.0.0",
@@ -4744,7 +4724,6 @@
           "version": "3.0.1",
           "bundled": true,
           "dev": true,
-          "optional": true,
           "requires": {
             "ansi-regex": "^2.0.0"
           }
@@ -4788,14 +4767,12 @@
         "wrappy": {
           "version": "1.0.2",
           "bundled": true,
-          "dev": true,
-          "optional": true
+          "dev": true
         },
         "yallist": {
           "version": "3.0.3",
           "bundled": true,
-          "dev": true,
-          "optional": true
+          "dev": true
         }
       }
     },
@@ -5750,8 +5727,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",
@@ -11026,8 +11002,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",

+ 2 - 2
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)
@@ -856,7 +856,7 @@
 						userToken: this.token
 					}
 				};
-				this.get("api" + this.$ports.FastReply.userWords, obj).then(res => {
+				this.$http.get(this.$ports.FastReply.userWords, obj).then(res => {
 					if (res.data.code == 1) {
 						this.FastReply = res.data.data;
 					}

+ 41 - 0
service/static/paste.js

@@ -0,0 +1,41 @@
+// (function(){
+    var imgReader = function( item ){
+      var blob = item.getAsFile(),
+        reader = new FileReader();
+      // 读取文件后将其显示在网页中
+      reader.onload = function( e ){
+        var img = new Image();
+   
+        img.src = e.target.result;
+        document.body.appendChild( img );
+      };
+      // 读取文件
+      reader.readAsDataURL( blob );
+    };
+    document.getElementById( 'input' ).addEventListener( 'paste', function( e ){
+       // 添加到事件对象中的访问系统剪贴板的接口
+      var clipboardData = e.clipboardData,
+        i = 0,
+        items, item, types;
+   
+      if( clipboardData ){
+        items = clipboardData.items;
+        if( !items ){
+          return;
+        }
+        item = items[0];
+        // 保存在剪贴板中的数据类型
+        types = clipboardData.types || [];
+        for( ; i < types.length; i++ ){
+          if( types[i] === 'Files' ){
+            item = items[i];
+            break;
+          }
+        }
+        // 判断是否为图片数据
+        if( item && item.kind === 'file' && item.type.match(/^image\//i) ){
+          imgReader( item );
+        }
+      }
+    });
+//   })(); 

+ 63 - 24
service/static/publicMethods.js

@@ -1,3 +1,4 @@
+import frceArr from './frce';
 export default {
     //获取图片
     imgPreview(file, callback) {
@@ -17,7 +18,7 @@ export default {
               let formData = new FormData();
               img.src = result;
               img.onload = function() {
-                  let data = self.compress(img,name);
+                  let data = self.compress(img);
                   let blob = self.dataURItoBlob(data);
                   formData.append("file", blob,name+'.jpeg');
                   //图片预览,配置文件,formData数据;
@@ -92,15 +93,17 @@ export default {
         minute = minute < 10 ? ('0' + minute) : minute;
         second = second < 10 ? ('0' + second) : second;
         if (isDtae == 0){
-        return y + custom + m //+'student';
+            return y + custom + m //+'student';
         }else if (isDtae ==1){
-        return y + custom + m + custom + d;
+            return y + custom + m + custom + d;
+        }else if(isDtae == 3){
+            return  h + ':' + minute //+ ':' + second;
         }else{
-        return y + '-' + m + '-' + d + ' ' + h + ':' + minute //+ ':' + second;
+            return y + '-' + m + '-' + d + ' ' + h + ':' + minute //+ ':' + second;
         }
     },
 
-    /*****************屏蔽关键字******************/
+    /*****************提示关键字及记录次数******************/
     /**
      * 
      * @param {*} data 
@@ -113,16 +116,9 @@ export default {
         let num = 0,text='';
         //匹配出会话中的敏感词
          data.replace(eval('/' + snstive + '/g'), (res) => {
-            // var str = '';
-            console.log(res)
             text +=','+res;
-            // for (var i = 0; i < res.length; i++) {
-            //     str += '*';
-            // }
             num ++;
-            // return str;
         })
-
         return {
             text,
             num
@@ -165,10 +161,17 @@ export default {
     * @param {function} callback1   访客正常链接回调方法
     */
    visitorsConnect([redata,offlineList,sessionList,sessionType,dataIndex,dataList,user_name],callback,callback1){
+        // console.log('将会话工单写入访客信息',redata);
+        // console.log('访客信息评价',evaluate);
+        if(redata.evaluate_id > 0){
+            redata.user_info.isEva = 10;
+        }
         //将会话工单写入访客信息
         redata.user_info.conversationId = redata.conversationId;
         //默认离线列表没有访客信息
         let isTrue = true;
+        let name ='';
+        let sessionInfo  = '';
 
         //匹配是否是离线用户上线
         if(offlineList.length > 0){
@@ -177,35 +180,40 @@ export default {
                 if(offlineList[i].id == redata.user_info.id  ){
                     //查询离线列表是否有此用户会话工单未结束
                     if(offlineList[i].conversationId  ==  redata.conversationId){
+                        // console.log(sessionType,offlineList);
                         //工单号未结束的数据获取历史聊天消息和对象名字
                         if(sessionType == 2 && i == dataIndex){//客服选中离线重新链接访客
                             dataList = [];
                             dataList = offlineList[i].data;
-                            user_name  = offlineList[i].name;
+                            name  =  offlineList[i].nick_name ? offlineList[i].nick_name : offlineList[i].name;
                             sessionType = 1;
                             dataIndex = sessionList.length == 0 ? 0 : sessionList.length-1;
                         }else if(sessionType == 2 && i < dataIndex){//客服选中离线列表重新链接访客后面的访客
                             if(i > 0){
                                 dataList = offlineList[i].data;
-                                user_name  = offlineList[i].name;
+                                name  = offlineList[i].nick_name ? offlineList[i].nick_name : offlineList[i].name;
                             }
+                        }else {
+                            name = redata.user_info.nick_name ? redata.user_info.nick_name : redata.user_info.name;
                         }
                         //将掉线前聊天消息写入到用户对象里面
                         redata.user_info.data = offlineList[i].data;
                     }else{
                         //工单号已结束数据处理
                         if(dataIndex == 0 && sessionList.length  == 0){
-                            user_name = redata.user_info.name;
+                            name =redata.user_info.nick_name ? redata.user_info.nick_name : redata.user_info.name;
                             dataList = [];
                         }
                         redata.user_info.data = [];
                     }
+                    //获取离线列表数据
+                    sessionInfo = offlineList[i]
                     //将离线状态用户删除
                     offlineList.splice(i,1);
-
+                    
+                    isTrue = false;
                     //回调
                     callback && callback(offlineList);
-                    isTrue = false;
                     break;
                 }
             }
@@ -216,14 +224,16 @@ export default {
             if(sessionList.length  == 0){
                 //判断是否选离线用户列表
                 if(offlineList.length > 0 && sessionType ==2){
-                //不做处理
+                    //不做处理
+                    
                 }else{
-                    dataIndex = 0
-                    sessionType = 1
-                    user_name = redata.user_info.name;
+                    dataIndex = 0;
+                    sessionType = 1;
+                    // console.log(redata.user_info.nick_name,redata.user_info.name);
+                    name = redata.user_info.nick_name ? redata.user_info.nick_name : redata.user_info.name ;
                     dataList = [];
                 }
-            }else{
+            }else{ 
                 for(let i = 0; i < sessionList.length; i++){
                     //匹配离线列表是否有这个用户
                     if(sessionList[i].id == redata.user_info.id  ){
@@ -231,11 +241,38 @@ export default {
                         break;
                     }
                 }
+
+                //判断接入用户是否有昵称展示
+                redata.user_info.name = redata.user_info.nick_name ? redata.user_info.nick_name : redata.user_info.name ;
+            }
+            //历史会话消息
+            if(redata.history.length > 0){
+                let chatData= [];
+                redata.history.forEach(e=>{
+                    let content = JSON.parse(e.content);
+                    let obj = {
+                        text:this.turnFace(content.text,frceArr.frce) ,
+                        img: content.img,
+                        type: false,
+                    };
+                    if( e.from_id.startsWith("KF")){
+                        //this.turnFace(redata.content.text,frceArr.frce);
+                        chatData.push({type: 'service', content: obj, time:this.customFormatDateTime(e.time_line,'',3)})
+                    }else{
+                        chatData.push({type: 'user', content: obj, time:this.customFormatDateTime(e.time_line,'',3)})
+                    }
+                })           
+                redata.user_info.data = chatData;
+                dataList = chatData;
+            }else{
+                redata.user_info.data = [];
             }
-            redata.user_info.data = [];
+        }else{
+            redata.user_info.data = sessionInfo.data
         }
+        // console.log(name);
         //回调
-        callback1 && callback1(redata,sessionList,offlineList,sessionType,dataIndex,dataList,user_name);
+        callback1 && callback1(redata,sessionList,offlineList,sessionType,dataIndex,dataList,name);
     },
 
     /*****************用户会话离线及相关数据*********************/
@@ -299,6 +336,7 @@ export default {
     sessionEnd([redata,sessionList,offlineList,sessionType,dataIndex,user_name,dataList],callback){
         let isTrue = true;
         let userInfo = [];
+        // console.log('哈哈',sessionList);
         //会话中列表匹配
         if(sessionList.length > 0){
             for(let i = 0 ; i < sessionList.length; i++){
@@ -369,6 +407,7 @@ export default {
                 }
             }
         }
+        console.log('测试掉线',sessionList);
         //回调
         callback && callback(sessionList,offlineList,sessionType,dataIndex,user_name,dataList,userInfo);