Browse Source

后台权限独立到本项目,
至此,
官网及其后台项目完全独立

linch 5 years ago
parent
commit
54caf83254

+ 338 - 0
Application/Admin/Controller/SysController.class.php

@@ -0,0 +1,338 @@
+<?php
+namespace Admin\Controller;
+
+use Think\Controller;
+use Common\Controller\AuthController;
+use Think\Auth;
+
+class SysController extends AuthController
+{
+    
+    /************************************管理员模块****************************************/
+    
+    public function admin_list()
+    {
+        $admin_mod = new \Common\Model\AdminModel();
+        $page = $this->myGet('p', 0);
+        $field = '*';
+        $page_size = 20;
+        $val = I('val');
+        $auth = new Auth();
+        if ($val) {
+            $where['admin_username'] = array('like', "%" . $val . "%");
+        }
+        $where['admin_type'] = 1;
+        $admin_list = $admin_mod->x_get_list($where, $page, $page_size, $field, 'admin_id asc');
+        $count = $admin_mod->x_count($where);
+        $pager = $admin_mod->x_show($count, $page_size);
+        foreach ($admin_list as $k => $v) {
+            $group = $auth->getGroups($v['admin_id']);
+            $admin_list[$k]['group'] = $group[0]['title'];
+        }
+
+        $this->assign('pager', $pager);
+        $this->assign('admin_list', $admin_list);
+        $this->display();
+    }
+
+    public function admin_list_runedit()
+    {
+        if (IS_POST) {
+            $admin = M('admin');
+            $admin_access = M('auth_group_access');
+            $admin_pwd = I('admin_pwd') ? I('admin_pwd') : '';
+            //随机盐
+            $salt = rand_str(10);
+            $sldata = array(
+                'admin_username' => I('post.admin_username'),
+                'admin_email'    => '',
+                'admin_tel'      => I('post.admin_tel'),
+                'admin_open'     => 1,
+                'admin_realname' => I('post.admin_realname'),
+                'admin_ip'       => get_client_ip(),
+                'admin_addtime'  => time(),
+            );
+            if ($admin_pwd) {
+                $sldata['admin_pwd'] = md5($admin_pwd . $salt);
+                $sldata['admin_salt'] = $salt;
+            }
+            $admin_id = I('post.admin_id') ? intval(I('post.admin_id')) : false;
+            if (!$admin_id) {
+                $this->error('非法请求');
+            }
+            $result = $admin->where('admin_id=' . $admin_id)->save($sldata);
+            $accdata = array(
+                'uid'      => $admin_id,
+                'group_id' => I('post.group_id'),
+            );
+            $admin_access->where('uid=' . $admin_id)->save($accdata);
+            $this->ajaxReturn(1);
+        } else {
+            $admin_mod = M('admin');
+            $admin_access_mod = M('auth_group_access');
+            $admin_id = I('admin_id');
+            $admin_data = $admin_mod->where('admin_id=' . $admin_id)->find();
+            $group_id = $admin_access_mod->where('uid=' . $admin_id)->getfield('group_id');
+            $admin_data['group_id'] = $group_id;
+            $auth_group = M('auth_group')->select();
+            $this->assign('auth_group', $auth_group);
+            $this->assign('admin_data', $admin_data);
+            $this->display('admin_list_edit');
+        }
+    }
+
+    public function admin_list_runadd()
+    {
+        if (IS_POST) {
+            $admin = M('admin');
+            $admin_access = M('auth_group_access');
+            $admin_pwd = I('admin_pwd') ? I('admin_pwd') : '123456';
+            //随机盐
+            $salt = rand_str(10);
+            $sldata = array(
+                'admin_username' => I('post.admin_username'),
+                'admin_pwd'      => md5($admin_pwd . $salt),
+                'admin_salt'     => $salt,
+                'admin_email'    => '',
+                'admin_tel'      => I('post.admin_tel'),
+                'admin_open'     => 1,
+                'admin_realname' => I('post.admin_realname'),
+                'admin_ip'       => get_client_ip(),
+                'admin_addtime'  => time(),
+            );
+            $result = $admin->add($sldata);
+            $accdata = array(
+                'uid'      => $result,
+                'group_id' => I('post.group_id'),
+            );
+            $flag = $admin_access->where($accdata)->find();
+            if (!$flag) {
+                $admin_access->add($accdata);
+            }
+            $this->ajaxReturn(1);
+        } else {
+            $auth_group = M('auth_group')->select();
+            $this->assign('auth_group', $auth_group);
+            $this->display('admin_list_add');
+        }
+    }
+    
+    public function admin_list_del()
+    {
+        $admin_id = I('admin_id');
+        if ($admin_id == 1) {
+            $this->error('管理员不可删除');
+        }
+        $res = M('admin')->where(array('admin_id' => I('admin_id')))->delete();
+        $res = M('auth_group_access')->where(array('uid' => I('admin_id')))->delete();
+        $this->ajaxReturn($res);
+
+    }
+
+
+    //用户组管理
+    public function admin_group()
+    {
+        $auth_group = M('auth_group')->select();
+        $this->assign('auth_group', $auth_group);
+        $this->display();
+    }
+
+    //添加用户组
+    public function admin_group_add()
+    {
+        if (!IS_POST) {
+            $this->display();
+        } else {
+            $sldata = array(
+                'title'   => I('title'),
+                'status'  => I('status'),
+                'addtime' => time(),
+            );
+            $flag = M('auth_group')->add($sldata);
+            $this->success($flag);
+        }
+    }
+
+    //删除用户组
+    public function admin_group_del()
+    {
+        $flag = M('auth_group')->where(array('id' => I('id')))->delete();
+        $this->ajaxReturn($flag);
+    }
+    
+    public function admin_group_edit()
+    {
+        if (!IS_POST) {
+            $group = M('auth_group')->where(array('id' => I('id')))->find();
+            $this->assign('group', $group);
+            $this->display();
+        } else {
+            $sldata = array(
+                'id'     => I('id'),
+                'title'  => I('title'),
+                'status' => I('status'),
+            );
+            $flag = M('auth_group')->save($sldata);
+            $this->ajaxReturn($flag);
+        }
+    }
+    
+    public function admin_group_state()
+    {
+        $id = I('x');
+        $status = M('auth_group')->where(array('id' => $id))->getField('status');//判断当前状态情况
+        if ($status == 1) {
+            $statedata = array('status' => 0);
+            $auth_group = M('auth_group')->where(array('id' => $id))->setField($statedata);
+            $this->success('状态禁止', 1, 1);
+        } else {
+            $statedata = array('status' => 1);
+            $auth_group = M('auth_group')->where(array('id' => $id))->setField($statedata);
+            $this->success('状态开启', 1, 1);
+        }
+
+    }
+    
+    public function admin_rule()
+    {
+        $nav = new \Org\Util\Leftnav;
+        $admin_rule = M('auth_rule')->order('sort')->select();
+        $arr = $nav::rule($admin_rule);
+        $this->assign('admin_rule', $arr);//权限列表
+        $this->display('Sys/admin_rule');
+    }
+    
+    public function admin_rule_add()
+    {
+        if (IS_AJAX) {
+            $admin_rule = M('auth_rule');
+            I('name') ? trim(I('name')) : $this->error('控/方必填');
+            I('title') ? trim(I('name')) : $this->error('名称必填');
+            $sldata = array(
+                'name'    => I('name'),
+                'title'   => I('title'),
+                'status'  => I('status'),
+                'sort'    => I('sort'),
+                'addtime' => time(),
+                'pid'     => I('pid'),
+            );
+            $flag = $admin_rule->add($sldata);
+            //$this->redirect('admin_rule');
+            $this->success('权限添加成功');
+        }
+    }
+    
+    public function admin_rule_state()
+    {
+        $id = I('x');
+        $statusone = M('auth_rule')->where(array('id' => $id))->getField('status');//判断当前状态情况
+        if ($statusone == 1) {
+            $statedata = array('status' => 0);
+            $auth_group = M('auth_rule')->where(array('id' => $id))->setField($statedata);
+            $this->success('状态禁止', 1, 1);
+        } else {
+            $statedata = array('status' => 1);
+            $auth_group = M('auth_rule')->where(array('id' => $id))->setField($statedata);
+            $this->success('状态开启', 1, 1);
+        }
+
+    }
+    
+    public function ruleorder()
+    {
+        if (!IS_AJAX) {
+            $this->error('提交方式不正确', 0, 0);
+        } else {
+            $auth_rule = M('auth_rule');
+            foreach ($_POST as $id => $sort) {
+                $auth_rule->where(array('id' => $id))->setField('sort', $sort);
+            }
+            $this->success('排序更新成功', U('admin_rule'), 1);
+        }
+    }
+    
+    public function admin_rule_edit()
+    {
+        if (IS_AJAX) {
+            $admin_rule = M('auth_rule');
+            $sldata = array(
+                'id'      => I('id'),
+                'name'    => I('name'),
+                'title'   => I('title'),
+                'status'  => I('status'),
+                'is_show' => I('is_show'),
+                'pid'     => I('pid'),
+            );
+            $admin_rule->save($sldata);
+            $this->success('权限修改成功');
+        } else {
+            $nav = new \Org\Util\Leftnav;
+            $admin_rule = M('auth_rule')->order('sort')->select();
+            $arr = $nav::rule($admin_rule);
+            $this->assign('admin_rule', $arr);//权限列表
+            $admin_rule = M('auth_rule')->where(array('id' => I('id')))->find();
+            $this->assign('rule', $admin_rule);
+            $this->display('Sys/admin_rule_edit');
+        }
+    }
+
+    public function admin_rule_runedit()
+    {
+        if (!IS_AJAX) {
+            $this->error('提交方式不正确', 0, 0);
+        } else {
+            $admin_rule = M('auth_rule');
+            $sldata = array(
+                'id'     => I('id'),
+                'name'   => I('name'),
+                'title'  => I('title'),
+                'status' => I('status'),
+                'css'    => I('css'),
+                'sort'   => I('sort'),
+            );
+            $admin_rule->save($sldata);
+            $this->success('权限修改成功', U('admin_rule'), 1);
+        }
+    }
+    
+    public function admin_rule_del()
+    {
+        $flag = M('auth_rule')->where(array('id' => I('id')))->delete();
+        $this->ajaxReturn($flag);
+    }
+    
+    //三重权限配置
+    public function admin_group_access()
+    {
+        $admin_group = M('auth_group')->where(array('id' => I('id')))->find();
+        $m = M('auth_rule');
+        $data = $m->field('id,name,title')->where('pid=0')->select();
+        foreach ($data as $k => $v) {
+            $data[$k]['sub'] = $m->field('id,name,title')->where('pid=' . $v['id'])->select();
+            foreach ($data[$k]['sub'] as $kk => $vv) {
+                $data[$k]['sub'][$kk]['sub'] = $m->field('id,name,title')->where('pid=' . $vv['id'])->select();
+            }
+        }
+        $this->assign('admin_group', $admin_group);    // 顶级
+        $this->assign('data', $data);    // 顶级
+        $this->display();
+    }
+    
+    public function admin_group_runaccess()
+    {
+        $m = M('auth_group');
+        $new_rules = I('new_rules');
+        $imp_rules = implode(',', $new_rules) . ',';
+        $sldata = array(
+            'id'    => I('id'),
+            'rules' => $imp_rules,
+        );
+        if ($m->save($sldata)) {
+            $this->success('权限配置成功', U('admin_group'));
+            //$this->redirect('admin_group');
+        } else {
+            $this->error('权限配置失败');
+        }
+    }
+}

