<?php /*a:3:{s:69:"/home/affivpnx/app.peakwork.pro/app/admin/view/system/manage_add.html";i:1763742186;s:65:"/home/affivpnx/app.peakwork.pro/app/admin/view/public/header.html";i:1763742186;s:65:"/home/affivpnx/app.peakwork.pro/app/admin/view/public/footer.html";i:1763742186;}*/ ?>
<!doctype html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>后台登录-<?php echo htmlentities($system_name); ?></title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link rel="stylesheet" href="/static/admin/css/font.css">
    <link rel="stylesheet" href="/static/admin/css/xadmin.css">
    <script type="text/javascript" src="/static/admin/js/jquery.min.js"></script>
    <!-- <link rel="stylesheet" href="./css/theme5.css"> -->
    <script src="/static/admin/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/static/admin/js/xadmin.js?date=<?php echo date('Ymd'); ?>"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="/static/admin/js/html5.min.js"></script>
    <script src="/static/admin/js/respond.min.js"></script>
    <![endif]-->
</head>

<body>
<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form">
            <input type="hidden" name="id" value="<?php echo htmlentities($admin_id); ?>">
            <div class="layui-form-item">
                <label for="username" class="layui-form-label">
                    <span class="x-red">*</span>用户名/Network
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="username" name="username" lay-verify="username"
                           autocomplete="off" class="layui-input" value="<?php echo htmlentities((isset($info['username']) && ($info['username'] !== '')?$info['username']:'')); ?>"
                           <?php if($admin_id > 0): ?>disabled<?php endif; ?>>
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>将会成为您唯一的登入名
                </div>
            </div>
            <div class="layui-form-item">
                <label for="L_pass" class="layui-form-label">密码</label>
                <div class="layui-input-inline">
                    <input type="password" id="L_pass" name="password" lay-verify="pass" autocomplete="off"
                           class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    6到16个字符
                </div>
            </div>
            <div class="layui-form-item">
                <label for="L_repass" class="layui-form-label">确认密码</label>
                <div class="layui-input-inline">
                    <input type="password" id="L_repass" lay-verify="repass" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="role_id" class="layui-form-label">
                    <span class="x-red">*</span>角色
                </label>
                <div class="layui-input-inline">
                    <select name="role_id" id="role_id">
                        <?php if(is_array($role_list) || $role_list instanceof \think\Collection || $role_list instanceof \think\Paginator): if( count($role_list)==0 ) : echo "" ;else: foreach($role_list as $key=>$vo): ?>
                        <option value="<?php echo htmlentities($vo['id']); ?>" <?php if($info['role_id'] == $vo['id']): ?>selected<?php endif; ?>><?php echo htmlentities($vo['title']); ?></option>
                        <?php endforeach; endif; else: echo "" ;endif; ?>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="L_repass" class="layui-form-label">
                </label>
                <button class="layui-btn" lay-filter="add" lay-submit="">
                    <?php if($admin_id == 0): ?>增加<?php else: ?>更新<?php endif; ?>
                </button>
            </div>
        </form>
    </div>
</div>
<script type="text/javascript">
    layui.use(['form', 'layer'],
        function () {
            $ = layui.jquery;
            var form = layui.form,
                layer = layui.layer;
            var pass_reg = /^(?=.*[a-zA-Z])(?=.*\d)(?=.*[~!@#$%^&*()_+`\-={}:";'<>?,.\/]).{6,16}$/;

            //自定义验证规则
            form.verify({
                username: function (val) {
                    if (val.length < 2) {
                        return '用户名/Network至少2个字符';
                    }
                    var reg = new RegExp("[\\u4E00-\\u9FFF]+", "g");
                    if (reg.test(val)) {
                        return '用户名/Network不能有中文';
                    }
                },
                pass: function (val) {
                    if (val != '') {
                        if (val.length < 6) {
                            return '密码长度必须6-16';
                        }
                        if (!pass_reg.test(val))
                            return '密码必须由6-16位字母、数字、特殊符号组成';
                    }
                },
                repass: function (value) {
                    if ($('#L_pass').val() != $('#L_repass').val()) {
                        return '两次密码不一致';
                    }
                }
            });

            //监听提交
            form.on('submit(add)', function (data) {
                console.log(data.field);
                //发异步，把数据提交给php
                $.ajax({
                    url: '<?php echo url("admin/System/manageAdd"); ?>',
                    type: 'post',
                    data: data.field,
                    dataType: 'json',
                    success: function (res) {
                        if (res.status == '200') {
                            tipAction(1, res.msg);
                            setTimeout(function () {
                                // 获得frame索引
                                // var index = parent.layer.getFrameIndex(window.name);
                                //关闭当前frame
                                // parent.layer.close(index);
                                parent.location.reload();
                            }, 1000);
                        } else {
                            tipAction(2, res.msg);
                        }
                    },
                    error: function () {
                        tipAction(2, '系统繁忙,请重试');
                    }
                });
                return false;
            });
        });
</script>
</body>
</html>
<script type="application/javascript">
    /**
     * 统一接口返回提示弹窗
     * type 1-成功 2-失败
     * info 提示信息
     * */
    function tipAction(type, info) {
        layer.msg(info, {icon: type, time: 1500})
    }

    //图片放大
    function showBig(obj) {
        let img_src = $(obj).attr('src');
        layer.open({
            type: 1,
            area: ['70%', 'auto'],
            shadeClose: true,
            title: false,
            closeBtn: false,
            content: `<div style=""><img src="${img_src}" alt="" width="100%"></div>`
        });
    }
</script>

