<?php
/**
 * 网站编辑
 */
$title = '网站编辑';
include "header.php";

?>
<div class="row">
    <div class="col-xl-12">
        <div class="card">
            <div class="card-body">
                <div class="row">
                    <div class="col-md-12">
                        <h3 class="mb-3 header-title text-success"><?= $title ?></h3>
                        <form class="form-horizontal layui-form">
                            <div class="form-group mb-3">
                                <label for="example-input-normal" style="font-weight: 500">网站名称</label>
                                <input type="text" name="sitename" lay-verify="required"
                                       class="form-control" value="<?= $conf['sitename'] ?>" placeholder="请输入站点名称">
                            </div>
                            <div class="form-group mb-3">
                                <label for="example-input-normal" style="font-weight: 500">网站关键词</label>
                                <input type="text" name="keywords" lay-verify="required"
                                       class="form-control" value="<?= $conf['keywords'] ?>" placeholder="请输入站点名称">
                            </div>
                            <div class="form-group mb-3">
                                <label for="example-input-normal" style="font-weight: 500">网站描述语</label>
                                <input type="text" name="description" lay-verify="required"
                                       class="form-control" value="<?= $conf['description'] ?>" placeholder="请输入站点名称">
                            </div>
                            <div class="form-group mb-3">
                                <label for="example-input-normal" style="font-weight: 500">客服QQ</label>
                                <input type="text" name="kfqq" lay-verify="required"
                                       class="form-control" value="<?= $conf['kfqq'] ?>" placeholder="请输入客服QQ">
                            </div>
                            <div class="form-group mb-3">
                                <label for="example-input-normal" style="font-weight: 500">官方群链接</label>
                                <input type="text" name="Communication" lay-verify="required"
                                       class="form-control" value="<?= $conf['Communication'] ?>"
                                       placeholder="请输入官方群链接">
                            </div>
                            <div class="form-group mb-3">
                                <label for="example-input-normal" style="font-weight: 500">邀请奖励</label>
                                <input type="text" name="award" lay-verify="required"
                                       class="form-control" value="<?= $conf['award'] ?>"
                                       placeholder="每邀请1人奖励的<?= $conf['currency'] ?>数量">
                            </div>
                            <div class="form-group mb-3">
                                <label for="example-input-normal" style="font-weight: 500">货币名称</label>
                                <input type="text" name="currency" lay-verify="required"
                                       class="form-control" value="<?= $conf['currency'] ?>" placeholder="网站货币的名称">
                            </div>
                            <div class="form-group mb-3">
                                <label for="example-input-normal" style="font-weight: 500">签到赠送</label>
                                <input type="text" name="Signin" lay-verify="required"
                                       class="form-control" value="<?= $conf['Signin'] ?>"
                                       placeholder="每天签到奖励的<?= $conf['currency'] ?>数量">
                            </div>
                            <div class="form-group mb-3">
                                <label for="example-input-normal" style="font-weight: 500">免费商品或积分商品每日兑换限制<font
                                            color="red">(单一用户)</font></label>
                                <input type="text" name="getinreturn" lay-verify="required"
                                       class="form-control" value="<?= $conf['getinreturn'] ?>"
                                       placeholder="每日单一用户可用积分兑换商品的次数(包含免费商品)">
                            </div>

                            <div class="form-group mb-3">
                                <label for="example-input-normal" style="font-weight: 500">免费商品或积分商品每日兑换限制<font
                                            color="red">(整个站点)</font></label>
                                <input type="text" name="getinreturn_all" lay-verify="required"
                                       class="form-control" value="<?= $conf['getinreturn_all'] ?>"
                                       placeholder="每日整个网站可用积分兑换商品的次数(包含免费商品)">
                            </div>

                            <div class="form-group mb-3">
                                <label for="example-input-normal" style="font-weight: 500">API对接密钥</label>
                                <input type="text" name="secret" lay-verify="required"
                                       class="form-control" value="<?= $conf['secret'] ?>"
                                       placeholder="调用后台接口时使用！">
                            </div>

                            <div class="form-group mb-3">
                                <label for="example-input-normal" style="font-weight: 500">下单违禁词 <font color="red">(若下单信息中包含下列关键词则无法购买商品,多个请使用英文逗号分割)</font></label>
                                <input type="text" name="blacklist"
                                       class="form-control" value="<?= $conf['blacklist'] ?>"
                                       placeholder="请使用英文逗号分割！">
                            </div>

                            <div class="form-group mb-3">
                                <label for="example-input-normal" style="font-weight: 500">安全中心 <font color="red">关闭后不再记录用户访问日志</font> <a href="admin.security.center.php">进入</a></label>
                                <select class="custom-select mt-3" lay-search name="SecurityCenter">
                                    <option <?= $conf['SecurityCenter'] == 1 ? 'selected' : '' ?> value="1">开启整站日志监控
                                    </option>
                                    <option <?= $conf['SecurityCenter'] == -1 ? 'selected' : '' ?> value="-1">关闭整站日志监控
                                    </option>
                                </select>
                            </div>

                            <div class="form-group mb-3">
                                <label for="example-input-normal" style="font-weight: 500">代付款分享语句 <font color="red">可用参数：[url] = 付款链接</font></label>
                                <input type="text" name="share_url" lay-verify="required"
                                       class="form-control" value="<?= $conf['share_url'] ?>"
                                       placeholder="[url] = 付款链接">
                            </div>

                            <div class="form-group mb-3">
                                <label for="example-input-normal" style="font-weight: 500">logo地址</label>
                                <div class="input-group">
                                    <input type="text" lay-verify="required" lay-verType="tips"
                                           class="form-control" name="logo" id="image" value="<?= $conf['logo'] ?>"
                                           placeholder="网站logo的地址"/>
                                    <div class="input-group-append">
                                                <span class="input-group-text" id="upload"
                                                      style="cursor: pointer">上传</span>
                                    </div>
                                    <div class="input-group-append">
                                                <span class="input-group-text"
                                                      onclick="layer.alert('<img src=\''+$('#image').val()+'\' style=width:100%  />')"
                                                      style="cursor: pointer;background-color: slateblue;color: white">预览</span>
                                    </div>
                                    <div class="input-group-append">
                                        <a href="http://cdn.vue8.cn/s/pieoksig"
                                           target="_blank" class="input-group-text"
                                           style="cursor: pointer;background-color: #a8f46b;color: white">图库</a>
                                    </div>
                                </div>
                            </div>
                            <button type="submit" lay-submit lay-filter="Web_editor"
                                    class="btn btn-block btn-xs btn-success">保存内容
                            </button>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