+ 67 - 0
Application/Admin/View/Sys/admin_group.html

@@ -0,0 +1,67 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+	<include file="./Application/Admin/View/head.html" />
+</head>
+<body>
+<include file="./Application/Admin/View/bread_crumbs.html" />
+<div class="page-container">
+	<div class="text-c">
+		<div class="cl pd-5 bg-1 bk-gray">
+                <span class="l">
+                    <a class="btn btn-primary radius" href="javascript:;" onclick="cp_add('添加用户组','{:U('Sys/admin_group_add')}', '600', '400')"><i class="Hui-iconfont">&#xe600;</i> 添加用户组</a>
+                </span>
+			<!--<span class="r">共有数据:<strong>54</strong> 条</span>-->
+		</div>
+		<table class="table table-border table-bordered table-hover table-bg">
+			<thead>
+			<tr>
+				<th scope="col" colspan="100">用户组管理</th>
+			</tr>
+			<tr class="text-c">
+				<th width="40">ID</th>
+				<th width="40">用户组</th>
+				<th width="90">状态</th>
+				<th width="100">操作</th>
+			</tr>
+			</thead>
+			<tbody>
+			<volist name="auth_group" id="vo">
+				<tr class="text-c">
+					<td>{$vo.id}</td>
+					<td>{$vo.title}</td>
+					<td><if condition="$vo['status'] eq 0"><font color="red">禁用</font></if><if condition="$vo['status'] eq 1"><font color="green">启用</font></if></td>
+					<td class="f-14">
+						<a title="授权" href="javascript:;" onclick="cp_full_add('授权','admin_group_access?id={$vo.id}', '600', '400')" style="text-decoration:none"><i class="Hui-iconfont">&#xe61d;</i>授权</a>
+						<a title="编辑" href="javascript:;" onclick="cp_add('编辑','admin_group_edit?id={$vo.id}', '600', '400')" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i>编辑</a>
+						<a title="删除" href="javascript:;" onclick="cp_del(this, '{$vo.id}')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i>删除</a>
+					</td>
+				</tr>
+			</volist>
+			</tbody>
+		</table>
+		<div class="meneame">{$pager}</div>
+	</div>
+	<include file="./Application/Admin/View/foot.html" />
+	<script type="text/javascript">
+		/*-删除*/
+		function cp_del(obj, id) {
+			layer.confirm('删除须谨慎,确认要删除吗?', function(index) {
+				//此处请求后台程序,下方是成功后的前台处理……
+				$.ajax({
+					type: "get",
+					url: "admin_group_del",
+					data: {id: id},
+//                        async: false,
+					success: function(data) {
+						if (data == 1) {
+							$(obj).parents("tr").remove();
+							layer.msg('已删除!', {icon: 1, time: 1000});
+						}
+					}
+				});
+			});
+		}
+	</script>
+</body>
+</html>

