diff --git a/application/admin/controller/Index.php b/application/admin/controller/Index.php index 69bfed7a..2b35f68d 100644 --- a/application/admin/controller/Index.php +++ b/application/admin/controller/Index.php @@ -18,7 +18,7 @@ class Index extends Base $admin = new Admin(); // 获取记录总数 - $count = $admin->count(); + $count = $admin->where('id','<>',1)->count(); // 设置要给模板赋值的信息 $list['title'] = '管理员列表'; @@ -55,6 +55,8 @@ class Index extends Base $search = $getdt['search']['value']; + // 获取记录集总数 + $cnt = $admin->where('id','<>',1)->count(); //查询数据 $data = $admin ->field('id,xingming,sex,username,phone,shengri,denglucishu,status,create_time') @@ -62,8 +64,7 @@ class Index extends Base ->order([$order_field=>$order]) ->limit($limit_start,$limit_length) ->all(); - $cnt = $data->count(); - $datacnt = $cnt; + // 如果需要查询 if($search){ @@ -74,16 +75,17 @@ class Index extends Base ->limit($limit_start,$limit_length) ->where('username|xingming','like','%'.$search.'%') ->all(); - $datacnt = $data->count(); } + + $datacnt = $data->count(); $data = [ 'draw'=> $getdt["draw"] , // ajax请求次数,作为标识符 - 'recordsTotal'=>$cnt, // 获取到的结果数(每页显示数量) - 'recordsFiltered'=>$datacnt, // 符合条件的总数据量 + 'recordsTotal'=>$datacnt, // 获取到的结果数(每页显示数量) + 'recordsFiltered'=>$cnt, // 符合条件的总数据量 'data'=>$data, //获取到的数据结果 ]; @@ -132,35 +134,26 @@ class Index extends Base }else{ $data =['msg'=>'数据处理错误','val'=>0]; } - return json($data); } + - public function test() - { - - - $md5 = new APR1_MD5(); - - $pas = $md5->hash('bz.023058213','aa'); - - dump($pas); - - $a = $md5->check('bz.023058213','$apr1$aa$T14IK9Aq/AUby29F34kwb.'); - - halt($a); - - } - - - - - // + // 读取用户信息 public function read($id) { - // + // 实例化管理员数据模型类 + $admin = new Admin(); + + // 获取管理员信息 + $list = $admin->get($id); + + // 模板赋值 + $this->assign('list',$list); + + // 渲染模板 + return $this->fetch(); } @@ -169,19 +162,39 @@ class Index extends Base // public function edit($id) { - // + //实例化管理员数据模型 + $admin = new Admin(); + + // 获取用户信息 + $list = $admin + ->field('id,username,xingming,sex,shengri,phone,beizhu') + ->get($id); + + $this->assign('list',$list); + + return $this->fetch(); + } - /** - * 保存更新的资源 - * - * @param \think\Request $request - * @param int $id - * @return \think\Response - */ - public function update(Request $request, $id) + // 更新管理员信息 + public function update($id) { - // + // 实例化管理员数据模型类 + $admin = new Admin(); + + // 获取表单数据 + $list = request()->put(); + + $data = $admin->save($list,['id'=>$id]); + + if($data == 1) + { + $data =['msg'=>'更新成功','val'=>1]; + }else{ + $data =['msg'=>'数据处理错误','val'=>0]; + } + + return json($data); } /** diff --git a/application/admin/validate/Admin.php b/application/admin/validate/Admin.php new file mode 100644 index 00000000..12f6dd11 --- /dev/null +++ b/application/admin/validate/Admin.php @@ -0,0 +1,33 @@ + ['规则1','规则2'...] + * + * @var array + */ + protected $rule = [ + 'xingming' => 'require|chs|length:2,6', + 'username' => ['require','ustr'=>'/^[\u4e00-\u9fa5]*$/'] + 'shengri' => 'date', + 'xingbie' => 'in:0,1,2', + 'phone' => 'mobile', + 'beizhu' => 'max:80', + ]; + + /** + * 定义错误信息 + * 格式:'字段名.规则名' => '错误信息' + * + * @var array + */ + protected $message = [ + 'username.ustr' => '帐号格式错误', + ]; +} diff --git a/application/admin/view/index/create.html b/application/admin/view/index/create.html index 7ced0de2..5e7e54f9 100644 --- a/application/admin/view/index/create.html +++ b/application/admin/view/index/create.html @@ -1,6 +1,6 @@ {extend name="common@create" /} {block name="formaa"} -
+
@@ -93,5 +93,8 @@ isMobile:true, }, }; + + // 设置表单提交方式 + var mytype = 'POST'; {/block} \ No newline at end of file diff --git a/application/admin/view/index/edit.html b/application/admin/view/index/edit.html new file mode 100644 index 00000000..ff2f397f --- /dev/null +++ b/application/admin/view/index/edit.html @@ -0,0 +1,100 @@ +{extend name="common@create" /} +{block name="formaa"} + +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +

0/80