<?php include "bottom.php"; ?>

<script>
    layui.use('form', function () {
        var form = layui.form;
        form.on('submit(Web_editor)', function (data) {
            layer.alert('是否要执行当前操作？', {
                icon: 3, btn: ['确定', '取消'], btn1: function (layero, index) {
                    var index = layer.msg('数据保存中,请稍后...', {icon: 16, time: 999999});
                    $.post('ajax.php?act=config_set', data.field, function (res) {
                        if (res.code == 1) {
                            layer.close(index);
                            layer.alert(res.msg, {
                                btn1: function (layero, index) {
                                    location.reload();
                                }
                            });
                        } else {
                            layer.close(index);
                            layer.alert(res.msg, {
                                btn1: function (layero, index) {
                                    location.reload();
                                }
                            });
                        }
                    });
                }
            });
            return false;
        })
    });
    layui.use(['upload', 'form'], function () {
        var upload = layui.upload;
        var uploadInst = upload.render({
            elem: '#upload' //绑定元素
            , url: 'ajax.php?act=image_up' //上传接口
            , done: function (res, index, upload) {
                layer.msg('图片上传成功');
                $("#image").val(res.src);
                $("#image_base").attr('src', res.src);
            }
            , error: function () {
                layer.msg('图片上传失败!')
            }
        });
    });
</script>