+ 104 - 0
Application/Admin/View/Sys/admin_group_access.html

@@ -0,0 +1,104 @@
+<!--_meta 作为公共模版分离出去-->
+<!DOCTYPE HTML>
+<html>
+<head>
+    <include file="./Application/Admin/View/head.html" />
+    <link rel="stylesheet" type="text/css" href="/Public/lib/bootstrap-Switch/bootstrapSwitch.css" />
+</head>
+<body>
+<article class="page-container">
+    <form action="{:U('Sys/admin_group_runaccess')}" method="post" class="form form-horizontal" id="form-admin-role-add">
+        <div class="row cl">
+            <label class="form-label col-xs-4 col-sm-3">用户组名:</label>
+            <div class="formControls col-xs-8 col-sm-9">{$admin_group.title}
+            </div>
+        </div>
+        <div class="row cl">
+            <label class="form-label col-xs-4 col-sm-3">权限列表:</label>
+            <div class="formControls col-xs-8 col-sm-9">
+                <foreach name="data" item="vo">
+                <dl class="permission-list">
+                    <dt>
+                        <label>
+                            <input <if condition="strstr($admin_group['rules'],$vo['id']) eq true">checked</if> type="checkbox" value="{$vo.id}" name="new_rules[]" id="user-Character-0">
+                            {$vo.title}</label>
+                    </dt>
+                    <dd>
+                        <foreach name="vo['sub']" item="sub">
+                        <dl class="cl permission-list2">
+                            <dt>
+                                <label class="">
+                                    <input <if condition=" strpos($admin_group['rules'],','.$sub['id'].',') GT -1 ">checked</if> type="checkbox" value="{$sub.id}" name="new_rules[]" id="{$sub.id}">
+                                    {$sub.title}</label>
+                            </dt>
+                            <dd>
+                                <foreach name="sub['sub']" item="subb">
+                                    </br>
+                                <label class="">
+                                    <input <if condition=" strpos($admin_group['rules'],','.$subb['id'].',') GT -1 ">checked</if> type="checkbox" value="{$subb.id}" name="new_rules[]" id="{$subb.id}">
+                                    {$subb.title}</label>
+                                </foreach>
+                            </dd>
+                        </dl>
+                        </foreach>
+                    </dd>
+                </dl>
+                </foreach>
+            </div>
+        </div>
+        <div class="row cl">
+            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
+                <input name="id" id="id" type="hidden" value="{$admin_group.id}" />
+                <button type="submit" class="btn btn-success radius" id="admin-role-save" name="admin-role-save"><i class="icon-ok"></i> 确定</button>
+            </div>
+        </div>
+    </form>
+</article>
+
+<!--_footer 作为公共模版分离出去-->
+<include file="./Application/Admin/View/foot.html" />
+<script type="text/javascript" src="/Public/lib/jquery/jquery.form.js"></script>
+<!--/_footer /作为公共模版分离出去-->
+
+<!--请在下方写此页面业务相关的脚本-->
+<script type="text/javascript">
+    $(function(){
+        $(".permission-list dt input:checkbox").click(function(){
+            $(this).closest("dl").find("dd input:checkbox").prop("checked",$(this).prop("checked"));
+        });
+        $(".permission-list2 dd input:checkbox").click(function(){
+            var l =$(this).parent().parent().find("input:checked").length;
+            var l2=$(this).parents(".permission-list").find(".permission-list2 dd").find("input:checked").length;
+            if($(this).prop("checked")){
+                $(this).closest("dl").find("dt input:checkbox").prop("checked",true);
+                $(this).parents(".permission-list").find("dt").first().find("input:checkbox").prop("checked",true);
+            }
+            else{
+                if(l==0){
+                    $(this).closest("dl").find("dt input:checkbox").prop("checked",false);
+                }
+                if(l2==0){
+                    $(this).parents(".permission-list").find("dt").first().find("input:checkbox").prop("checked",false);
+                }
+            }
+        });
+
+        $("#form-admin-role-add").validate({
+            rules:{
+
+            },
+            onkeyup:false,
+            focusCleanup:true,
+            success:"valid",
+            submitHandler:function(form){
+                $(form).ajaxSubmit();
+                parent.layer.msg('授权成功了!', {icon: 6, time:2000});
+                var index = parent.layer.getFrameIndex(window.name);
+                parent.layer.close(index);
+            }
+        });
+    });
+</script>
+<!--/请在上方写此页面业务相关的脚本-->
+</body>
+</html>

