Ethan 6 سال پیش
والد
کامیت
4b6c6e05f9

+ 1 - 0
application/admin/config.php

@@ -8,6 +8,7 @@ return [
         '__JS__'  => '/static/admin/js',
         '__IMG__' => '/static/admin/images',
         '__EDIT__' => '/static/kindeditor',
+        '__ENTRANCE__' => '/static/entranceJs',
     ],
 
     // 客服状态

+ 208 - 64
application/admin/controller/Settings.php

@@ -9,20 +9,76 @@ namespace app\admin\controller;
 class Settings extends Base
 {
     // 访客端入口列表
+    public function entranceList()
+    {
+        if(request()->isAjax()){
+            // 查询目录下所有文件
+            $files = $this->allFile(ROOT_PATH.'entranceJs/new');
+            $filesInfo = [];
+            foreach ($files as $v) {
+                $addTime = filemtime(ROOT_PATH."entranceJs/new/$v");
+                $lastLoad = fileatime(ROOT_PATH."entranceJs/new/$v");
+                $filesInfo[] = (object)[
+                    'fileName' => $v,
+                    'addTime' => date("Y-m-d H:i:s",$addTime),
+                    'lastLoad' => date("Y-m-d H:i:s",$lastLoad),
+                    'operate' => $this->fileBtn($v),
+                ];
+            }
+            $return = (object)[
+                'total' => count($filesInfo),
+                'rows' => $filesInfo,
+            ];
+            return json($return);
+        }
+
+        return $this->fetch('entrancelist');
+    }
+    // 访客端入口新增
     public function index()
     {
+        if(request()->isPost()){
+            $param = input('post.');
+            $name = $param['name'];
+            // 查询目录下所有文件
+            $files = $this->allFile(ROOT_PATH.'entranceJs/new');
+            $have = 0;
+            // 判断是否存在该文件.
+            foreach ($files as $v) {
+                $fileName = substr($v,0,strpos($v, '.'));
+                if ($fileName == $name) {
+                    $have = 1;
+                    break;
+                }
+            }
+            if ($have) {
+                return json(['code' => -2, 'data' => '', 'msg' => '文件名已存在']);
+            }
+            $result = db('guestenter')->order('sort','asc')->select();
+            $copy = $this->file2dir(ROOT_PATH.'entranceJs/FloatingButton.js',ROOT_PATH.'entranceJs/new/', $name.'.js');
+            $result[] = (object)[
+                "margin_top" => $param['marginTop'],
+                "stop_time" => $param['overtime'],
+                "copywriting" => $param['overtimeInfo'],
+            ];
+            $data = json_encode($result);
+            if ($copy) {
+                $dataArr = ["data = $data;"];
+                $result = $this->UpdataFile(ROOT_PATH.'entranceJs/new/'.$name.'.js', $dataArr, 24, 24, false);
+                if ($result) {
+                    return json(['code' => 1, 'data' => 'settings/index', 'msg' => '入口添加成功']);
+                } else {
+                    return json(['code' => -2, 'data' => '', 'msg' => '操作失败']);
+                }
+            } else {
+                return json(['code' => -2, 'data' => '', 'msg' => '操作失败']);
+            }
+        }
         if(request()->isAjax()){
             $param  = input('param.');
             $limit  = $param['pageSize'];
             $offset = (($param['pageNumber'] - 1) * $limit);
             $where = [];
-//            if (empty($param['searchText']) === false || intval($param['searchText']) == 0) {
-//                $where['user_account|user_name|user_job_number|fullname'] = ['like', '%' . $param['searchText'] . '%'];
-//            }
-            //客服组
-//            if ($param['group_id'] != '' && $param['group_id'] != 0) {
-//                $where['group_id'] = $param['group_id'];
-//            }
             $result = db('guestenter')->where($where)->limit($offset, $limit)->order('sort', 'asc')->select();
             //客服组
             $group = db('groups')->select();
@@ -58,53 +114,48 @@ class Settings extends Base
 
         return $this->fetch();
     }
-
-    // 添加访客端入口
+    // 访客端入口列表
     public function add()
     {
-        if(request()->isPost()){
+        if(request()->isAjax()){
+            $param  = input('param.');
+            $limit  = $param['pageSize'];
+            $offset = (($param['pageNumber'] - 1) * $limit);
+            $where = [];
+            $result = db('guestenter')->where($where)->limit($offset, $limit)->order('sort', 'asc')->select();
+            //客服组
+            $group = db('groups')->select();
+            foreach($result as $key=>$vo){
+                // 优化显示头像
+                $result[$key]['image'] = '<img src="' . $vo['image'] . '" height="40px">';
 
-            $param = input('post.');
-            unset($param['file']); // 删除layui头像上传隐藏字段
-            // 检测账号
-            if(!empty($param['name'])){
-                $user = db('guestenter')->where('name', $param['name'])->find();
-                if(!empty($user)){
-                    return json(['code' => -1, 'data' => '', 'msg' => '该名称已存在']);
+                if($vo['group_id'] == 'all'){
+                    $result[$key]['user_group'] = '所有客服组';
+                }
+                for($i=0;$i<count($group);$i++){
+                    if($vo['group_id'] == $group[$i]['id']){
+                        $result[$key]['user_group'] = $group[$i]['name'];
+                    }
                 }
-            }
-
-            if(strlen($param['name'])>12) {
-                return json(['code' => -8, 'data' => '', 'msg' => '名称字数超过限制']);
-            }
 
-            if(!is_numeric($param['sort'])) {
-                return json(['code' => -6, 'data' => '', 'msg' => '排序未输入整数']);
+                // 生成操作按钮
+                $result[$key]['operate'] = $this->makeBtn($vo['id']);
             }
 
-            if(empty($param['group_id'])){
-                return json(['code' => -3, 'data' => '', 'msg' => '请选择分组']);
-            }
-             //检测头像
-            if(empty($param['image'])){
-                return json(['code' => -4, 'data' => '', 'msg' => '请上传图片']);
-            }
+            $return['total'] = db('guestenter')->where($where)->count();  //总数据
+            $return['rows'] = $result;
 
-            try{
-                db('guestenter')->insert($param);
-            }catch(\Exception $e){
-                return json(['code' => -5, 'data' => '', 'msg' => $e->getMessage()]);
-            }
+            return json($return);
 
-            return json(['code' => 1, 'data' => 'settings/index', 'msg' => '添加功能菜单成功']);
         }
+        $settings = db('settings')->where('id',1)->find();
 
         $this->assign([
-            'groups' => db('groups')->select(),
+            'settings' => $settings,
             'status' => config('kf_status')
         ]);
 
-        return $this->fetch('add');
+        return $this->fetch();
     }
 
     // 编辑访客端入口
@@ -172,6 +223,30 @@ class Settings extends Base
         }
     }
 
+    // 删除访客端入口文件
+    public function delFile()
+    {
+        if(request()->isAjax()){
+            $fileName = input('param.fileName');
+
+            try{
+                unlink(ROOT_PATH."entranceJs/new/$fileName");
+            }catch(\Exception $e){
+                return json(['code' => -1, 'data' => '', 'msg' => $e->getMessage()]);
+            }
+
+            return json(['code' => 1, 'data' => '', 'msg' => '删除成功']);
+        }
+    }
+
+    /**
+     * 效果预览
+     */
+    function demo()
+    {
+        return $this->fetch();
+    }
+
     // 上传客服头像
     public function upAvatar()
     {
@@ -204,38 +279,107 @@ class Settings extends Base
         return $operate;
     }
 
-    //自动邀请设置
-    public function update(){
-        if(request()->isPost()){
-
-            $param = input('post.');
+    // 生成按钮
+    private function fileBtn($fileName)
+    {
 
-            $info['stop_time'] = $param['overtime'];
-            $info['copywriting'] = $param['overtimeInfo'];
+        $operate = '<a style="margin-left:5px;" href="javascript:DelFile(`' . $fileName . '`)"><button type="button" class="btn btn-danger btn-sm">';
+        $operate .= '<i class="fa fa-trash-o"></i> 删除</button></a> ';
 
-            try{
-                db('settings')->where('id', $param['id'])->update($info);
-            }catch(\Exception $e){
-                return json(['code' => -5, 'data' => 'settings/index', 'msg' => $e->getMessage()]);
+        return $operate;
+    }
+    //复制文件
+    function file2dir($sourcefile, $dir,$filename){
+        if( ! file_exists($sourcefile)){
+            return false;
+        }
+        //$filename = basename($sourcefile);
+        return copy($sourcefile, $dir .''. $filename);
+    }
+    // 获取文件夹下的文件.
+    function allFile($dir) {
+        $handle=opendir($dir);
+        $i=0;
+        $list = [];
+        while(!!$file = readdir($handle)) {
+            if (($file!=".")and($file!="..")) {
+                $list[$i]=$file;
+                $i=$i+1;
             }
-            return json(['code' => 1, 'data' => $this->redirect('settings/index'), 'msg' => '自动邀请设置成功']);
         }
+        closedir($handle);
+        return $list;
     }
 
-    //访客端入口上边距设置
-    public function margin(){
-        if(request()->isPost()){
-
-            $param = input('post.');
-
-            $info['margin_top'] = $param['margin-top'];
-
-            try{
-                db('settings')->where('id', $param['id'])->update($info);
-            }catch(\Exception $e){
-                return json(['code' => -6, 'data' => 'settings/index', 'msg' => $e->getMessage()]);
+    /**
+     * 修改文件
+     * @author GRACE
+     * @param $file       文件路径
+     * @param $arr        修改值数组
+     * @param $len        开始索引位置
+     * @param $end        结束索引位置 或 匹配 索引值
+     * @param bool $loke  文件为空时,是否添加 <?php 头
+     */
+    function UpdataFile ($file, $arr, $len, $end, $loke = true)
+    {
+        if (is_dir($file)) {
+            exit($file. '请传入正确的文件路径');
+        }
+        if (is_file($file)) {
+            // 判断是否是常规文件
+            if (is_readable($file)) {
+                // 文件是否可读
+                if (is_writable($file)) {
+                    // 文件是否可写
+                    $fp = file($file);
+                    // 以数据的方式读取文件
+                    if (!empty($fp)) {
+                        $lokes = true;
+                        $arr1 = [];
+                        // 接收前半部分
+                        $arr2 = [];
+                        // 接收后半部分
+                        foreach ($fp as $k => $v) {
+                            if ($k >= $len && $lokes) {
+                                if (is_int($end)) {
+                                    if ($k == $end) {
+                                        $lokes = false;
+                                    }
+                                } else {
+                                    if (trim($v) == $end) {
+                                        $arr2[] = $v; $lokes = false;
+                                    }
+                                }
+                            } else {
+                                if ($lokes) {
+                                    $arr1[] = $v;
+                                } else {
+                                    $arr2[] = $v;
+                                }
+                            }
+                        }
+                        $arr3 = join('', $arr1).join(PHP_EOL, $arr).PHP_EOL.join('', $arr2);
+                        if (file_put_contents($file, $arr3)) {
+                            return '修改成功';
+                        } else {
+                            return '修改失败';
+                        }
+                    } else {
+                        if ($loke) {
+                            $a = '<?php'.PHP_EOL; $a.= join(PHP_EOL, $arr).PHP_EOL; file_put_contents($file, $a, FILE_APPEND);
+                        } else {
+                            $a = join(PHP_EOL, $arr).PHP_EOL; file_put_contents($file, $a, FILE_APPEND);
+                        }
+                    }
+                } else {
+                    exit($file. 'The file is not writable');
+                }
+            } else {
+                exit($file. ' is not a regular file');
             }
-            return json(['code' => 1, 'data' => $this->redirect('settings/index'), 'msg' => '自动邀请设置成功']);
+        } else {
+            exit($file. ' is not a regular file');
         }
     }
+
 }

+ 241 - 0
application/admin/controller/SettingsOld.php

@@ -0,0 +1,241 @@
+<?php
+/**
+ * User: nickbai
+ * Date: 2017/10/23 13:33
+ * Email: 1902822973@qq.com
+ */
+namespace app\admin\controller;
+
+class Settings extends Base
+{
+    // 访客端入口列表
+    public function index()
+    {
+        if(request()->isAjax()){
+            $param  = input('param.');
+            $limit  = $param['pageSize'];
+            $offset = (($param['pageNumber'] - 1) * $limit);
+            $where = [];
+//            if (empty($param['searchText']) === false || intval($param['searchText']) == 0) {
+//                $where['user_account|user_name|user_job_number|fullname'] = ['like', '%' . $param['searchText'] . '%'];
+//            }
+            //客服组
+//            if ($param['group_id'] != '' && $param['group_id'] != 0) {
+//                $where['group_id'] = $param['group_id'];
+//            }
+            $result = db('guestenter')->where($where)->limit($offset, $limit)->order('sort', 'asc')->select();
+            //客服组
+            $group = db('groups')->select();
+            foreach($result as $key=>$vo){
+                // 优化显示头像
+                $result[$key]['image'] = '<img src="' . $vo['image'] . '" height="40px">';
+
+                if($vo['group_id'] == 'all'){
+                    $result[$key]['user_group'] = '所有客服组';
+                }
+                for($i=0;$i<count($group);$i++){
+                    if($vo['group_id'] == $group[$i]['id']){
+                        $result[$key]['user_group'] = $group[$i]['name'];
+                    }
+                }
+
+                // 生成操作按钮
+                $result[$key]['operate'] = $this->makeBtn($vo['id']);
+            }
+
+            $return['total'] = db('guestenter')->where($where)->count();  //总数据
+            $return['rows'] = $result;
+
+            return json($return);
+
+        }
+        $settings = db('settings')->where('id',1)->find();
+
+        $this->assign([
+            'settings' => $settings,
+            'status' => config('kf_status')
+        ]);
+
+        return $this->fetch();
+    }
+
+    // 添加访客端入口
+    public function add()
+    {
+        if(request()->isPost()){
+
+            $param = input('post.');
+            unset($param['file']); // 删除layui头像上传隐藏字段
+            // 检测账号
+            if(!empty($param['name'])){
+                $user = db('guestenter')->where('name', $param['name'])->find();
+                if(!empty($user)){
+                    return json(['code' => -1, 'data' => '', 'msg' => '该名称已存在']);
+                }
+            }
+
+            if(strlen($param['name'])>12) {
+                return json(['code' => -8, 'data' => '', 'msg' => '名称字数超过限制']);
+            }
+
+            if(!is_numeric($param['sort'])) {
+                return json(['code' => -6, 'data' => '', 'msg' => '排序未输入整数']);
+            }
+
+            if(empty($param['group_id'])){
+                return json(['code' => -3, 'data' => '', 'msg' => '请选择分组']);
+            }
+             //检测头像
+            if(empty($param['image'])){
+                return json(['code' => -4, 'data' => '', 'msg' => '请上传图片']);
+            }
+
+            try{
+                db('guestenter')->insert($param);
+            }catch(\Exception $e){
+                return json(['code' => -5, 'data' => '', 'msg' => $e->getMessage()]);
+            }
+
+            return json(['code' => 1, 'data' => 'settings/index', 'msg' => '添加功能菜单成功']);
+        }
+
+        $this->assign([
+            'groups' => db('groups')->select(),
+            'status' => config('kf_status')
+        ]);
+
+        return $this->fetch('add');
+    }
+
+    // 编辑访客端入口
+    public function edit()
+    {
+        if(request()->isAjax()){
+
+            $param = input('post.');
+            unset($param['file']); // 删除layui头像上传隐藏字段
+
+            if(strlen($param['name'])>12) {
+                return json(['code' => -8, 'data' => '', 'msg' => '名称字数超过限制']);
+            }
+
+            if(!is_numeric($param['sort'])) {
+                return json(['code' => -6, 'data' => '', 'msg' => '排序未输入整数']);
+            }
+
+            if(empty($param['group_id'])){
+                return json(['code' => -2, 'data' => '', 'msg' => '请选择分组']);
+            }
+
+            $name = db('guestenter')->where('name',$param['name'])->where('id','<>',$param['id'])->select();
+            if(!empty($name)){
+                return json(['code' => -3, 'data' => '', 'msg' => '此名称已存在']);
+            }
+
+            $info = array();
+            $info['name'] = $param['name'];
+            $info['image'] = $param['image'];
+            $info['group_id'] = $param['group_id'];
+            $info['sort'] = $param['sort'];
+
+            try{
+                db('guestenter')->where('id', $param['id'])->update($info);
+            }catch(\Exception $e){
+                return json(['code' => -6, 'data' => '', 'msg' => $e->getMessage()]);
+            }
+            return json(['code' => 1, 'data' => 'settings/index', 'msg' => '编辑功能菜单成功']);
+        }
+        $id = input('param.id/d');
+        $info = db('guestenter')->where('id', $id)->find();
+
+        $this->assign([
+            'info' => $info,
+            'status' => config('kf_status'),
+            'groups' => db('groups')->select()
+        ]);
+        return $this->fetch('edit');
+    }
+
+    // 删除访客端入口
+    public function del()
+    {
+        if(request()->isAjax()){
+            $id = input('param.id/d');
+
+            try{
+                db('guestenter')->where('id', $id)->delete();
+            }catch(\Exception $e){
+                return json(['code' => -1, 'data' => '', 'msg' => $e->getMessage()]);
+            }
+
+            return json(['code' => 1, 'data' => '', 'msg' => '删除功能菜单成功']);
+        }
+    }
+
+    // 上传客服头像
+    public function upAvatar()
+    {
+        if(request()->isAjax()) {
+
+            $file = request()->file('file');
+            if (!empty($file)) {
+                // 移动到框架应用根目录/public/uploads/ 目录下
+                $info = $file->move(ROOT_PATH . 'public' . DS . 'uploads');
+                if ($info) {
+                    $src = '/uploads' . '/' . date('Ymd') . '/' . $info->getFilename();
+                    return json(['code' => 0, 'data' => ['src' => $src], 'msg' => 'ok']);
+                } else {
+                    // 上传失败获取错误信息
+                    return json(['code' => -1, 'data' => '', 'msg' => $file->getError()]);
+                }
+            }
+        }
+    }
+
+    // 生成按钮
+    private function makeBtn($id)
+    {
+        $operate = '<a style="margin-left:5px;" href="' . url('settings/edit', ['id' => $id]) . '">';
+        $operate .= '<button type="button" class="btn btn-primary btn-sm"><i class="fa fa-paste"></i> 编辑</button></a> ';
+
+        $operate .= '<a style="margin-left:5px;" href="javascript:Del(' . $id . ')"><button type="button" class="btn btn-danger btn-sm">';
+        $operate .= '<i class="fa fa-trash-o"></i> 删除</button></a> ';
+
+        return $operate;
+    }
+
+    //自动邀请设置
+    public function update(){
+        if(request()->isPost()){
+
+            $param = input('post.');
+
+            $info['stop_time'] = $param['overtime'];
+            $info['copywriting'] = $param['overtimeInfo'];
+
+            try{
+                db('settings')->where('id', $param['id'])->update($info);
+            }catch(\Exception $e){
+                return json(['code' => -5, 'data' => 'settings/index', 'msg' => $e->getMessage()]);
+            }
+            return json(['code' => 1, 'data' => $this->redirect('settings/index'), 'msg' => '自动邀请设置成功']);
+        }
+    }
+
+    //访客端入口上边距设置
+    public function margin(){
+        if(request()->isPost()){
+
+            $param = input('post.');
+
+            $info['margin_top'] = $param['margin-top'];
+
+            try{
+                db('settings')->where('id', $param['id'])->update($info);
+            }catch(\Exception $e){
+                return json(['code' => -6, 'data' => 'settings/index', 'msg' => $e->getMessage()]);
+            }
+            return json(['code' => 1, 'data' => $this->redirect('settings/index'), 'msg' => '自动邀请设置成功']);
+        }
+    }
+}

+ 49 - 1
application/admin/controller/System.php

@@ -119,7 +119,7 @@ class System extends Base
                 return json(['code' => -2, 'data' => '', 'msg' => $e->getMessage()]);
             }
 
-            return json(['code' => 1, 'data' => '', 'msg' => '编辑智能问答成功']);
+            return json(['code' => 1, 'data' => '', 'msg' => '编辑成功']);
         }
 
         $id                     = input('param.id');
@@ -133,6 +133,54 @@ class System extends Base
 
     }//end editWelcome()
 
+    /**
+     * 新增系统欢迎语
+     *
+     * @access public
+     */
+    public function delWelcome()
+    {
+        if (request()->isAjax()) {
+            $id = input('param.id');
+            $where['id'] = $id;
+
+            try {
+                model('Reply')->delReply($where);
+            } catch (\Exception $e) {
+                return json(['code' => -1, 'data' => '', 'msg' => $e->getMessage()]);
+            }
+
+            return json(['code' => 1, 'data' => '', 'msg' => '删除成功']);
+        }
+    }
+
+    /**
+     * 新增系统欢迎语
+     *
+     * @access public
+     */
+    public function addWelcome()
+    {
+        if(request()->isAjax()){
+            $param = input('post.');
+            $data['sort'] = $param['sort'];
+            $data['word'] = htmlspecialchars($param['word']);
+            $data['status'] = 1;
+            $data['type'] = 1;
+
+            try{
+                model('Reply')->addReply($data);
+            }catch(\Exception $e){
+                return json(['code' => -2, 'data' => '', 'msg' => $e->getMessage()]);
+            }
+
+            return json(['code' => 1, 'data' => '', 'msg' => '新增成功']);
+        }
+
+        return $this->fetch('addwelcome');
+
+    }//end addWelcome()
+
 
     /**
      * 会话设置

+ 30 - 0
application/admin/model/Reply.php

@@ -40,6 +40,36 @@ class Reply extends Model
     }//end selectReply()
 
 
+    /**
+     * 新增数据
+     *
+     * @access public
+     * @param mixed $data 数据
+     * @return array 返回类型
+     */
+    public function addReply($data)
+    {
+        $result = $this->insert($data);
+        return $result;
+
+    }//end addReply()
+
+
+    /**
+     * 删除数据筛选
+     *
+     * @access public
+     * @param mixed $where 条件
+     * @return array 返回类型
+     */
+    public function delReply($where)
+    {
+        $result = $this->where($where)->delete();
+        return $result;
+
+    }//end delReply()
+
+
     /**
      * 数据修改
      *

+ 1 - 0
application/admin/view/accounts/addlabel.html

@@ -10,6 +10,7 @@
     <link href="__CSS__/animate.min.css" rel="stylesheet">
     <link href="__JS__/layui/css/layui.css" rel="stylesheet">
     <link href="__CSS__/style.min.css?v=4.1.0" rel="stylesheet">
+    <script src="../../../../entranceJs/FloatingButton.js"></script>
 </head>
 <body class="gray-bg">
 <div class="wrapper wrapper-content animated fadeInRight">

+ 188 - 0
application/admin/view/settings/demo.html

@@ -0,0 +1,188 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <meta charset="utf-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>效果展示</title>
+</head>
+<body class="gray-bg">
+<script type="text/javascript">
+  var xmlhttp=new XMLHttpRequest();
+  var data = [];//配置信息
+  var appip_source = '';
+  var appuip_user = '999';
+  var isIE=!!window.ActiveXObject;    //是否IE浏览器
+  var isIE6=isIE&&!window.XMLHttpRequest;  //是否IE6浏览器
+  var isIE7=isIE&&!isIE6&&!isIE8;  //是否IE7浏览器
+  var isIE8=isIE&&!!document.documentMode;  //是否IE8浏览器
+  var availheight = screen.availHeight;   //默认高度为屏幕的高度
+  var hostname = location.protocol+'//'+location.host;
+  var adminDomain = 'http://kfadmin.bocai186.com';   //服务器域名
+  var serverDomain = 'http://kefu.bocai186.com';   //客服域名
+  var userDomain = 'http://kf.bocai186.com';   //用户域名
+  if(isIE8){
+    availheight= screen.height;
+  }
+  //IE11升级弹出窗口小
+  if (!!window.ActiveXObject || "ActiveXObject" in window){
+    availheight= screen.height;
+  }
+  function getQueryVariable(variable)
+  {
+    var query = window.location.search.substring(1);
+    var vars = query.split("&");
+    for (var i=0;i<vars.length;i++) {
+      var pair = vars[i].split("=");
+      if(pair[0] == variable){return pair[1];}
+    }
+    return(false);
+  }
+
+  var div = document.createElement('div');
+
+  //ajax获取浮动按钮和提示配置信息
+  xmlhttp.open("GET",hostname+"/service/Index/getGuestEnter?t="+ Math.random(),true);
+  xmlhttp.send();
+  var runTime = getQueryVariable('runTime');
+  var runContent = decodeURI(getQueryVariable('runContent'));
+  var distance = getQueryVariable('distance');
+  xmlhttp.onreadystatechange=function(){
+    if (xmlhttp.readyState == 4 && xmlhttp.status == 200){
+      console.log(JSON.parse(xmlhttp.responseText));
+      let res = JSON.parse(xmlhttp.responseText);
+      if(res.code == 1 ){
+        data = res.data;
+        //浮动按钮样式
+        div.style= `position: fixed; right:15px; top:${distance}px;width:80px;background: #867c7c00;border-radius: 10px 0 0 10px;
+            display:flex;flex-direction: column; justify-content: space-between;`;
+        div.style.height = 80*(data.length)+'px';
+        //拼接浮动按钮样式
+        let btn_html ='';
+        for(let i = 0 ;i<data.length-1;i++){
+          btn_html += `<div id='set_user_info_${data[i].group_id}' style="width:80px;height:80px;background:#9a949775;display:flex;
+                flex-direction: column;justify-content: center;align-items: center; cursor:pointer;z-index:1000; ">
+                <img  id='set_user_img_${data[i].group_id}'src='${data[i].image}'></img>
+                <span id='set_user_span_${data[i].group_id}' style="font-size:12px;font-weight:bold; color: #f0f0f0;">${data[i].name}</span> </div>`;
+        }
+        div.innerHTML = btn_html;
+      }
+      //延时显示提示框
+      setTimeout(function(){
+        create_prompt_box();
+      }, runTime*1000);
+    }
+  }
+
+  /***
+   * 打开会话窗口
+   */
+  div.onclick =function(e){
+    console.log(window.location.href)
+    var index=e.target.id.lastIndexOf("_");
+    // console.log(e.target,index);
+    var group_id  = e.target.id.substring(index+1,e.target.id.length);
+    console.log(window);
+    if(group_id != 'all'){
+      openWindowCenter(userDomain+"?appid="+appip_source+"&appuid="+appuip_user+'&group_id='+group_id,700,700);
+    }else{
+      openWindowCenter(userDomain+"/?appid="+appip_source+"&appuid="+appuip_user,700,700);
+    }
+  }
+  //将浮动按钮添加到对应到网站body上
+  document.body.appendChild(div);
+
+
+
+  /**
+   * 提示框样式
+   */
+  function create_prompt_box(){
+    var popupWindowBox = document.createElement('div');
+    popupWindowBox.style = `position: fixed; top:35%; padding: 10px; left:45%;width:350px;height:160px;
+    background:#e5e5e5;border-radius:10px;font-size:17px;display:flex; flex-direction: column;
+    justify-content: space-between;z-index:9999;`;
+    //拼接提示框样式
+    popupWindowBox.innerHTML =`
+    <div style='display:flex;flex-direction: row;justify-content: center;'>
+    <span style="font-weight:bold; color: #666666;">${runContent}</span>
+    </div>
+    <div style='flex-direction: row;display:flex;justify-content: flex-end;'>
+    <div id="$startSession" style='margin-right: 10px; padding: 4px;border: 1px solid #999; border-radius: 4px; color: #666666;font-weight: bold;cursor:pointer;'>开始会话</div>
+    <div id="$cancel" style="padding: 3px;border: 1px solid #999; border-radius: 4px; color: #666666;font-weight: bold;cursor:pointer;">下次再说</div>
+    </div>
+    `;
+    popupWindowBox.onclick =function(e){
+      if(e.target.id == '$startSession'){
+        openWindowCenter(userDomain+"/?appid="+appip_source+"&appuid="+appuip_user,700,700);
+      }else if(e.target.id == '$cancel'){
+        popupWindowBox.style.display="none";
+      }
+    }
+
+
+    //将提示框添加到对应到网站body上
+    document.body.appendChild(popupWindowBox);
+  }
+
+  // padding: 3px;border: 1px solid #999; border-radius: 4px; color: #666666;font-weight: bold;
+
+  // /***
+  //  *
+  //  */
+  // function   (){
+
+  // }
+
+  /**
+   * 打开一个居中的窗口
+   * @param pageUrl url链接
+   * @param innerWidth 宽度,不带px,小于0表示百分比
+   * @param innerHeight 高度,不带px,小于0表示百分比
+   */
+  function openWindowCenter(pageUrl, innerWidth, innerHeight){
+    var screenWidth = screen.availWidth;
+    var screenHeight = screen.availHeight;
+    var width = screenWidth;
+    var height = screenHeight;
+
+    if(innerWidth < 1){
+      width = screenWidth * innerWidth;
+      screenWidth = (screen.availWidth - width)/2;
+    }else{
+      width = innerWidth;
+      screenWidth = (screen.availWidth - innerWidth)/2;
+    }
+    if(innerHeight < 1){
+      height = screenHeight * innerHeight;
+      screenHeight = (screen.availHeight - height)/2;
+    }else{
+      height = innerHeight;
+      screenHeight = (screen.availHeight - innerHeight)/2;
+    }
+    window.open(pageUrl, "", "left=" + screenWidth + ",top=" + screenHeight +",width=" + width + ",height=" + height + ",resizable=no,scrollbars=no,status=no,toolbar=no,menubar=no,location=no");
+  };
+
+
+  //html页面调用
+  /**
+   * 获取数据
+   */
+  function set_user_info_js(a,b){
+    appip_source = a;
+    appuip_user=b;
+  }
+
+  //vue调用
+  // export default {
+  //     /**
+  //      * 获取数据
+  //      */
+  //     set_user_info_vue: function (a,b){
+  //         appip_source = a;
+  //         appuip_user =b;
+  //     }
+  // }
+
+</script>
+</body>
+</html>

+ 189 - 0
application/admin/view/settings/entrancelist.html

@@ -0,0 +1,189 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <meta charset="utf-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>功能菜单</title>
+    <link rel="shortcut icon" href="favicon.ico">
+    <link href="__CSS__/bootstrap.min.css?v=3.3.6" rel="stylesheet">
+    <link href="__CSS__/font-awesome.min.css?v=4.4.0" rel="stylesheet">
+    <link href="__CSS__/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
+    <link href="__CSS__/animate.min.css" rel="stylesheet">
+    <link href="__CSS__/style.min.css?v=4.1.0" rel="stylesheet">
+    <link href="__JS__/layui/css/myLayui.css" rel="stylesheet">
+</head>
+<body class="gray-bg">
+<div class="wrapper wrapper-content animated fadeInRight">
+    <!-- Panel Other -->
+    <div class="ibox float-e-margins">
+        <div class="ibox-title">
+            <h5>接入文件列表</h5>
+        </div>
+        <div class="ibox-content">
+            <a href="/admin/settings/index.html" style="margin-top: -10px">
+                <button class="btn btn-primary" type="button" style="margin-top:5px"><strong>新增</strong>
+                </button>
+            </a>
+            <div class="example-wrap">
+                <div class="example">
+                    <table id="cusTable">
+                        <thead>
+                        <!--<th data-field="id">id</th>-->
+                        <th data-field="fileName">文件名称</th>
+                        <th data-field="addTime">生成时间</th>
+                        <th data-field="lastLoad">最后访问时间</th>
+                        <th data-field="operate">最后访问时间</th>
+                        </thead>
+                    </table>
+                </div>
+            </div>
+            <!-- End Example Pagination -->
+        </div>
+    </div>
+</div>
+<!-- End Panel Other -->
+<script src="__JS__/jquery.min.js?v=2.1.4"></script>
+<script src="__JS__/bootstrap.min.js?v=3.3.6"></script>
+<script src="__JS__/content.min.js?v=1.0.0"></script>
+<script src="__JS__/plugins/bootstrap-table/bootstrap-table.min.js"></script>
+<script src="__JS__/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script>
+<script src="__JS__/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
+<script src="__JS__/plugins/layer/layer.min.js"></script>
+<script src="__JS__/layui/layui.js"></script>
+<script src="__JS__/jquery.form.js"></script>
+<script type="text/javascript">
+    function goDemo() {
+      let runTime = $('#runTime').val();
+      let runContent = $('#runContent').val();
+      let distance = $('#distance').val();
+      window.open("/admin/Settings/demo.html?runTime="+runTime+"&runContent="+runContent+"&distance="+distance);
+    }
+
+    layui.use(['form', 'upload'], function(){
+        var form = layui.form;
+
+        form.on('select(group)', function(value){
+            $("#group_id").val(value.value);
+            onSearch()
+        });
+
+    });
+
+</script>
+<script type="text/javascript">
+    function initTable() {
+        //先销毁表格
+        $('#cusTable').bootstrapTable('destroy');
+        //初始化表格,动态从服务器加载数据
+        $("#cusTable").bootstrapTable({
+            method: "get",  //使用get请求到服务器获取数据
+            url: "{:url('settings/entranceList')}", //获取数据的地址
+            striped: true,  //表格显示条纹
+            pagination: false, //启动分页
+            pageSize: 50,  //每页显示的记录数
+            pageNumber:1, //当前第几页
+            pageList: [20, 50],  //记录数可选列表
+            sidePagination: "server", //表示服务端请求
+            paginationFirstText: "首页",
+            paginationPreText: "上一页",
+            paginationNextText: "下一页",
+            paginationLastText: "尾页",
+            queryParamsType : "undefined",
+            queryParams: function queryParams(params) {   //设置查询参数
+                var param = {
+                    pageNumber: params.pageNumber,
+                    pageSize: params.pageSize,
+                    group_id:$('#group_id').val(),
+                    searchText:$('#username').val()
+                };
+                return param;
+            },
+            onLoadSuccess: function(res){  //加载成功时执行
+                if(111 == res.code){
+                    window.location.reload();
+                }
+                layer.msg("加载成功", {time : 1000});
+            },
+            onLoadError: function(){  //加载失败时执行
+                layer.msg("加载数据失败");
+            }
+        });
+    }
+
+    $(document).ready(function () {
+        //调用函数,初始化表格
+        initTable();
+
+        //当点击查询按钮的时候执行
+        $("#search").bind("click", initTable);
+    });
+
+    function DelFile(fileName){
+        layer.confirm('确认删除此入口文件吗?', {icon: 3, title:'提示'}, function(index){
+            //do something
+            $.getJSON("{:url('settings/delFile')}", {'fileName' : fileName}, function(res){
+                if(1 == res.code){
+                    layer.alert(res.msg, {title: '友情提示', icon: 1, closeBtn: 0}, function(){
+                        initTable();
+                    });
+                }else if(111 == res.code){
+                    window.location.reload();
+                }else{
+                    layer.alert(res.msg, {title: '友情提示', icon: 2});
+                }
+            });
+            layer.close(index);
+        })
+    }
+    function showStart(){
+      index = layer.load(0, {shade: false});
+      return true;
+    }
+
+    function showSuccess(res){
+
+      layer.ready(function(){
+        layer.close(index);
+        if(1 == res.code){
+          layer.alert(res.msg, {title: '友情提示', icon: 1, closeBtn: 0}, function(){
+            window.location.href = '/admin/accounts/label.html';
+          });
+        }else if(111 == res.code){
+          window.location.reload();
+        }else{
+          layer.msg(res.msg, {anim: 6});
+        }
+      });
+    }
+
+    $(document).ready(function(){
+      // 添加菜单
+      var options = {
+        beforeSubmit:showStart,
+        success:showSuccess
+      };
+
+      $('#commentForm').submit(function(){
+        $(this).ajaxSubmit(options);
+        return false;
+      });
+    });
+
+    // 表单验证
+    $.validator.setDefaults({
+      highlight: function(e) {
+        $(e).closest(".form-group").removeClass("has-success").addClass("has-error")
+      },
+      success: function(e) {
+        e.closest(".form-group").removeClass("has-error").addClass("has-success")
+      },
+      errorElement: "span",
+      errorPlacement: function(e, r) {
+        e.appendTo(r.is(":radio") || r.is(":checkbox") ? r.parent().parent().parent() : r.parent())
+      },
+      errorClass: "help-block m-b-none",
+      validClass: "help-block m-b-none"
+    });
+</script>
+</body>
+</html>

+ 103 - 62
application/admin/view/settings/index.html

@@ -20,87 +20,72 @@
             <h5>接入设置</h5>
         </div>
         <div class="ibox-content">
-            <form class="form-horizontal m-t layui-form" id="Form" method="post" action="{:url('settings/update')}">
-                <h4 style="margin-bottom: 10px;">自动邀请设置</h4>
-                <div class="ibox-title">
+            <h4 style="margin-bottom: 10px;">入口设置</h4>
+            <div class="ibox-title" style="min-height: 0px;">
+            </div>
+            <a href="/admin/settings/add.html" style="margin-top: -10px">
+                <button class="btn btn-primary" type="button" style="margin-top:5px"><strong>新增入口</strong>
+                </button>
+            </a>
+            <div class="example-wrap">
+                <div class="example">
+                    <table id="cusTable">
+                        <thead>
+                        <!--<th data-field="id">id</th>-->
+                        <th data-field="name">名称</th>
+                        <th data-field="image">图片</th>
+                        <th data-field="user_group">关联客服组</th>
+                        <th data-field="sort">排序</th>
+                        <th data-field="operate">操作</th>
+                        </thead>
+                    </table>
+                </div>
+            </div>
+            <form class="form-horizontal m-t layui-form" id="commentForm" method="post" action="{:url('settings/index')}">
+                <h4 style="margin-bottom: 10px; margin-top: 40px;">自动邀请设置</h4>
+                <div class="ibox-title" style="min-height: 0px;">
                 </div>
                 <div class="form-group" style="flex-wrap: wrap; display: flex">
                     <p style="width: 100%; margin-left: 20px; color: #9c9c9c; margin-bottom: 15px; font-size: 15px;">访客访问网站时,系统可以自动发起会话邀请,默认0秒为不邀请。</p>
-                    <label class="col-sm-2 control-label">访问停留:</label>
+                    <label style="font-weight: 500;" class="col-sm-2 control-label">访问停留:</label>
                     <div class="input-group col-sm-1">
-                        <input type="hidden" name="id" value="{$settings['id']}">
-                        <input type="text" class="form-control" name="overtime" required="" aria-required="true" value="{$settings['stop_time']}">
+                        <input id="runTime" type="text" class="form-control" name="overtime" required="" aria-required="true" value="{$settings['stop_time']}">
                     </div>
-                    <label class="control-label" style="margin-left: 20px;">秒</label>
+                    <label style="font-weight: 500;" class="control-label" style="margin-left: 20px;">秒</label>
                 </div>
                 <div class="form-group" style="flex-wrap: wrap; display: flex">
-                    <label class="col-sm-2 control-label">发出邀请文案:</label>
+                    <label style="font-weight: 500;" class="col-sm-2 control-label">发出邀请文案:</label>
                     <div class="input-group col-sm-8">
-                        <input type="text" class="form-control" name="overtimeInfo" required="" aria-required="true" value="{$settings['copywriting']}">
+                        <input id="runContent" type="text" class="form-control" name="overtimeInfo" required="" aria-required="true" value="{$settings['copywriting']}">
                     </div>
                 </div>
-                <div class="form-group" style="margin-top: 40px;">
-                    <label class="col-sm-2 control-label"></label>
-                    <div class="input-group col-sm-4">
-                        <button class="btn btn-primary" type="submit">提交</button>
-                    </div>
+                <h4 style="margin-bottom: 10px; margin-top: 40px;">自动邀请设置</h4>
+                <div class="ibox-title" style="min-height: 0px;">
                 </div>
-            </form>
-
-            <h4 style="margin-bottom: 10px;">访客端入口设置</h4>
-            <div class="ibox-title">
-            </div>
-
-            <form class="form-horizontal m-t layui-form" id="marginForm" method="post" action="{:url('settings/margin')}">
                 <div class="form-group" style="flex-wrap: wrap; display: flex">
                     <p style="width: 100%; margin-left: 20px; color: #9c9c9c; margin-bottom: 15px; font-size: 15px;">访客端入口上边距设置</p>
-                    <label class="col-sm-2 control-label">上边距:</label>
+                    <label style="font-weight: 500;" class="col-sm-2 control-label">上边距:</label>
+                    <div class="input-group col-sm-1">
+                        <input id="distance" type="text" class="form-control" name="marginTop" required="" aria-required="true" value="{$settings['margin_top']}">
+                    </div>
+                    <label style="font-weight: 500;" class="control-label" style="margin-left: 20px;">px</label>
+                </div>
+                <h4 style="margin-bottom: 10px; margin-top: 40px;">JS设置</h4>
+                <div class="ibox-title" style="min-height: 0px;">
+                </div>
+                <div class="form-group" style="flex-wrap: wrap; display: flex">
+                    <label style="font-weight: 500;" class="col-sm-2 control-label">JS名:</label>
                     <div class="input-group col-sm-1">
-                        <input type="hidden" name="id" value="{$settings['id']}">
-                        <input type="text" class="form-control" name="margin-top" required="" aria-required="true" value="{$settings['margin_top']}">
+                        <input type="text" class="form-control" name="name" required="" aria-required="true">
                     </div>
-                    <label class="control-label" style="margin-left: 20px;">px</label>
                 </div>
                 <div class="form-group" style="margin-top: 40px;">
-                    <label class="col-sm-2 control-label"></label>
-                    <div class="input-group col-sm-4">
-                        <button class="btn btn-primary" type="submit">提交</button>
+                    <div class="input-group col-sm-4" style="margin-left: 20px;">
+                        <a class="btn btn-primary" onclick="goDemo()">预览</a>
+                        <button class="btn btn-primary" type="submit" style="margin-left: 20px;">提交</button>
                     </div>
                 </div>
             </form>
-
-            <a href="/admin/settings/add.html">
-                <button class="btn btn-primary" type="button" style="margin-top:5px"><strong>新增访客端入口</strong>
-                </button>
-            </a>
-            <!--搜索框开始-->
-            <!--<form id='commentForm' role="form" method="post" class="form-inline pull-right">-->
-                <!--<div class="content clearfix m-b">-->
-                    <!--<div class="form-group">-->
-                        <!--<label>功能菜单:</label>-->
-                        <!--<input type="text" class="form-control" id="username" name="user_name">-->
-                    <!--</div>-->
-                    <!--<div class="form-group">-->
-                        <!--<button class="btn btn-primary" type="button" style="margin-top:5px" id="search"><strong>搜 索</strong>-->
-                        <!--</button>-->
-                    <!--</div>-->
-                <!--</div>-->
-            <!--</form>-->
-            <!--搜索框结束-->
-            <div class="example-wrap">
-                <div class="example">
-                    <table id="cusTable">
-                        <thead>
-                        <!--<th data-field="id">id</th>-->
-                        <th data-field="name">名称</th>
-                        <th data-field="image">图片</th>
-                        <th data-field="user_group">关联客服组</th>
-                        <th data-field="sort">排序</th>
-                        <th data-field="operate">操作</th>
-                        </thead>
-                    </table>
-                </div>
-            </div>
             <!-- End Example Pagination -->
         </div>
     </div>
@@ -114,7 +99,14 @@
 <script src="__JS__/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
 <script src="__JS__/plugins/layer/layer.min.js"></script>
 <script src="__JS__/layui/layui.js"></script>
+<script src="__JS__/jquery.form.js"></script>
 <script type="text/javascript">
+    function goDemo() {
+      let runTime = $('#runTime').val();
+      let runContent = $('#runContent').val();
+      let distance = $('#distance').val();
+      window.open("/admin/Settings/demo.html?runTime="+runTime+"&runContent="+runContent+"&distance="+distance);
+    }
 
     layui.use(['form', 'upload'], function(){
         var form = layui.form;
@@ -136,7 +128,7 @@
             method: "get",  //使用get请求到服务器获取数据
             url: "{:url('settings/index')}", //获取数据的地址
             striped: true,  //表格显示条纹
-            pagination: true, //启动分页
+            pagination: false, //启动分页
             pageSize: 50,  //每页显示的记录数
             pageNumber:1, //当前第几页
             pageList: [20, 50],  //记录数可选列表
@@ -192,6 +184,55 @@
             layer.close(index);
         })
     }
+    function showStart(){
+      index = layer.load(0, {shade: false});
+      return true;
+    }
+
+    function showSuccess(res){
+
+      layer.ready(function(){
+        layer.close(index);
+        if(1 == res.code){
+          layer.alert(res.msg, {title: '友情提示', icon: 1, closeBtn: 0}, function(){
+            window.location.href = '/admin/settings/entranceList.html';
+          });
+        }else if(111 == res.code){
+          window.location.reload();
+        }else{
+          layer.msg(res.msg, {anim: 6});
+        }
+      });
+    }
+
+    $(document).ready(function(){
+      // 添加菜单
+      var options = {
+        beforeSubmit:showStart,
+        success:showSuccess
+      };
+
+      $('#commentForm').submit(function(){
+        $(this).ajaxSubmit(options);
+        return false;
+      });
+    });
+
+    // 表单验证
+    $.validator.setDefaults({
+      highlight: function(e) {
+        $(e).closest(".form-group").removeClass("has-success").addClass("has-error")
+      },
+      success: function(e) {
+        e.closest(".form-group").removeClass("has-error").addClass("has-success")
+      },
+      errorElement: "span",
+      errorPlacement: function(e, r) {
+        e.appendTo(r.is(":radio") || r.is(":checkbox") ? r.parent().parent().parent() : r.parent())
+      },
+      errorClass: "help-block m-b-none",
+      validClass: "help-block m-b-none"
+    });
 </script>
 </body>
 </html>

+ 197 - 0
application/admin/view/settings/indexOld.html

@@ -0,0 +1,197 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <meta charset="utf-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>功能菜单</title>
+    <link rel="shortcut icon" href="favicon.ico">
+    <link href="__CSS__/bootstrap.min.css?v=3.3.6" rel="stylesheet">
+    <link href="__CSS__/font-awesome.min.css?v=4.4.0" rel="stylesheet">
+    <link href="__CSS__/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
+    <link href="__CSS__/animate.min.css" rel="stylesheet">
+    <link href="__CSS__/style.min.css?v=4.1.0" rel="stylesheet">
+    <link href="__JS__/layui/css/myLayui.css" rel="stylesheet">
+</head>
+<body class="gray-bg">
+<div class="wrapper wrapper-content animated fadeInRight">
+    <!-- Panel Other -->
+    <div class="ibox float-e-margins">
+        <div class="ibox-title">
+            <h5>接入设置</h5>
+        </div>
+        <div class="ibox-content">
+            <form class="form-horizontal m-t layui-form" id="Form" method="post" action="{:url('settings/update')}">
+                <h4 style="margin-bottom: 10px;">自动邀请设置</h4>
+                <div class="ibox-title">
+                </div>
+                <div class="form-group" style="flex-wrap: wrap; display: flex">
+                    <p style="width: 100%; margin-left: 20px; color: #9c9c9c; margin-bottom: 15px; font-size: 15px;">访客访问网站时,系统可以自动发起会话邀请,默认0秒为不邀请。</p>
+                    <label class="col-sm-2 control-label">访问停留:</label>
+                    <div class="input-group col-sm-1">
+                        <input type="hidden" name="id" value="{$settings['id']}">
+                        <input type="text" class="form-control" name="overtime" required="" aria-required="true" value="{$settings['stop_time']}">
+                    </div>
+                    <label class="control-label" style="margin-left: 20px;">秒</label>
+                </div>
+                <div class="form-group" style="flex-wrap: wrap; display: flex">
+                    <label class="col-sm-2 control-label">发出邀请文案:</label>
+                    <div class="input-group col-sm-8">
+                        <input type="text" class="form-control" name="overtimeInfo" required="" aria-required="true" value="{$settings['copywriting']}">
+                    </div>
+                </div>
+                <div class="form-group" style="margin-top: 40px;">
+                    <label class="col-sm-2 control-label"></label>
+                    <div class="input-group col-sm-4">
+                        <button class="btn btn-primary" type="submit">提交</button>
+                    </div>
+                </div>
+            </form>
+
+            <h4 style="margin-bottom: 10px;">访客端入口设置</h4>
+            <div class="ibox-title">
+            </div>
+
+            <form class="form-horizontal m-t layui-form" id="marginForm" method="post" action="{:url('settings/margin')}">
+                <div class="form-group" style="flex-wrap: wrap; display: flex">
+                    <p style="width: 100%; margin-left: 20px; color: #9c9c9c; margin-bottom: 15px; font-size: 15px;">访客端入口上边距设置</p>
+                    <label class="col-sm-2 control-label">上边距:</label>
+                    <div class="input-group col-sm-1">
+                        <input type="hidden" name="id" value="{$settings['id']}">
+                        <input type="text" class="form-control" name="margin-top" required="" aria-required="true" value="{$settings['margin_top']}">
+                    </div>
+                    <label class="control-label" style="margin-left: 20px;">px</label>
+                </div>
+                <div class="form-group" style="margin-top: 40px;">
+                    <label class="col-sm-2 control-label"></label>
+                    <div class="input-group col-sm-4">
+                        <button class="btn btn-primary" type="submit">提交</button>
+                    </div>
+                </div>
+            </form>
+
+            <a href="/admin/settings/add.html">
+                <button class="btn btn-primary" type="button" style="margin-top:5px"><strong>新增访客端入口</strong>
+                </button>
+            </a>
+            <!--搜索框开始-->
+            <!--<form id='commentForm' role="form" method="post" class="form-inline pull-right">-->
+                <!--<div class="content clearfix m-b">-->
+                    <!--<div class="form-group">-->
+                        <!--<label>功能菜单:</label>-->
+                        <!--<input type="text" class="form-control" id="username" name="user_name">-->
+                    <!--</div>-->
+                    <!--<div class="form-group">-->
+                        <!--<button class="btn btn-primary" type="button" style="margin-top:5px" id="search"><strong>搜 索</strong>-->
+                        <!--</button>-->
+                    <!--</div>-->
+                <!--</div>-->
+            <!--</form>-->
+            <!--搜索框结束-->
+            <div class="example-wrap">
+                <div class="example">
+                    <table id="cusTable">
+                        <thead>
+                        <!--<th data-field="id">id</th>-->
+                        <th data-field="name">名称</th>
+                        <th data-field="image">图片</th>
+                        <th data-field="user_group">关联客服组</th>
+                        <th data-field="sort">排序</th>
+                        <th data-field="operate">操作</th>
+                        </thead>
+                    </table>
+                </div>
+            </div>
+            <!-- End Example Pagination -->
+        </div>
+    </div>
+</div><a href="http://kefu.bocai186.com/demo/index.html" target="_blank">aaaaaaa</a>
+<!-- End Panel Other -->
+<script src="__JS__/jquery.min.js?v=2.1.4"></script>
+<script src="__JS__/bootstrap.min.js?v=3.3.6"></script>
+<script src="__JS__/content.min.js?v=1.0.0"></script>
+<script src="__JS__/plugins/bootstrap-table/bootstrap-table.min.js"></script>
+<script src="__JS__/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script>
+<script src="__JS__/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
+<script src="__JS__/plugins/layer/layer.min.js"></script>
+<script src="__JS__/layui/layui.js"></script>
+<script type="text/javascript">
+
+    layui.use(['form', 'upload'], function(){
+        var form = layui.form;
+
+        form.on('select(group)', function(value){
+            $("#group_id").val(value.value);
+            onSearch()
+        });
+
+    });
+
+</script>
+<script type="text/javascript">
+    function initTable() {
+        //先销毁表格
+        $('#cusTable').bootstrapTable('destroy');
+        //初始化表格,动态从服务器加载数据
+        $("#cusTable").bootstrapTable({
+            method: "get",  //使用get请求到服务器获取数据
+            url: "{:url('settings/index')}", //获取数据的地址
+            striped: true,  //表格显示条纹
+            pagination: true, //启动分页
+            pageSize: 50,  //每页显示的记录数
+            pageNumber:1, //当前第几页
+            pageList: [20, 50],  //记录数可选列表
+            sidePagination: "server", //表示服务端请求
+            paginationFirstText: "首页",
+            paginationPreText: "上一页",
+            paginationNextText: "下一页",
+            paginationLastText: "尾页",
+            queryParamsType : "undefined",
+            queryParams: function queryParams(params) {   //设置查询参数
+                var param = {
+                    pageNumber: params.pageNumber,
+                    pageSize: params.pageSize,
+                    group_id:$('#group_id').val(),
+                    searchText:$('#username').val()
+                };
+                return param;
+            },
+            onLoadSuccess: function(res){  //加载成功时执行
+                if(111 == res.code){
+                    window.location.reload();
+                }
+                layer.msg("加载成功", {time : 1000});
+            },
+            onLoadError: function(){  //加载失败时执行
+                layer.msg("加载数据失败");
+            }
+        });
+    }
+
+    $(document).ready(function () {
+        //调用函数,初始化表格
+        initTable();
+
+        //当点击查询按钮的时候执行
+        $("#search").bind("click", initTable);
+    });
+
+    function Del(id){
+        layer.confirm('确认删除此功能菜单?', {icon: 3, title:'提示'}, function(index){
+            //do something
+            $.getJSON("{:url('settings/del')}", {'id' : id}, function(res){
+                if(1 == res.code){
+                    layer.alert(res.msg, {title: '友情提示', icon: 1, closeBtn: 0}, function(){
+                        initTable();
+                    });
+                }else if(111 == res.code){
+                    window.location.reload();
+                }else{
+                    layer.alert(res.msg, {title: '友情提示', icon: 2});
+                }
+            });
+            layer.close(index);
+        })
+    }
+</script>
+</body>
+</html>

+ 186 - 0
application/admin/view/system/addwelcome.html

@@ -0,0 +1,186 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <meta charset="utf-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>新增欢迎语</title>
+    <link rel="shortcut icon" href="favicon.ico">
+    <link href="__CSS__/bootstrap.min.css?v=3.3.6" rel="stylesheet">
+    <link href="__CSS__/font-awesome.min.css?v=4.4.0" rel="stylesheet">
+    <link href="__CSS__/animate.min.css" rel="stylesheet">
+    <link href="__JS__/layui/css/layui.css" rel="stylesheet">
+    <link href="__CSS__/style.min.css?v=4.1.0" rel="stylesheet">
+    <script charset="utf-8" src="__EDIT__/kindeditor-min.js"></script>
+    <script charset="utf-8" src="__EDIT__/lang/zh_CN.js"></script>
+    <script>
+      KindEditor.ready(function(K) {
+        K.each({
+          'plug-align' : {
+            name : '对齐方式',
+            method : {
+              'justifyleft' : '左对齐',
+              'justifycenter' : '居中对齐',
+              'justifyright' : '右对齐'
+            }
+          },
+          'plug-order' : {
+            name : '编号',
+            method : {
+              'insertorderedlist' : '数字编号',
+              'insertunorderedlist' : '项目编号'
+            }
+          },
+          'plug-indent' : {
+            name : '缩进',
+            method : {
+              'indent' : '向右缩进',
+              'outdent' : '向左缩进'
+            }
+          }
+        },function( pluginName, pluginData ){
+          var lang = {};
+          lang[pluginName] = pluginData.name;
+          KindEditor.lang( lang );
+          KindEditor.plugin( pluginName, function(K) {
+            var self = this;
+            self.clickToolbar( pluginName, function() {
+              var menu = self.createMenu({
+                name : pluginName,
+                width : pluginData.width || 100
+              });
+              K.each( pluginData.method, function( i, v ){
+                menu.addItem({
+                  title : v,
+                  checked : false,
+                  iconClass : pluginName+'-'+i,
+                  click : function() {
+                    self.exec(i).hideMenu();
+                  }
+                });
+              })
+            });
+          });
+        });
+        K.create('#contentqq', {
+          themeType : 'qq',
+          items : [
+            'bold','italic','underline','fontname','fontsize','forecolor','hilitecolor','plug-align','plug-order','plug-indent','link'
+          ]
+        });
+      });
+    </script>
+</head>
+<body class="gray-bg">
+<div class="wrapper wrapper-content animated fadeInRight">
+    <div class="row">
+        <div class="col-sm-8">
+            <div class="ibox float-e-margins">
+                <div class="ibox-title">
+                    <h5>新增欢迎语</h5>
+                </div>
+                <div class="ibox-content">
+                    <form class="form-horizontal m-t layui-form" id="commentForm" method="post" action="{:url('system/addWelcome')}">
+                        <div class="form-group" style="display: flex">
+                            <label style="margin-left: 40px; line-height: 2.5;">排序:</label>
+                            <div class="input-group col-sm-4">
+                                <input class="form-control" name="sort" required="" aria-required="true"/>
+                            </div>
+                        </div>
+                        <div class="form-group">
+                            <label style="margin-left: 40px">欢迎语:</label>
+                            <div class="input-group col-sm-4" style="margin-top: 10px; margin-left: 40px">
+                                <textarea id="contentqq" name="word" style="width:700px;height:200px;visibility:hidden;"></textarea>
+                            </div>
+                        </div>
+                        <div class="form-group">
+                            <div style="margin-left: 40px; margin-top: 20px;">
+                                <button class="btn btn-primary" type="submit">提交</button>
+                            </div>
+                        </div>
+                    </form>
+                </div>
+            </div>
+
+        </div>
+    </div>
+</div>
+<script src="__JS__/jquery.min.js?v=2.1.4"></script>
+<script src="__JS__/bootstrap.min.js?v=3.3.6"></script>
+<script src="__JS__/content.min.js?v=1.0.0"></script>
+<script src="__JS__/plugins/validate/jquery.validate.min.js"></script>
+<script src="__JS__/plugins/validate/messages_zh.min.js"></script>
+<script src="__JS__/plugins/layer/layer.min.js"></script>
+<script src="__JS__/layui/layui.js"></script>
+<script src="__JS__/jquery.form.js"></script>
+<script type="text/javascript">
+    const myHost = "http://" + window.location.host;
+
+    layui.use(['form', 'upload'], function(){
+        var form = layui.form;
+    });
+
+    var index = '';
+    function showStart(){
+        index = layer.load(0, {shade: false});
+        return true;
+    }
+
+    function showSuccess(res){
+
+        layer.ready(function(){
+            layer.close(index);
+            if(1 == res.code){
+                layer.alert(res.msg, {title: '友情提示', icon: 1, closeBtn: 0}, function(){
+                    window.location.href = myHost + '/admin/system/welcoming';
+                });
+            }else if(111 == res.code){
+                window.location.reload();
+            }else{
+                layer.msg(res.msg, {anim: 6});
+            }
+        });
+    }
+
+    $(document).ready(function(){
+        // 添加管理员
+        var options = {
+            beforeSubmit:showStart,
+            success:showSuccess
+        };
+
+        $('#commentForm').submit(function(){
+            $(this).ajaxSubmit(options);
+            return false;
+        });
+    });
+
+    // 表单验证
+    $.validator.setDefaults({
+        highlight: function(e) {
+            $(e).closest(".form-group").removeClass("has-success").addClass("has-error")
+        },
+        success: function(e) {
+            e.closest(".form-group").removeClass("has-error").addClass("has-success")
+        },
+        errorElement: "span",
+        errorPlacement: function(e, r) {
+            e.appendTo(r.is(":radio") || r.is(":checkbox") ? r.parent().parent().parent() : r.parent())
+        },
+        errorClass: "help-block m-b-none",
+        validClass: "help-block m-b-none"
+    });
+
+    layui.use(['form', 'upload'], function(){
+        var form = layui.form;
+
+        form.on('select(group)', function(value){
+            $("#groups_id").val(value.value);
+        });
+
+        form.on('select(robotgroups)', function(value){
+            $("#robotgroups_id").val(value.value);
+        });
+    });
+</script>
+</body>
+</html>

+ 19 - 16
application/admin/view/system/welcoming.html

@@ -19,7 +19,7 @@
             <h5>欢迎语列表</h5>
         </div>
         <div class="ibox-content">
-            <a href="/admin/system/welcomeAdd.html">
+            <a href="/admin/system/addWelcome.html">
                 <button class="btn btn-primary" type="button" style="margin-top:5px"><strong>新 增</strong>
                 </button>
             </a>
@@ -94,23 +94,26 @@
         $("#search").bind("click", initTable);
     });
 
-    function menuDel(id) {
-        layer.confirm('确认删除菜单?', {icon: 3, title: '提示'}, function (index) {
-            //do something
-            $.getJSON("{:url('menu/delMenu')}", {'id': id}, function (res) {
-                if (1 == res.code) {
-                    layer.alert(res.msg, {title: '友情提示', icon: 1, closeBtn: 0}, function () {
-                        initTable();
-                    });
-                } else if (111 == res.code) {
-                    window.location.reload();
-                } else {
-                    layer.alert(res.msg, {title: '友情提示', icon: 2});
-                }
+
+
+    function delWelcome(id){
+      layer.confirm('确认删除此欢迎语吗?', {icon: 3, title:'提示'}, function(index){
+        //do something
+        $.getJSON("{:url('system/delWelcome')}", {'id' : id}, function(res){
+          if(1 == res.code){
+            layer.alert(res.msg, {title: '友情提示', icon: 1, closeBtn: 0}, function(){
+              initTable();
             });
+          }else if(111 == res.code){
+            window.location.reload();
+          }else{
+            layer.alert(res.msg, {title: '友情提示', icon: 2});
+          }
+        });
+
+        layer.close(index);
+      })
 
-            layer.close(index);
-        })
     }
 </script>
 </body>

+ 155 - 0
entranceJs/FloatingButton.js

@@ -0,0 +1,155 @@
+var xmlhttp=new XMLHttpRequest();
+var data = [];//配置信息
+var appip_source = '';
+var appuip_user = '999';
+var isIE=!!window.ActiveXObject;    //是否IE浏览器
+var isIE6=isIE&&!window.XMLHttpRequest;  //是否IE6浏览器
+var isIE7=isIE&&!isIE6&&!isIE8;  //是否IE7浏览器
+var isIE8=isIE&&!!document.documentMode;  //是否IE8浏览器
+var availheight = screen.availHeight;   //默认高度为屏幕的高度
+var hostname = location.protocol+'//'+location.host;
+var adminDomain = 'http://kfadmin.bocai186.com';   //服务器域名
+var serverDomain = 'http://kefu.bocai186.com';   //客服域名
+var userDomain = 'http://kf.bocai186.com';   //用户域名
+if(isIE8){
+  availheight= screen.height;
+}
+//IE11升级弹出窗口小
+if (!!window.ActiveXObject || "ActiveXObject" in window){
+  availheight= screen.height;
+}
+
+
+var div = document.createElement('div');
+
+data = [];
+//浮动按钮样式
+div.style = `position: fixed; right:15px; top:${data[data.length - 1].margin_top}px;width:80px;background: #867c7c00;border-radius: 10px 0 0 10px;
+            display:flex;flex-direction: column; justify-content: space-between;z-index:1000;`;
+div.style.height = 80 * (data.length) + 'px';
+//拼接浮动按钮样式
+let btn_html = '';
+for (let i = 0; i < data.length - 1; i++) {
+  btn_html += `<div id='set_user_info_${data[i].group_id}' style="width:80px;height:80px;background:#9a949775;display:flex;
+                flex-direction: column;justify-content: center;align-items: center; cursor:pointer;z-index:1000; "> 
+                <img  id='set_user_img_${data[i].group_id}'src='${adminDomain}${data[i].image}'></img> 
+                <span id='set_user_span_${data[i].group_id}' style="font-size:12px;font-weight:bold; color: #f0f0f0;">${data[i].name}</span> </div>`;
+}
+div.innerHTML = btn_html;
+//延时显示提示框
+setTimeout(function () {
+  create_prompt_box();
+}, data[data.length - 1].stop_time * 1000);
+
+/***
+ * 打开会话窗口
+ */
+div.onclick =function(e){
+  console.log(window.location.href)
+  var index=e.target.id.lastIndexOf("_");
+  // console.log(e.target,index);
+  var group_id  = e.target.id.substring(index+1,e.target.id.length);
+  console.log(window);
+  if(group_id != 'all'){
+    openWindowCenter(userDomain+"/?appid="+appip_source+"&appuid="+appuip_user+'&group_id='+group_id,700,700);
+  }else{
+    openWindowCenter(userDomain+"/?appid="+appip_source+"&appuid="+appuip_user,700,700);
+  }
+}
+//将浮动按钮添加到对应到网站body上
+setTimeout(function(){
+  document.body.appendChild(div);
+}, 2000);
+
+
+
+
+/**
+ * 提示框样式
+ */
+function create_prompt_box(){
+  var popupWindowBox = document.createElement('div');
+  popupWindowBox.style = `position: fixed; top:35%; padding: 10px; left:45%;width:350px;height:160px;
+    background:#e5e5e5;border-radius:10px;font-size:17px;display:flex; flex-direction: column;
+    justify-content: space-between;z-index:9999;`;
+  //拼接提示框样式
+  popupWindowBox.innerHTML =`
+    <div style='display:flex;flex-direction: row;justify-content: center;'> 
+    <span style="font-weight:bold; color: #666666;">${data[data.length - 1].copywriting}</span> 
+    </div> 
+    <div style='flex-direction: row;display:flex;justify-content: flex-end;'>
+    <div id="$startSession" style='margin-right: 10px; padding: 4px;border: 1px solid #999; border-radius: 4px; color: #666666;font-weight: bold;cursor:pointer;'>开始会话</div>
+    <div id="$cancel" style="padding: 3px;border: 1px solid #999; border-radius: 4px; color: #666666;font-weight: bold;cursor:pointer;">下次再说</div> 
+    </div> 
+    `;
+  popupWindowBox.onclick =function(e){
+    if(e.target.id == '$startSession'){
+      openWindowCenter(userDomain+"/?appid="+appip_source+"&appuid="+appuip_user,700,700);
+    }else if(e.target.id == '$cancel'){
+      popupWindowBox.style.display="none";
+    }
+  }
+
+
+  //将提示框添加到对应到网站body上
+  document.body.appendChild(popupWindowBox);
+}
+
+// padding: 3px;border: 1px solid #999; border-radius: 4px; color: #666666;font-weight: bold;
+
+// /***
+//  *
+//  */
+// function   (){
+
+// }
+
+/**
+ * 打开一个居中的窗口
+ * @param pageUrl url链接
+ * @param innerWidth 宽度,不带px,小于0表示百分比
+ * @param innerHeight 高度,不带px,小于0表示百分比
+ */
+function openWindowCenter(pageUrl, innerWidth, innerHeight){
+  var screenWidth = screen.availWidth;
+  var screenHeight = screen.availHeight;
+  var width = screenWidth;
+  var height = screenHeight;
+
+  if(innerWidth < 1){
+    width = screenWidth * innerWidth;
+    screenWidth = (screen.availWidth - width)/2;
+  }else{
+    width = innerWidth;
+    screenWidth = (screen.availWidth - innerWidth)/2;
+  }
+  if(innerHeight < 1){
+    height = screenHeight * innerHeight;
+    screenHeight = (screen.availHeight - height)/2;
+  }else{
+    height = innerHeight;
+    screenHeight = (screen.availHeight - innerHeight)/2;
+  }
+  window.open(pageUrl, "", "left=" + screenWidth + ",top=" + screenHeight +",width=" + width + ",height=" + height + ",resizable=no,scrollbars=no,status=no,toolbar=no,menubar=no,location=no");
+};
+
+
+//html页面调用
+/**
+ * 获取数据
+ */
+function set_user_info_js(a,b){
+  appip_source = a;
+  appuip_user=b;
+}
+
+//vue调用
+// export default {
+//     /**
+//      * 获取数据
+//      */
+//     set_user_info_vue: function (a,b){
+//         appip_source = a;
+//         appuip_user =b;
+//     }
+// }

+ 155 - 0
entranceJs/new/ff.js

@@ -0,0 +1,155 @@
+var xmlhttp=new XMLHttpRequest();
+var data = [];//配置信息
+var appip_source = '';
+var appuip_user = '999';
+var isIE=!!window.ActiveXObject;    //是否IE浏览器
+var isIE6=isIE&&!window.XMLHttpRequest;  //是否IE6浏览器
+var isIE7=isIE&&!isIE6&&!isIE8;  //是否IE7浏览器
+var isIE8=isIE&&!!document.documentMode;  //是否IE8浏览器
+var availheight = screen.availHeight;   //默认高度为屏幕的高度
+var hostname = location.host;
+var adminDomain = 'kfadmin.bocai186.com';   //服务器域名
+var serverDomain = 'kefu.bocai186.com';   //客服域名
+var userDomain = 'kf.bocai186.com';   //用户域名
+if(isIE8){
+  availheight= screen.height;
+}
+//IE11升级弹出窗口小
+if (!!window.ActiveXObject || "ActiveXObject" in window){
+  availheight= screen.height;
+}
+
+
+var div = document.createElement('div');
+
+data = [{"id":2,"name":"\u552e\u540e\u652f\u6301","image":"\/uploads\/20190809\/8005f8e4bd78904794f5b2eae54957b4.png","group_id":"2","sort":2},{"id":5,"name":"\u552e\u524d\u54a8\u8be2","image":"\/uploads\/20190809\/ce52fd990d35c4c100af6e1fbe708a55.png","group_id":"1","sort":3},{"id":6,"name":"\u5728\u7ebf\u5ba2\u670d","image":"\/uploads\/20190809\/233b8dce85c445b5dd3c092526146d9c.png","group_id":"all","sort":8},{"margin_top":"300","stop_time":"15","copywriting":"\u60a8\u597d\uff0c\u8bf7\u95ee\u6709\u4ec0\u4e48\u53ef\u4ee5\u5e2e\u52a9\u60a8\uff1f"}];
+//浮动按钮样式
+div.style = `position: fixed; right:15px; top:${data[data.length - 1].margin_top}px;width:80px;background: #867c7c00;border-radius: 10px 0 0 10px;
+            display:flex;flex-direction: column; justify-content: space-between;z-index:1000;`;
+div.style.height = 80 * (data.length) + 'px';
+//拼接浮动按钮样式
+let btn_html = '';
+for (let i = 0; i < data.length - 1; i++) {
+  btn_html += `<div id='set_user_info_${data[i].group_id}' style="width:80px;height:80px;background:#9a949775;display:flex;
+                flex-direction: column;justify-content: center;align-items: center; cursor:pointer;z-index:1000; "> 
+                <img  id='set_user_img_${data[i].group_id}'src='${adminDomain}${data[i].image}'></img> 
+                <span id='set_user_span_${data[i].group_id}' style="font-size:12px;font-weight:bold; color: #f0f0f0;">${data[i].name}</span> </div>`;
+}
+div.innerHTML = btn_html;
+//延时显示提示框
+setTimeout(function () {
+  create_prompt_box();
+}, data[data.length - 1].stop_time * 1000);
+
+/***
+ * 打开会话窗口
+ */
+div.onclick =function(e){
+  console.log(window.location.href)
+  var index=e.target.id.lastIndexOf("_");
+  // console.log(e.target,index);
+  var group_id  = e.target.id.substring(index+1,e.target.id.length);
+  console.log(window);
+  if(group_id != 'all'){
+    openWindowCenter(userDomain+"/?appid="+appip_source+"&appuid="+appuip_user+'&group_id='+group_id,700,700);
+  }else{
+    openWindowCenter(userDomain+"/?appid="+appip_source+"&appuid="+appuip_user,700,700);
+  }
+}
+//将浮动按钮添加到对应到网站body上
+setTimeout(function(){
+  document.body.appendChild(div);
+}, 2000);
+
+
+
+
+/**
+ * 提示框样式
+ */
+function create_prompt_box(){
+  var popupWindowBox = document.createElement('div');
+  popupWindowBox.style = `position: fixed; top:35%; padding: 10px; left:45%;width:350px;height:160px;
+    background:#e5e5e5;border-radius:10px;font-size:17px;display:flex; flex-direction: column;
+    justify-content: space-between;z-index:9999;`;
+  //拼接提示框样式
+  popupWindowBox.innerHTML =`
+    <div style='display:flex;flex-direction: row;justify-content: center;'> 
+    <span style="font-weight:bold; color: #666666;">${data[data.length - 1].copywriting}</span> 
+    </div> 
+    <div style='flex-direction: row;display:flex;justify-content: flex-end;'>
+    <div id="$startSession" style='margin-right: 10px; padding: 4px;border: 1px solid #999; border-radius: 4px; color: #666666;font-weight: bold;cursor:pointer;'>开始会话</div>
+    <div id="$cancel" style="padding: 3px;border: 1px solid #999; border-radius: 4px; color: #666666;font-weight: bold;cursor:pointer;">下次再说</div> 
+    </div> 
+    `;
+  popupWindowBox.onclick =function(e){
+    if(e.target.id == '$startSession'){
+      openWindowCenter(userDomain+"/?appid="+appip_source+"&appuid="+appuip_user,700,700);
+    }else if(e.target.id == '$cancel'){
+      popupWindowBox.style.display="none";
+    }
+  }
+
+
+  //将提示框添加到对应到网站body上
+  document.body.appendChild(popupWindowBox);
+}
+
+// padding: 3px;border: 1px solid #999; border-radius: 4px; color: #666666;font-weight: bold;
+
+// /***
+//  *
+//  */
+// function   (){
+
+// }
+
+/**
+ * 打开一个居中的窗口
+ * @param pageUrl url链接
+ * @param innerWidth 宽度,不带px,小于0表示百分比
+ * @param innerHeight 高度,不带px,小于0表示百分比
+ */
+function openWindowCenter(pageUrl, innerWidth, innerHeight){
+  var screenWidth = screen.availWidth;
+  var screenHeight = screen.availHeight;
+  var width = screenWidth;
+  var height = screenHeight;
+
+  if(innerWidth < 1){
+    width = screenWidth * innerWidth;
+    screenWidth = (screen.availWidth - width)/2;
+  }else{
+    width = innerWidth;
+    screenWidth = (screen.availWidth - innerWidth)/2;
+  }
+  if(innerHeight < 1){
+    height = screenHeight * innerHeight;
+    screenHeight = (screen.availHeight - height)/2;
+  }else{
+    height = innerHeight;
+    screenHeight = (screen.availHeight - innerHeight)/2;
+  }
+  window.open(pageUrl, "", "left=" + screenWidth + ",top=" + screenHeight +",width=" + width + ",height=" + height + ",resizable=no,scrollbars=no,status=no,toolbar=no,menubar=no,location=no");
+};
+
+
+//html页面调用
+/**
+ * 获取数据
+ */
+function set_user_info_js(a,b){
+  appip_source = a;
+  appuip_user=b;
+}
+
+//vue调用
+// export default {
+//     /**
+//      * 获取数据
+//      */
+//     set_user_info_vue: function (a,b){
+//         appip_source = a;
+//         appuip_user =b;
+//     }
+// }

+ 155 - 0
entranceJs/new/rrrr.js

@@ -0,0 +1,155 @@
+var xmlhttp=new XMLHttpRequest();
+var data = [];//配置信息
+var appip_source = '';
+var appuip_user = '999';
+var isIE=!!window.ActiveXObject;    //是否IE浏览器
+var isIE6=isIE&&!window.XMLHttpRequest;  //是否IE6浏览器
+var isIE7=isIE&&!isIE6&&!isIE8;  //是否IE7浏览器
+var isIE8=isIE&&!!document.documentMode;  //是否IE8浏览器
+var availheight = screen.availHeight;   //默认高度为屏幕的高度
+var hostname = location.host;
+var adminDomain = 'kfadmin.bocai186.com';   //服务器域名
+var serverDomain = 'kefu.bocai186.com';   //客服域名
+var userDomain = 'kf.bocai186.com';   //用户域名
+if(isIE8){
+  availheight= screen.height;
+}
+//IE11升级弹出窗口小
+if (!!window.ActiveXObject || "ActiveXObject" in window){
+  availheight= screen.height;
+}
+
+
+var div = document.createElement('div');
+
+data = [{"id":2,"name":"\u552e\u540e\u652f\u6301","image":"\/uploads\/20190809\/8005f8e4bd78904794f5b2eae54957b4.png","group_id":"2","sort":2},{"id":5,"name":"\u552e\u524d\u54a8\u8be2","image":"\/uploads\/20190809\/ce52fd990d35c4c100af6e1fbe708a55.png","group_id":"1","sort":3},{"id":6,"name":"\u5728\u7ebf\u5ba2\u670d","image":"\/uploads\/20190809\/233b8dce85c445b5dd3c092526146d9c.png","group_id":"all","sort":8},{"margin_top":"300","stop_time":"15","copywriting":"\u60a8\u597d\uff0c\u8bf7\u95ee\u6709\u4ec0\u4e48\u53ef\u4ee5\u5e2e\u52a9\u60a8\uff1f"}];
+//浮动按钮样式
+div.style = `position: fixed; right:15px; top:${data[data.length - 1].margin_top}px;width:80px;background: #867c7c00;border-radius: 10px 0 0 10px;
+            display:flex;flex-direction: column; justify-content: space-between;z-index:1000;`;
+div.style.height = 80 * (data.length) + 'px';
+//拼接浮动按钮样式
+let btn_html = '';
+for (let i = 0; i < data.length - 1; i++) {
+  btn_html += `<div id='set_user_info_${data[i].group_id}' style="width:80px;height:80px;background:#9a949775;display:flex;
+                flex-direction: column;justify-content: center;align-items: center; cursor:pointer;z-index:1000; "> 
+                <img  id='set_user_img_${data[i].group_id}'src='${adminDomain}${data[i].image}'></img> 
+                <span id='set_user_span_${data[i].group_id}' style="font-size:12px;font-weight:bold; color: #f0f0f0;">${data[i].name}</span> </div>`;
+}
+div.innerHTML = btn_html;
+//延时显示提示框
+setTimeout(function () {
+  create_prompt_box();
+}, data[data.length - 1].stop_time * 1000);
+
+/***
+ * 打开会话窗口
+ */
+div.onclick =function(e){
+  console.log(window.location.href)
+  var index=e.target.id.lastIndexOf("_");
+  // console.log(e.target,index);
+  var group_id  = e.target.id.substring(index+1,e.target.id.length);
+  console.log(window);
+  if(group_id != 'all'){
+    openWindowCenter(userDomain+"/?appid="+appip_source+"&appuid="+appuip_user+'&group_id='+group_id,700,700);
+  }else{
+    openWindowCenter(userDomain+"/?appid="+appip_source+"&appuid="+appuip_user,700,700);
+  }
+}
+//将浮动按钮添加到对应到网站body上
+setTimeout(function(){
+  document.body.appendChild(div);
+}, 2000);
+
+
+
+
+/**
+ * 提示框样式
+ */
+function create_prompt_box(){
+  var popupWindowBox = document.createElement('div');
+  popupWindowBox.style = `position: fixed; top:35%; padding: 10px; left:45%;width:350px;height:160px;
+    background:#e5e5e5;border-radius:10px;font-size:17px;display:flex; flex-direction: column;
+    justify-content: space-between;z-index:9999;`;
+  //拼接提示框样式
+  popupWindowBox.innerHTML =`
+    <div style='display:flex;flex-direction: row;justify-content: center;'> 
+    <span style="font-weight:bold; color: #666666;">${data[data.length - 1].copywriting}</span> 
+    </div> 
+    <div style='flex-direction: row;display:flex;justify-content: flex-end;'>
+    <div id="$startSession" style='margin-right: 10px; padding: 4px;border: 1px solid #999; border-radius: 4px; color: #666666;font-weight: bold;cursor:pointer;'>开始会话</div>
+    <div id="$cancel" style="padding: 3px;border: 1px solid #999; border-radius: 4px; color: #666666;font-weight: bold;cursor:pointer;">下次再说</div> 
+    </div> 
+    `;
+  popupWindowBox.onclick =function(e){
+    if(e.target.id == '$startSession'){
+      openWindowCenter(userDomain+"/?appid="+appip_source+"&appuid="+appuip_user,700,700);
+    }else if(e.target.id == '$cancel'){
+      popupWindowBox.style.display="none";
+    }
+  }
+
+
+  //将提示框添加到对应到网站body上
+  document.body.appendChild(popupWindowBox);
+}
+
+// padding: 3px;border: 1px solid #999; border-radius: 4px; color: #666666;font-weight: bold;
+
+// /***
+//  *
+//  */
+// function   (){
+
+// }
+
+/**
+ * 打开一个居中的窗口
+ * @param pageUrl url链接
+ * @param innerWidth 宽度,不带px,小于0表示百分比
+ * @param innerHeight 高度,不带px,小于0表示百分比
+ */
+function openWindowCenter(pageUrl, innerWidth, innerHeight){
+  var screenWidth = screen.availWidth;
+  var screenHeight = screen.availHeight;
+  var width = screenWidth;
+  var height = screenHeight;
+
+  if(innerWidth < 1){
+    width = screenWidth * innerWidth;
+    screenWidth = (screen.availWidth - width)/2;
+  }else{
+    width = innerWidth;
+    screenWidth = (screen.availWidth - innerWidth)/2;
+  }
+  if(innerHeight < 1){
+    height = screenHeight * innerHeight;
+    screenHeight = (screen.availHeight - height)/2;
+  }else{
+    height = innerHeight;
+    screenHeight = (screen.availHeight - innerHeight)/2;
+  }
+  window.open(pageUrl, "", "left=" + screenWidth + ",top=" + screenHeight +",width=" + width + ",height=" + height + ",resizable=no,scrollbars=no,status=no,toolbar=no,menubar=no,location=no");
+};
+
+
+//html页面调用
+/**
+ * 获取数据
+ */
+function set_user_info_js(a,b){
+  appip_source = a;
+  appuip_user=b;
+}
+
+//vue调用
+// export default {
+//     /**
+//      * 获取数据
+//      */
+//     set_user_info_vue: function (a,b){
+//         appip_source = a;
+//         appuip_user =b;
+//     }
+// }

+ 1 - 0
entranceJs/请勿修改FloatingButton.txt

@@ -0,0 +1 @@
+该文件为js生成基础文件,若修改可能会造成系统生成js文件错误,请慎重!!!

BIN
public/static/material/b8bb9caffc4239cc4ef517c33f11db53.png


BIN
public/static/material/企业LOGO.png


BIN
public/static/material/卡通客服男1.png


BIN
public/static/material/卡通机器人1.png


BIN
public/static/material/售前客服.png


BIN
public/static/material/售后客服.png


BIN
public/static/material/在线客服.png


BIN
public/static/material/广告.png


+ 48 - 27
vendor/GatewayWorker_windows/Applications/whisper/Events.php

@@ -89,17 +89,18 @@ class Events
         // 检测是否开启自动应答
         $sayHello = self::$global->systemReplay;
         if (!empty($sayHello)) {
-
-            $hello = [
-                'message_type' => 'helloMessage',
-                'data' => [
-                    'name' => '智能助手',
-                    'time' => date('H:i'),
-                    'content' => $sayHello
-                ]
-            ];
-            Gateway::sendToClient($client_id, json_encode($hello, 256));
-            unset($hello);
+            foreach ($sayHello as $v) {
+                $hello = [
+                    'message_type' => 'helloMessage',
+                    'data' => [
+                        'name' => '智能助手',
+                        'time' => date('H:i'),
+                        'content' => $v
+                    ]
+                ];
+                Gateway::sendToClient($client_id, json_encode($hello, 256));
+                unset($hello);
+            }
         }
         unset($sayHello);
         // 检测是否开启广告
@@ -224,6 +225,16 @@ class Events
         if (empty($data)) {
             return;
         }
+        if (!Gateway::isOnline($data['kf_client_id'])) {
+            $errorMessage = [
+                'message_type' => 'kfNotOnlin',
+                'data' => [
+                    'error' => '客服不在线请稍后再试',
+                ]
+            ];
+            Gateway::sendToClient($data['client_id'], json_encode($errorMessage, 256));
+            return;
+        }
         $chat_message = [
             'message_type' => 'chatMessage',
             'data' => [
@@ -773,9 +784,6 @@ class Events
         }
         // 获取当前客服.
         $kfInfo = json_decode(self::$redis->HGET('KFINFO', 'KF' . $data['kf_id']), true);
-        if (empty($kfInfo)) {
-            return;
-        }
         // 删除当前工单.
         self::$redis->hdel('SERVICELOG', $servicelogId);
         // 当前服务客服删除当前人员.
@@ -792,7 +800,7 @@ class Events
         $chat_message = [
             'message_type' => 'closeBysever',
             'data' => [
-                'content' => '客服停止了该会话',
+                'content' => '会话关闭',
                 'time' => date('H:i'),
             ]
         ];
@@ -1086,7 +1094,7 @@ class Events
         $serviceid = intval($serviceid);
         $userInfo = json_decode(self::$redis->hget(self::USERINFOKEY, $uid), true);
         $kfinfo = json_decode(self::$redis->hget(self::KFINFOKEY, $kfuid), true);
-        if (empty($userInfo) || empty($kfinfo)) {
+        if (empty($userInfo)) {
             return false;
         }
         // 获取旧工单信息.
@@ -1481,17 +1489,30 @@ class Events
                     Gateway::sendToClient($data['client_id'], json_encode($chat_message, 256));
                 }
                 // 双方静默超时.
-            } elseif ($data['userLastTime'] <= $overtime && $data['serverLastTime'] <= $overtime) {
-                self::serverClose($k, 2);
-                // 如果小于设定时间前一分钟则给出提示.
-            } elseif ($data['userLastTime'] <= $setOvertime && $data['serverLastTime'] <= $setOvertime) {
-                $chat_message = [
-                    'message_type' => 'overtime',
-                    'data' => [
-                        'content' => $configOvertime['systemconfig_content'],
-                    ]
-                ];
-                Gateway::sendToClient($data['client_id'], json_encode($chat_message, 256));
+            } elseif (isset($data['serverLastTime'])) {
+                if ($data['userLastTime'] <= $overtime && $data['serverLastTime'] <= $overtime) {
+                    self::serverClose($k, 2);
+                } elseif ($data['userLastTime'] <= $setOvertime && $data['serverLastTime'] <= $setOvertime) {
+                    $chat_message = [
+                        'message_type' => 'overtime',
+                        'data' => [
+                            'content' => $configOvertime['systemconfig_content'],
+                        ]
+                    ];
+                    Gateway::sendToClient($data['client_id'], json_encode($chat_message, 256));
+                }
+            } else {
+                if ($data['userLastTime'] <= $overtime) {
+                    self::serverClose($k, 2);
+                } elseif ($data['userLastTime'] <= $setOvertime) {
+                    $chat_message = [
+                        'message_type' => 'overtime',
+                        'data' => [
+                            'content' => $configOvertime['systemconfig_content'],
+                        ]
+                    ];
+                    Gateway::sendToClient($data['client_id'], json_encode($chat_message, 256));
+                }
             }
         }
     }