<?php /*a:3:{s:67:"/home/affivpnx/app.peakwork.pro/app/admin/view/member/user_add.html";i:1770136113;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>

<style>
    .layui-form-selected dl {
        z-index: 1000;
    }
</style>

<body>
    <div class="layui-fluid">
        <div class="layui-row">
            <form class="layui-form">
                <input type="hidden" name="id" value="<?php echo htmlentities($id); ?>">
                <div class="layui-form-item">
                    <label for="username" class="layui-form-label">Phone Number</label>
                    <div class="layui-input-inline">
                        <input type="text" id="username" name="username" lay-verify="name" autocomplete="off"
                            class="layui-input" value="<?php echo htmlentities((isset($info['username']) && ($info['username'] !== '')?$info['username']:'')); ?>" <?php if($id > 0): ?>disabled<?php endif; ?>>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="nickname" class="layui-form-label">昵称</label>
                    <div class="layui-input-inline">
                        <input type="text" id="nickname" name="nickname" lay-verify="name" autocomplete="off"
                            class="layui-input" value="<?php echo htmlentities((isset($info['nickname']) && ($info['nickname'] !== '')?$info['nickname']:'')); ?>">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="credit_score" class="layui-form-label">信用分</label>
                    <div class="layui-input-inline">
                        <input type="number" id="credit_score" name="credit_score" lay-verify="required"
                            autocomplete="off" class="layui-input" value="<?php echo htmlentities((isset($info['credit_score']) && ($info['credit_score'] !== '')?$info['credit_score']:'100')); ?>">
                    </div>
                </div>
                <?php if($id == 0): ?>
                <div class="layui-form-item">
                    <label for="password" class="layui-form-label">登录密码</label>
                    <div class="layui-input-inline">
                        <input type="text" id="password" name="password" lay-verify="name" autocomplete="off"
                            class="layui-input" value="">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="deal_pass" class="layui-form-label">取款密码</label>
                    <div class="layui-input-inline">
                        <input type="text" id="deal_pass" name="deal_pass" lay-verify="name" autocomplete="off"
                            class="layui-input" value="">
                    </div>
                </div>
                <?php endif; ?>
                <div class="layui-form-item">
                    <label for="level_id" class="layui-form-label">VIP等级</label>
                    <div class="layui-input-inline">
                        <select name="level_id" id="level_id">
                            <?php if(is_array($level) || $level instanceof \think\Collection || $level instanceof \think\Paginator): if( count($level)==0 ) : echo "" ;else: foreach($level as $key=>$le): ?>
                            <option value="<?php echo htmlentities($le['id']); ?>" <?php if($info['level_id'] == $le['id']): ?>selected<?php endif; ?>><?php echo htmlentities($le['name']); ?>
                            </option>
                            <?php endforeach; endif; else: echo "" ;endif; ?>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="pid" class="layui-form-label">上级id</label>
                    <div class="layui-input-inline">
                        <input type="text" name="pid" id="pid" autocomplete="off" class="layui-input"
                            value="<?php echo htmlentities((isset($info['pid']) && ($info['pid'] !== '')?$info['pid']:'0')); ?>">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">
                    </label>
                    <button class="layui-btn" lay-filter="add" lay-submit="">
                        <?php if($id == 0): ?>增加<?php else: ?>更新<?php endif; ?>
                    </button>
                </div>
            </form>
        </div>
    </div>
    <script type="text/javascript">
        layui.use(['form'], function () {
            var form = layui.form;

            //自定义验证规则
            form.verify({
                name: function (val) {
                    if (val.length < 2) {
                        return '至少2个字符';
                    }
                },
                image: function (val) {
                    if (val == '') {
                        return '请上传图片';
                    }
                },
            });

            //监听提交
            form.on('submit(add)', function (data) {
                //发异步，把数据提交给php
                $.ajax({
                    url: '<?php echo url("admin/Member/userAdd"); ?>',
                    type: 'post',
                    data: data.field,
                    dataType: 'json',
                    success: function (res) {
                        if (res.status == '200') {
                            tipAction(1, res.msg);
                            setTimeout(function () {
                                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>