+ 79 - 0
Application/Admin/View/Sys/admin_group_add.html

@@ -0,0 +1,79 @@
+<!--_meta 作为公共模版分离出去-->
+<!DOCTYPE HTML>
+<html>
+<head>
+	<include file="./Application/Admin/View/head.html" />
+	<link rel="stylesheet" type="text/css" href="/Public/lib/bootstrap-Switch/bootstrapSwitch.css" />
+</head>
+<body>
+<article class="page-container">
+	<form action="" method="post" class="form form-horizontal" id="form-admin-group-add">
+		<notempty name="info.id">
+			<div class="row cl">
+				<label class="form-label col-xs-4 col-sm-3">ID:</label>
+				<div class="formControls col-xs-8 col-sm-9">{$info.id}</div>
+			</div>
+		</notempty>
+
+		<div class="row cl">
+			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>用户组名:</label>
+			<div class="formControls col-xs-8 col-sm-9">
+				<input type="text" class="input-text" value="" placeholder="" id="title" name="title" style="width: 120px"/>
+			</div>
+		</div>
+
+		<div class="row cl">
+			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>是否启用:</label>
+			<div class="formControls col-xs-8 col-sm-9">
+				<select name="status" class="selectpicker" id="status">
+					<option value="1">启用</option>
+					<option value="0">禁用</option>
+				</select>
+			</div>
+		</div>
+
+		<div class="row cl">
+			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
+				<button type="submit" class="btn btn-success radius" id="admin-role-save" name="admin-role-save"><i class="icon-ok"></i> 确定</button>
+			</div>
+		</div>
+	</form>
+</article>
+<!--_footer 作为公共模版分离出去-->
+<include file="./Application/Admin/View/foot.html" />
+<!--/_footer /作为公共模版分离出去-->
+
+<script>
+	$().ready(function() {
+
+		$("#form-admin-group-add").validate({
+			rules: {
+				role_name: {
+					required: true,
+					minlength: 2
+				},
+			},
+			success: "valid",
+			submitHandler: function() {
+				$.ajax({
+					type: "post",
+					url: "/Admin/Sys/admin_group_add",
+					data: {title: $('#title').val(), status: $('#status').val()},
+					success: function(data) {
+						if (data != '0') {
+							//加载层-风格3
+							parent.layer.load(2);
+							parent.layer.msg('添加成功了!', {icon: 6});
+							parent.location.reload();
+							var index = parent.layer.getFrameIndex(window.name);
+							parent.layer.close(index);
+
+						}
+					}
+				});
+			}
+		});
+	});
+</script>
+</body>
+</html>

+ 74 - 0
Application/Admin/View/Sys/admin_group_edit.html

@@ -0,0 +1,74 @@
+<!--_meta 作为公共模版分离出去-->
+<!DOCTYPE HTML>
+<html>
+<head>
+	<include file="./Application/Admin/View/head.html" />
+	<link rel="stylesheet" type="text/css" href="/Public/lib/bootstrap-Switch/bootstrapSwitch.css" />
+</head>
+<body>
+<article class="page-container">
+	<form action="{:U('Sys/admin_group_edit')}" method="post" class="form form-horizontal" id="form-admin-group-edit">
+
+		<div class="row cl">
+			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>用户组名:</label>
+			<div class="formControls col-xs-8 col-sm-9">
+				<input type="text" class="input-text" value="{$group.title}" placeholder="" id="title" name="title" style="width: 120px"/>
+			</div>
+		</div>
+
+		<div class="row cl">
+			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>是否启用:</label>
+			<div class="formControls col-xs-8 col-sm-9">
+				<select name="status" class="selectpicker" id="status">
+					<option <if condition="$group['status'] eq 1">selected = "selected"</if> value="1">启用</option>
+					<option <if condition="$group['status'] eq 0">selected = "selected"</if> value="0">禁用</option>
+				</select>
+			</div>
+		</div>
+
+		<div class="row cl">
+			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
+				<input type="hidden" name="id" value="{$group.id}" id="id">
+				<button type="submit" class="btn btn-success radius" id="admin-role-save" name="admin-role-save"><i class="icon-ok"></i> 确定</button>
+			</div>
+		</div>
+	</form>
+</article>
+<!--_footer 作为公共模版分离出去-->
+<include file="./Application/Admin/View/foot.html" />
+<!--/_footer /作为公共模版分离出去-->
+
+<script>
+	$().ready(function() {
+
+		$("#form-admin-group-edit").validate({
+			rules: {
+				role_name: {
+					required: true,
+					minlength: 2
+				},
+			},
+			success: "valid",
+			submitHandler: function() {
+				$.ajax({
+					type: "post",
+					url: "/Admin/Sys/admin_group_edit",
+					data: {title: $('#title').val(), status: $('#status').val(), id: $('#id').val()},
+					success: function(data) {
+						if (data != '0') {
+							//加载层-风格3
+							parent.layer.load(2);
+							parent.layer.msg('编辑成功了!', {icon: 6});
+							parent.location.reload();
+							var index = parent.layer.getFrameIndex(window.name);
+							parent.layer.close(index);
+
+						}
+					}
+				});
+			}
+		});
+	});
+</script>
+</body>
+</html>