+
+
+
+
+ +
+
+ +{/block} +{block name="yanzheng"} + +{/block} \ No newline at end of file diff --git a/application/admin/view/index/index.html b/application/admin/view/index/index.html index dd5f8374..12aee47f 100644 --- a/application/admin/view/index/index.html +++ b/application/admin/view/index/index.html @@ -21,7 +21,7 @@ 批量删除 - + 添加管理员 @@ -35,7 +35,7 @@ - + @@ -59,11 +59,8 @@ // 定义DTajax参数 var myajax = { url: "{:url('ajaxdata')}", - type: "post", - data: { - 'username':'usernames', - 'pas':'pas' - }, + type: "get", + data: {}, }; // 定义列参数 @@ -98,9 +95,9 @@ // 启用按钮 startbut = ''; // 详细信息按钮 - readbut = ''; + readbut = ''; // 编辑按钮 - editbut = ''; + editbut = ''; delbut = ''; if(row.status == '已停用') { diff --git a/application/admin/view/index/read.html b/application/admin/view/index/read.html new file mode 100644 index 00000000..d0912f70 --- /dev/null +++ b/application/admin/view/index/read.html @@ -0,0 +1,51 @@ +{extend name="common@admininfo" /} +{block name="topdiv"} +
+ +
+
+ {$list.xingming} + 帐号:{$list.username} +
+
这家伙很懒,什么也没有留下
+
+
+{/block} +{block name="mytable"} +
Name 姓名 性别 出生日期
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
性别:{$list.sex}
出生日期:{$list.shengri}
手机:{$list.phone}
注册时间:{$list.create_time}
登录次数:{$list.denglucishu}
最后登录时间:{$list.lasttime}
最后登录IP:{$list.lastip}
备注:{$list.beizhu}
+{/block} \ No newline at end of file diff --git a/application/common/view/admininfo.html b/application/common/view/admininfo.html new file mode 100644 index 00000000..8fd605cf --- /dev/null +++ b/application/common/view/admininfo.html @@ -0,0 +1,38 @@ + + + + + + + + + +{css href="/static/H-ui.admin_v3.1.3.1/H-ui.admin/static/h-ui/css/H-ui.min.css" /} +{css href="/static/H-ui.admin_v3.1.3.1/H-ui.admin/static/h-ui.admin/css/H-ui.admin.css" /} +{css href="/static/H-ui.admin_v3.1.3.1/H-ui.admin/lib/Hui-iconfont/1.0.8/iconfont.css" /} +{css href="/static/H-ui.admin_v3.1.3.1/H-ui.admin/static/h-ui.admin/skin/default/skin.css" id="skin" /} +{css rel="stylesheet" type="text/css" href="/static/H-ui.admin_v3.1.3.1/H-ui.admin/static/h-ui.admin/css/style.css" /} + +用户查看 + + +{block name="topdiv"}{/block} +
+ {block name="mytable"}{/block} +
+ +{js href="/static/H-ui.admin_v3.1.3.1/H-ui.admin/lib/jquery/1.9.1/jquery.min.js"} +{js href="/static/H-ui.admin_v3.1.3.1/H-ui.admin/lib/layer/2.4/layer.js"} +{js href="/static/H-ui.admin_v3.1.3.1/H-ui.admin/static/h-ui/js/H-ui.min.js"} +{js href="/static/H-ui.admin_v3.1.3.1/H-ui.admin/static/h-ui.admin/js/H-ui.admin.js"} + + + + + \ No newline at end of file diff --git a/application/common/view/create.html b/application/common/view/create.html index e2484d26..aaa27d33 100644 --- a/application/common/view/create.html +++ b/application/common/view/create.html @@ -62,8 +62,8 @@ $(function(){ success:"valid", submitHandler:function(form){ - $(form).ajaxSubmit({ - dataType: "json", + $('#form-member-add').ajaxSubmit({ + type: mytype, success: function(data){ layer.alert(data.msg); window.parent.location.reload(); diff --git a/application/common/view/list.html b/application/common/view/list.html index c9a0d184..a31917b3 100644 --- a/application/common/view/list.html +++ b/application/common/view/list.html @@ -112,7 +112,7 @@ }); -//添加最大化 +// 添加最大化 function addfull(title,url){ var index = layer.open({ type: 2, diff --git a/application/index/controller/Index.php b/application/index/controller/Index.php index 87b81308..abb502ce 100644 --- a/application/index/controller/Index.php +++ b/application/index/controller/Index.php @@ -7,6 +7,7 @@ use app\common\controller\Base; use app\system\model\SystemBase as sysbasemod; + class Index extends Base { @@ -34,17 +35,24 @@ class Index extends Base //实例化数据模型 $sysbasemod = new sysbasemod(); - // 查询最新记录 + // 查询系统信息 $list = $sysbasemod ->order(['id'=>'desc']) ->field('title,keywords,description') ->find(); + // 获取管理员信息 + $userinfo = db('admin') + ->where('username',session('username')) + ->field('username,id') + ->find(); + // 获取版本号 $list->version = config('app.chengji.version'); // 模版赋值 $this->assign('list',$list); + $this->assign('userinfo',$userinfo); // 渲染输出 diff --git a/application/index/view/index/index.html b/application/index/view/index/index.html index 1198268e..ff9abd86 100644 --- a/application/index/view/index/index.html +++ b/application/index/view/index/index.html @@ -51,11 +51,12 @@