<?php /*a:3:{s:96:"/home/u833649990/domains/beyondtravel.tours/public_html/app/app/admin/view/member/level_add.html";i:1763702585;s:93:"/home/u833649990/domains/beyondtravel.tours/public_html/app/app/admin/view/public/header.html";i:1763702586;s:93:"/home/u833649990/domains/beyondtravel.tours/public_html/app/app/admin/view/public/footer.html";i:1763702586;}*/ ?>
<!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="name" class="layui-form-label">
                    <span class="x-red">*</span>名称
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="name" name="name" lay-verify="name"
                           autocomplete="off" class="layui-input" value="<?php echo htmlentities((isset($info['name']) && ($info['name'] !== '')?$info['name']:'')); ?>">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">图片</label>
                <div class="layui-input-inline" id="uploadControl">
                    <div class="layui-upload-drag <?php if(!(empty($info['img']) || (($info['img'] instanceof \think\Collection || $info['img'] instanceof \think\Paginator ) && $info['img']->isEmpty()))): ?>layui-hide<?php endif; ?>">
                        <i class="layui-icon" style="font-size: 30px"></i>
                        <p>点击上传，或将文件拖拽到此处</p>
                    </div>
                    <div class="<?php if(empty($info['img']) || (($info['img'] instanceof \think\Collection || $info['img'] instanceof \think\Paginator ) && $info['img']->isEmpty())): ?>layui-hide<?php endif; ?>" id="uploadView">
                        <img src="<?php echo htmlentities((isset($info['img']) && ($info['img'] !== '')?$info['img']:'')); ?>" alt="上传成功后渲染" style="max-width: 200px" width="100%">
                    </div>
                    <input type="hidden" name="img" value="<?php echo htmlentities((isset($info['img']) && ($info['img'] !== '')?$info['img']:'')); ?>">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="order_num" class="layui-form-label">
                    <span class="x-red">*</span>每日订单量
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="order_num" name="order_num" lay-verify="num"
                           autocomplete="off" class="layui-input" value="<?php echo htmlentities((isset($info['order_num']) && ($info['order_num'] !== '')?$info['order_num']:'')); ?>">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="order_num" class="layui-form-label">
                    <span class="x-red">*</span>任务轮
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="ring" name="ring" lay-verify="num"
                           autocomplete="off" class="layui-input" value="<?php echo htmlentities((isset($info['ring']) && ($info['ring'] !== '')?$info['ring']:'')); ?>">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="limit_price" class="layui-form-label">
                    <span class="x-red">*</span>限制金额
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="limit_price" name="limit_price"
                           autocomplete="off" class="layui-input" value="<?php echo htmlentities((isset($info['limit_price']) && ($info['limit_price'] !== '')?$info['limit_price']:'')); ?>">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>做单可用余额限制
                </div>
            </div>
            <div class="layui-form-item">
                <label for="reward_price" class="layui-form-label">
                    <span class="x-red">*</span>升级奖励
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="reward_price" name="reward_price"
                           autocomplete="off" class="layui-input" value="<?php echo htmlentities((isset($info['reward_price']) && ($info['reward_price'] !== '')?$info['reward_price']:'')); ?>">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>购买会员所返给的金额
                </div>
            </div>
            <div class="layui-form-item">
                <label for="price" class="layui-form-label">
                    <span class="x-red">*</span>等级价格
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="price" name="price" lay-verify="price"
                           autocomplete="off" class="layui-input" value="<?php echo htmlentities((isset($info['price']) && ($info['price'] !== '')?$info['price']:'')); ?>">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>购买会员金额
                </div>
            </div>
            <div class="layui-form-item">
                <label for="withdraw_min" class="layui-form-label">
                    <span class="x-red">*</span>提现最小金额
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="withdraw_min" name="withdraw_min" lay-verify="price"
                           autocomplete="off" class="layui-input" value="<?php echo htmlentities((isset($info['withdraw_min']) && ($info['withdraw_min'] !== '')?$info['withdraw_min']:'')); ?>">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="withdraw_max" class="layui-form-label">
                    <span class="x-red">*</span>提现最大金额
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="withdraw_max" name="withdraw_max" lay-verify="price"
                           autocomplete="off" class="layui-input" value="<?php echo htmlentities((isset($info['withdraw_max']) && ($info['withdraw_max'] !== '')?$info['withdraw_max']:'')); ?>">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="withdraw_min" class="layui-form-label">
                    <span class="x-red">*</span>充值最小金额
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="withdraw_min" name="charge_min" lay-verify="price"
                           autocomplete="off" class="layui-input" value="<?php echo htmlentities((isset($info['charge_min']) && ($info['charge_min'] !== '')?$info['charge_min']:'')); ?>">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="withdraw_max" class="layui-form-label">
                    <span class="x-red">*</span>充值最大金额
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="withdraw_max" name="charge_max" lay-verify="price"
                           autocomplete="off" class="layui-input" value="<?php echo htmlentities((isset($info['charge_max']) && ($info['charge_max'] !== '')?$info['charge_max']:'')); ?>">
                </div>
            </div>

            <div class="layui-form-item">
                <label for="withdraw_rate" class="layui-form-label">
                    <span class="x-red">*</span>手续费率
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="withdraw_rate" name="withdraw_rate" autocomplete="off" class="layui-input"
                           value="<?php echo htmlentities((isset($info['withdraw_rate']) && ($info['withdraw_rate'] !== '')?$info['withdraw_rate']:'0')); ?>">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>提现金额*所填数字
                </div>
            </div>
            <div class="layui-form-item">
                <label for="order_rate" class="layui-form-label">
                    <span class="x-red">*</span>订单佣金比例
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="order_rate" name="order_rate" autocomplete="off" class="layui-input"
                           value="<?php echo htmlentities((isset($info['order_rate']) && ($info['order_rate'] !== '')?$info['order_rate']:'0')); ?>">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>订单金额*所填数字
                </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>
                <a class="layui-btn" href="/admin/Member/levelList">返回</a>
            </div>
        </form>
    </div>
</div>
<script type="text/javascript">
    layui.use(['form', 'upload'], function () {
        var form = layui.form, upload = layui.upload;
        //拖拽上传
        upload.render({
            elem: '#uploadControl'
            , url: '<?php echo url("admin/Index/upload"); ?>' //此处用的是第三方的 http 请求演示，实际使用时改成您自己的上传接口即可。
            , accept: 'images' //允许上传的文件类型
            , field: 'file'//设定文件域的字段名
            , done: function (res) {
                //上传完毕
                if (res.status == '200') {
                    tipAction(1, res.msg);
                    $('.layui-upload-drag').addClass('layui-hide');
                    layui.$('#uploadView').removeClass('layui-hide').find('img').attr('src', res.data.file);
                    $('#uploadView').next().val(res.data.file);
                } else {
                    tipAction(2, res.msg);
                }
            }
            , error: function () {
                tipAction(2, '系统繁忙');
            }
        });

        //自定义验证规则
        form.verify({
            name: function (val) {
                if (val.length < 1) {
                    return '标题至少1个字符';
                }
            },
            num: [/^[0-9]\d*/, '请输入正确的数字'],
            price: [/^[1-9]\d*\.\d*|^[1-9]\d*/, '请输入正确的价格'],
        });

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