+ 66 - 0
Application/Admin/View/Sys/admin_list.html

@@ -0,0 +1,66 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+	<include file="./Application/Admin/View/head.html" />
+</head>
+<body>
+<include file="./Application/Admin/View/bread_crumbs.html" />
+<div class="page-container">
+	<div class="text-c">
+		<div class="cl pd-5 bg-1 bk-gray">
+                <span class="l">
+                    <a class="btn btn-primary radius" href="javascript:;" onclick="cp_add('添加用户','{:U('Sys/admin_list_runadd')}', '600', '400')"><i class="Hui-iconfont">&#xe600;</i> 添加用户</a>
+                </span>
+			<!--<span class="r">共有数据:<strong>54</strong> 条</span>-->
+		</div>
+		<table class="table table-border table-bordered table-hover table-bg">
+			<thead>
+			<tr>
+				<th scope="col" colspan="100">用户管理</th>
+			</tr>
+			<tr class="text-c">
+				<th width="40">ID</th>
+				<th width="40">用户名</th>
+				<th width="90">所属角色</th>
+				<th width="100">操作</th>
+			</tr>
+			</thead>
+			<tbody>
+			<volist name="admin_list" id="vo">
+				<tr class="text-c">
+					<td>{$vo.admin_id}</td>
+					<td>{$vo.admin_username}</td>
+					<td>{$vo.group}</td>
+					<!--<td><a href="{:U('Admins/edit')}?id={$vo.id}">编辑</a>|<a class="" href="javascript:delCheck('{$vo.name}','{:U('Admins/del')}?id={$vo.id}')">删除</a></td>-->
+					<td class="f-14">
+						<a title="编辑" href="javascript:;" onclick="cp_add('编辑管理员','admin_list_runedit&admin_id={$vo.admin_id}', '600', '400')" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i>编辑</a>
+						<a title="删除" href="javascript:;" onclick="cp_del(this, '{$vo.admin_id}')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i>删除</a>
+					</td>
+				</tr>
+			</volist>
+			</tbody>
+		</table>
+		<div class="meneame">{$pager}</div>
+	</div>
+	<include file="./Application/Admin/View/foot.html" />
+	<script type="text/javascript">
+		/*-删除*/
+		function cp_del(obj, admin_id) {
+			layer.confirm('删除须谨慎,确认要删除吗?', function(index) {
+				//此处请求后台程序,下方是成功后的前台处理……
+				$.ajax({
+					type: "get",
+					url: "admin_list_del",
+					data: {admin_id: admin_id},
+					success: function(data) {
+						if (data == 1) {
+							$(obj).parents("tr").remove();
+							layer.msg('已删除!', {icon: 1, time: 1000});
+						}
+					}
+				});
+			});
+		}
+	</script>
+</body>
+</html>

+ 102 - 0
Application/Admin/View/Sys/admin_list_add.html

@@ -0,0 +1,102 @@
+<!--_meta 作为公共模版分离出去-->
+<!DOCTYPE HTML>
+<html>
+    <head>
+    <include file="./Application/Admin/View/head.html" />
+</head>
+<body>
+    <article class="page-container">
+        <form action="{:U('Sys/admin_list_runadd')}" method="post" class="form form-horizontal" id="form-admin-role-add">
+            <notempty name="info.id">
+                <div class="row cl">
+                    <label class="form-label col-xs-4 col-sm-3">ID:</label>
+                    <div class="formControls col-xs-8 col-sm-9">{$info.id}</div>
+                </div>
+            </notempty>
+
+            <div class="row cl">
+                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>用户名:</label>
+                <div class="formControls col-xs-8 col-sm-9">
+                    <input type="text" class="input-text" value="{$admin_data.admin_username}" placeholder="" id="admin_username" name="admin_username" style="width: 120px"/>
+                </div>
+            </div>
+
+            <div class="row cl">
+                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>真实姓名:</label>
+                <div class="formControls col-xs-8 col-sm-9">
+                    <input type="text" class="input-text" value="{$admin_data.admin_realname}" placeholder="" id="admin_realname" name="admin_realname" style="width: 120px"/>
+                </div>
+            </div>
+
+            <div class="row cl">
+                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>手机号:</label>
+                <div class="formControls col-xs-8 col-sm-9">
+                    <input type="text" class="input-text" value="{$admin_data.admin_tel}" placeholder="" id="admin_tel" name="admin_tel" style="width: 120px"/>
+                </div>
+            </div>
+
+            <div class="row cl">
+                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>用户组:</label>
+                <div class="formControls col-xs-8 col-sm-9">
+                    <select name="group_id" class="selectpicker" id="group_id">
+                        <option value="0">--请选择--</option>
+                        <foreach name="auth_group" item="v">
+                            <option <?php if ($admin_data['group_id'] == $v['id']): ?> selected = "selected" <?php endif; ?> value="{$v.id}" >{$v.title}</option>
+                        </foreach>
+                    </select>
+                </div>
+            </div>
+
+            <div class="row cl">
+                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>密码:</label>
+                <div class="formControls col-xs-8 col-sm-9">
+                    <input type="text" class="input-text" value="" placeholder="" id="admin_pwd" name="admin_pwd" style="width: 120px">
+                </div>
+            </div>
+
+            <div class="row cl">
+                <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
+                    <input type="hidden" name="admin_id" id='admin_id' value="{$admin_data.admin_id}">
+                    <button type="submit" class="btn btn-success radius" id="admin-role-save" name="admin-role-save"><i class="icon-ok"></i> 确定</button>
+                </div>
+            </div>
+        </form>
+    </article>
+    <!--_footer 作为公共模版分离出去-->
+<include file="./Application/Admin/View/foot.html" />
+<!--/_footer /作为公共模版分离出去-->
+
+<script>
+    $().ready(function() {
+
+        $("#form-admin-role-add").validate({
+            rules: {
+                role_name: {
+                    required: true,
+                    minlength: 2
+                },
+            },
+            success: "valid",
+            submitHandler: function() {
+                $.ajax({
+                    type: "post",
+                    url: "/admin/Sys/admin_list_runadd",
+                    data:$('#form-admin-role-add').serialize(),
+                    success: function(data) {
+                        if (data != '0') {
+                            //加载层-风格3
+                            parent.layer.load(2);
+                            parent.layer.msg('恭喜主人添加成功了!', {icon: 6});
+                            parent.location.reload();
+                            var index = parent.layer.getFrameIndex(window.name);
+                            parent.layer.close(index);
+
+                        }
+                    }
+                });
+            }
+        });
+    });
+</script>
+</body>
+</html>

