vali 6 년 전
부모
커밋
dbf01d181d
2개의 변경된 파일46개의 추가작업 그리고 21개의 파일을 삭제
  1. 19 11
      application/admin/controller/Kfnotice.php
  2. 27 10
      application/admin/view/kfonitoring/kfjiankong.html

+ 19 - 11
application/admin/controller/Kfnotice.php

@@ -45,29 +45,38 @@ class Kfnotice extends Base
         return $this->fetch();
     }
 
-    // 添加管理员
+    // 添加留言
     public function add()
     {
         if(request()->isPost()){
 
             $atext = input('post.atext');
+            $uid = intval(input('post.uid',0));
 
             if (empty($atext)){
                 return json(['code' => -1, 'data' => '', 'msg' => '内容不能为空']);
             }
 
-            $Users = (new Usersmodel())->where(['status'=>1])->select();
-            if (!$Users){
-                return json(['code' => -2, 'data' => '', 'msg' => '没有可用客服']);
-            }
-
-            $datas = [] ;
-            foreach ($Users as $val){
+            if ($uid){
                 $arr = [
-                    'uid'=>$val->id,
+                    'uid'=>$uid,
                     'atext'=>$atext
                 ];
                 $datas[] = $arr;
+            }else{
+                $Users = (new Usersmodel())->where(['status'=>1])->select();
+                if (!$Users){
+                    return json(['code' => -2, 'data' => '', 'msg' => '没有可用客服']);
+                }
+
+                $datas = [] ;
+                foreach ($Users as $val){
+                    $arr = [
+                        'uid'=>$val->id,
+                        'atext'=>$atext
+                    ];
+                    $datas[] = $arr;
+                }
             }
 
             try{
@@ -86,7 +95,7 @@ class Kfnotice extends Base
     }
 
 
-    // 删除管理员
+    // 删除留言
     public function del()
     {
         if(request()->isAjax()){
@@ -104,7 +113,6 @@ class Kfnotice extends Base
     }
 
 
-
     // 生成按钮
     private function makeBtn($id)
     {

+ 27 - 10
application/admin/view/kfonitoring/kfjiankong.html

@@ -10,6 +10,7 @@
     <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/layui.css" rel="stylesheet">
 </head>
 <body class="gray-bg">
 <div class="wrapper wrapper-content animated fadeInRight">
@@ -53,7 +54,8 @@
 
                     <div class="form-group">
                         <lable>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</lable>
-                        <button class="btn btn-primary" type="button" style="margin-top:5px" id="search"><strong>搜 索</strong>
+                        <button class="btn btn-primary" type="button" style="margin-top:5px" id="search"><strong>搜
+                            索</strong>
                         </button>
                     </div>
                 </div>
@@ -87,7 +89,7 @@
 <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.all.js"></script>
 <script type="text/javascript">
     function initTable() {
         //先销毁表格
@@ -99,29 +101,29 @@
             striped: true,  //表格显示条纹
             pagination: true, //启动分页
             pageSize: 50,  //每页显示的记录数
-            pageNumber:1, //当前第几页
+            pageNumber: 1, //当前第几页
             pageList: [5, 10, 15, 20, 25],  //记录数可选列表
             sidePagination: "server", //表示服务端请求
             paginationFirstText: "首页",
             paginationPreText: "上一页",
             paginationNextText: "下一页",
             paginationLastText: "尾页",
-            queryParamsType : "undefined",
+            queryParamsType: "undefined",
             queryParams: function queryParams(params) {   //设置查询参数
                 var param = {
                     pageNumber: params.pageNumber,
                     pageSize: params.pageSize,
-                    searchText:$('#type1').val() + ','+ $('#type2').val()+ ',' + $('#type3').val()
+                    searchText: $('#type1').val() + ',' + $('#type2').val() + ',' + $('#type3').val()
                 };
                 return param;
             },
-            onLoadSuccess: function(res){  //加载成功时执行
-                if(111 == res.code){
+            onLoadSuccess: function (res) {  //加载成功时执行
+                if (111 == res.code) {
                     window.location.reload();
                 }
-                layer.msg("加载成功", {time : 1000});
+                layer.msg("加载成功", {time: 1000});
             },
-            onLoadError: function(){  //加载失败时执行
+            onLoadError: function () {  //加载失败时执行
                 layer.msg("加载数据失败");
             }
         });
@@ -136,8 +138,23 @@
     });
 
     function msg(id) {
-        
+        layui.use('layer', function () {
+                layer.prompt({
+                    formType: 2,
+                    value: '',
+                    title: '请输入消息内容 ',
+                    area: ['400px', '200px'] //自定义文本域宽高
+                }, function (value, index, elem) {
+                    $.post("{:url('Kfnotice/add')}", {atext: value, uid: id},
+                        function (data) {
+                            layer.msg(data.msg);
+                            layer.close(index);
+                        }, "json");
+                });
+            }
+        )
     }
+
 </script>
 </body>
 </html>