+ 102 - 0
Application/Admin/View/Sys/admin_list_edit.html

@@ -0,0 +1,102 @@
+<!--_meta 作为公共模版分离出去-->
+<!DOCTYPE HTML>
+<html>
+    <head>
+    <include file="./Application/Admin/View/head.html" />
+</head>
+<body>
+    <article class="page-container">
+        <form action="{:U('Sys/admin_list_runedit')}" method="post" class="form form-horizontal" id="form-admin-role-add">
+            <notempty name="info.id">
+                <div class="row cl">
+                    <label class="form-label col-xs-4 col-sm-3">ID:</label>
+                    <div class="formControls col-xs-8 col-sm-9">{$info.id}</div>
+                </div>
+            </notempty>
+
+            <div class="row cl">
+                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>用户名:</label>
+                <div class="formControls col-xs-8 col-sm-9">
+                    <input type="text" class="input-text" value="{$admin_data.admin_username}" placeholder="" id="admin_username" name="admin_username" style="width: 120px"/>
+                </div>
+            </div>
+
+            <div class="row cl">
+                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>真实姓名:</label>
+                <div class="formControls col-xs-8 col-sm-9">
+                    <input type="text" class="input-text" value="{$admin_data.admin_realname}" placeholder="" id="admin_realname" name="admin_realname" style="width: 120px"/>
+                </div>
+            </div>
+
+            <div class="row cl">
+                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>手机号:</label>
+                <div class="formControls col-xs-8 col-sm-9">
+                    <input type="text" class="input-text" value="{$admin_data.admin_tel}" placeholder="" id="admin_tel" name="admin_tel" style="width: 120px"/>
+                </div>
+            </div>
+
+            <div class="row cl">
+                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>用户组:</label>
+                <div class="formControls col-xs-8 col-sm-9">
+                    <select name="group_id" class="selectpicker" id="group_id">
+                        <option value="0">--请选择--</option>
+                        <foreach name="auth_group" item="v">
+                            <option <?php if ($admin_data['group_id'] == $v['id']): ?> selected = "selected" <?php endif; ?> value="{$v.id}" >{$v.title}</option>
+                        </foreach>
+                    </select>
+                </div>
+            </div>
+
+            <div class="row cl">
+                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>密码:</label>
+                <div class="formControls col-xs-8 col-sm-9">
+                    <input type="text" class="input-text" value="" placeholder="" id="admin_pwd" name="admin_pwd" style="width: 120px">
+                </div>
+            </div>
+
+            <div class="row cl">
+                <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
+                    <input type="hidden" name="admin_id" id='admin_id' value="{$admin_data.admin_id}">
+                    <button type="submit" class="btn btn-success radius" id="admin-role-save" name="admin-role-save"><i class="icon-ok"></i> 确定</button>
+                </div>
+            </div>
+        </form>
+    </article>
+    <!--_footer 作为公共模版分离出去-->
+<include file="./Application/Admin/View/foot.html" />
+<!--/_footer /作为公共模版分离出去-->
+
+<script>
+    $().ready(function() {
+
+        $("#form-admin-role-add").validate({
+            rules: {
+                role_name: {
+                    required: true,
+                    minlength: 2
+                },
+            },
+            success: "valid",
+            submitHandler: function() {
+                $.ajax({
+                    type: "post",
+                    url: "/admin/Sys/admin_list_runedit",
+                    data:$('#form-admin-role-add').serialize(),
+                    success: function(data) {
+                        if (data != '0') {
+                            //加载层-风格3
+                            parent.layer.load(2);
+                            parent.layer.msg('恭喜主人添加成功了!', {icon: 6});
+                            parent.location.reload();
+                            var index = parent.layer.getFrameIndex(window.name);
+                            parent.layer.close(index);
+
+                        }
+                    }
+                });
+            }
+        });
+    });
+</script>
+</body>
+</html>

+ 120 - 0
Application/Admin/View/Sys/admin_rule.html

@@ -0,0 +1,120 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+	<include file="./Application/Admin/View/head.html" />
+</head>
+<body>
+<include file="./Application/Admin/View/bread_crumbs.html" />
+<div class="page-container">
+	<div class="text-c">
+		<form name="admin_rule_add" id="admin_rule_add" method="post" action="{:U('admin_rule_add')}" >
+			<table class="table table-border table-bordered table-bg">
+				<tr>
+					<td>
+						&nbsp; 状态:
+                            <span class="select-box inline">
+                                <select name="status" class="select" id="status">
+									<option value="1" >启用</option>
+									<option value="0" >禁用</option>
+								</select>
+                            </span>
+						&nbsp; 父级:
+                            <span class="select-box inline">
+                                <select name="pid" class="select" id="pid">
+									<option value="0">--默认顶级--</option>
+									<foreach name="admin_rule" item="v">
+										<option value="{$v.id}" style="margin-left:55px;">{$v.lefthtml}{$v.title}</option>
+									</foreach>
+								</select>
+                            </span>
+						名称:<input name="title" id="title" class="input-text" style="width:150px;"/>
+						控/方:<input name="name" id="name" class="input-text" style="width:150px;"/>
+						<input class="btn btn-xs btn-danger ruleadd" type="submit" value="&nbsp;&nbsp;添加权限&nbsp;&nbsp;">
+					</td>
+				</tr>
+			</table>
+		</form>
+		<table class="table table-border table-bordered table-hover table-bg table-striped">
+			<thead>
+			<tr class="text-c">
+				<th width="40">ID</th>
+				<th width="150" >权限名称</th>
+				<th width="150">控制器/方法</th>
+				<th width="50">状态</th>
+				<th width="80">添加时间</th>
+				<th width="40">操作</th>
+			</tr>
+			</thead>
+			<tbody>
+			<foreach name="admin_rule" item="v">
+				<tr>
+					<td>{$v.id}</td>
+					<td style='padding-left:<if condition="$v.leftpin neq 0">{$v.leftpin}px</if>' >{$v.lefthtml}{$v.title}</td>
+					<td align="left">{$v.name}</td>
+					<td class="text-c"><if condition="$v['status'] eq 0"><font color="red">禁用</font></if><if condition="$v['status'] eq 1"><font color="green">启用</font></if></td>
+					<td class="text-c">{$v.addtime|date='Y-m-d H:i:s',###}</td>
+					<td class="text-c">
+						<a title="编辑" href="javascript:;" onclick="cp_add('编辑','admin_rule_edit&id={$v.id}', '600', '400')" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i>编辑</a>
+						<a title="删除" href="javascript:;" onclick="cp_del(this, '{$v.id}')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i>删除</a>
+					</td>
+				</tr>
+			</foreach>
+			</tbody>
+		</table>
+		<div class="meneame">{$pager}</div>
+	</div>
+	<include file="./Application/Admin/View/foot.html" />
+	<script type="text/javascript">
+		/*-删除*/
+		function cp_del(obj, id) {
+			layer.confirm('删除须谨慎,确认要删除吗?', function(index) {
+				//此处请求后台程序,下方是成功后的前台处理……
+				$.ajax({
+					type: "get",
+					url: "admin_rule_del",
+					data: {id: id},
+					success: function(data) {
+						if (data == 1) {
+							$(obj).parents("tr").remove();
+							layer.msg('已删除!', {icon: 1, time: 1000});
+						}
+					}
+				});
+			});
+		}
+	</script>
+	<script>
+		$().ready(function() {
+			$("#admin_rule_add").validate({
+				rules: {
+
+				},
+				success: "valid",
+				submitHandler: function() {
+					$.ajax({
+						type: "post",
+						url: "{:U('admin_rule_add')}",
+						data: {
+							title: $('#title').val(),
+							name: $('#name').val(),
+							status: $('#status').val(),
+							pid: $('#pid').val(),
+							type: $('#type').val(),
+						},
+						success: function(data) {
+							if (data.status == '1') {
+								//加载层-风格3
+								layer.msg(data.info, {icon: 1});
+								location.reload();
+
+							} else if(data.status == '0') {
+								parent.layer.msg(data.info, {icon: 2});
+							}
+						}
+					});
+				}
+			});
+		});
+	</script>
+</body>
+</html>

+ 100 - 0
Application/Admin/View/Sys/admin_rule_edit.html

@@ -0,0 +1,100 @@
+<!--_meta 作为公共模版分离出去-->
+<!DOCTYPE HTML>
+<html>
+<head>
+	<include file="./Application/Admin/View/head.html" />
+	<link rel="stylesheet" type="text/css" href="/Public/lib/bootstrap-Switch/bootstrapSwitch.css" />
+</head>
+<body>
+<article class="page-container">
+	<form action="{:U('Sys/admin_rule_edit')}" method="post" class="form form-horizontal" id="form-admin-rule-edit">
+
+		<div class="row cl">
+			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>权限名称:</label>
+			<div class="formControls col-xs-8 col-sm-9">
+				<input type="text" class="input-text" value="{$rule.title}" placeholder="" id="title" name="title" style="width: 120px"/>
+			</div>
+		</div>
+		<div class="row cl">
+			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>父级:</label>
+			<div class="formControls col-xs-8 col-sm-9">
+				<span class="select-box">
+					<select name="pid" id="pid" class="select">
+						<option value="0">--顶级--</option>
+						<foreach name="admin_rule" item="v">
+							<option <if condition="$rule['pid'] eq $v['id']">selected = "selected"</if> value="{$v.id}" style="margin-left:55px;">{$v.lefthtml}{$v.title}</option>
+						</foreach>
+					</select>
+				</span>
+			</div>
+		</div>
+		<div class="row cl">
+			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>控制器/方法:</label>
+			<div class="formControls col-xs-8 col-sm-9">
+				<input type="text" class="input-text" value="{$rule.name}" placeholder="" id="name" name="name" style="width: 120px"/>
+			</div>
+		</div>
+
+		<div class="row cl">
+			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>是否启用:</label>
+			<div class="formControls col-xs-8 col-sm-9">
+				<select name="status" class="selectpicker" id="status">
+					<option <if condition="$rule['status'] eq 1">selected = "selected"</if> value="1">启用</option>
+					<option <if condition="$rule['status'] eq 0">selected = "selected"</if> value="0">禁用</option>
+				</select>
+			</div>
+		</div>
+		<div class="row cl">
+			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>是否显示:</label>
+			<div class="formControls col-xs-8 col-sm-9">
+				<select name="is_show" class="selectpicker" id="is_show">
+					<option <if condition="$rule['is_show'] eq 1">selected = "selected"</if> value="1">显示</option>
+					<option <if condition="$rule['is_show'] eq 0">selected = "selected"</if> value="0">不显示</option>
+				</select>
+			</div>
+		</div>
+		<div class="row cl">
+			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
+				<input type="hidden" name="id" value="{$rule.id}" id="id">
+				<button type="submit" class="btn btn-success radius" id="admin-role-save" name="admin-role-save"><i class="icon-ok"></i> 确定</button>
+			</div>
+		</div>
+	</form>
+</article>
+<!--_footer 作为公共模版分离出去-->
+<include file="./Application/Admin/View/foot.html" />
+<!--/_footer /作为公共模版分离出去-->
+
+<script>
+	$().ready(function() {
+
+		$("#form-admin-rule-edit").validate({
+			rules: {
+				role_name: {
+					required: true,
+					minlength: 2
+				},
+			},
+			success: "valid",
+			submitHandler: function() {
+				$.ajax({
+					type: "post",
+					url: "/Admin/Sys/admin_rule_edit",
+					data: {status: $('#status').val(),is_show: $('#is_show').val(),title: $('#title').val(), name: $('#name').val(), id: $('#id').val(), pid: $('#pid').val()},
+					success: function(data) {
+						if (data.status= '1') {
+							//加载层-风格3
+							parent.layer.load(2);
+							parent.layer.msg(data.info, {icon: 6});
+							parent.location.reload();
+							var index = parent.layer.getFrameIndex(window.name);
+							parent.layer.close(index);
+						}
+					}
+				});
+			}
+		});
+	});
+</script>
+</body>
+</html>

+ 0 - 14
Application/Common/Conf/db.php

@@ -16,20 +16,6 @@ return array(
     'DB_CHARSET' => 'utf8mb4',
     'DB_FIELDS_CACHE' => false, // 启用字段缓存
 
-
-    'DB_CONFIG_XMOTION' => array(
-        'db_type'  => 'mysql',
-        'db_name'  => 'x-motion.cn',
-        'db_user'  => CB_DB_USER,
-        'db_pwd'   => CB_DB_PWD,
-        'db_host'  => DB_HOST,
-        'db_port'  => '3306',
-        'DB_PREFIX' => 'r_', // 数据库表前缀
-        'DB_CHARSET' => 'utf8mb4',
-        'DB_FIELDS_CACHE' => false, // 启用字段缓存
-    ),
-
-
     /*
        'DB_DEPLOY_TYPE'    => 1, // 设置分布式数据库支持
        'DB_TYPE'           => 'mysql', //分布式数据库类型必须相同

+ 0 - 3
Application/Common/Model/AdMessageModel.class.php

@@ -11,9 +11,6 @@ use Common\Model\BaseModel;
  */
 class AdMessageModel extends BaseModel
 {
-    //使用x-motion.cn数据库
-    protected $connection ='DB_CONFIG_XMOTION';
-
     //广告代码参数名称
     const ad_code_name = 'adm';
 

+ 14 - 0
Application/Common/Model/AdminModel.class.php

@@ -0,0 +1,14 @@
+<?php
+namespace Common\Model;
+
+use Common\Model\BaseModel;
+
+class AdminModel extends BaseModel
+{
+    protected $mod;
+
+    public function __construct() {
+        parent::__construct();
+        $this->mod = M('admin');
+    }
+}

+ 0 - 3
Application/Common/Model/HomeCityModel.class.php

@@ -11,9 +11,6 @@ use Common\Model\BaseModel;
  */
 class HomeCityModel extends BaseModel
 {
-    //使用x-motion.cn数据库
-    protected $connection = 'DB_CONFIG_XMOTION';
-
     //软删状态
     const status_del = 0;     //删除
     const status_on = 1;      //正常

+ 0 - 3
Application/Common/Model/HomeNewModel.class.php

@@ -11,9 +11,6 @@ use Common\Model\BaseModel;
  */
 class HomeNewModel extends BaseModel
 {
-    //使用x-motion.cn数据库
-    protected $connection = 'DB_CONFIG_XMOTION';
-
     //软删状态
     const status_del = 0;     //删除
     const status_on = 1;      //正常

+ 0 - 3
Application/Common/Model/HomeStoresModel.class.php

@@ -11,9 +11,6 @@ use Common\Model\BaseModel;
  */
 class HomeStoresModel extends BaseModel
 {
-    //使用x-motion.cn数据库
-    protected $connection = 'DB_CONFIG_XMOTION';
-
     //软删状态
     const status_del = 0;     //删除
     const status_on = 1;      //正常

+ 0 - 4
Application/Common/Model/HomeSubscriptionModel.class.php

@@ -11,10 +11,6 @@ use Common\Model\BaseModel;
  */
 class HomeSubscriptionModel extends BaseModel
 {
-
-    //使用x-motion.cn数据库
-    protected $connection = 'DB_CONFIG_XMOTION';
-
     protected $mod;
 
     //状态

+ 0 - 4
Application/Common/Model/MessageBoardModel.class.php

@@ -11,10 +11,6 @@ use Common\Model\BaseModel;
  */
 class MessageBoardModel extends BaseModel
 {
-
-    //使用x-motion.cn数据库
-    protected $connection ='DB_CONFIG_XMOTION';
-
     protected $mod;
 
     //状态

+ 0 - 3
Application/Common/Model/StoreApplicationModel.class.php

@@ -11,9 +11,6 @@ use Common\Model\BaseModel;
  */
 class StoreApplicationModel extends BaseModel
 {
-    //使用x-motion.cn数据库
-    protected $connection ='DB_CONFIG_XMOTION';
-
     protected $mod;
 
     //状态