<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>后台管理系统</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <link rel="shortcut icon" th:href="@{/images/logo.jpg}"/>
    <link rel="stylesheet" th:href="@{/js/layui/css/layui.css}">
    <link rel="stylesheet" th:href="@{/js/layui/css/admin.css}">
    <script type="text/javascript" th:src="@{/js/jquery-3.3.1.min.js}"></script>
    <script th:src="@{/js/layui/layui.js}" charset="utf-8"></script>
</head>
<body>
<div class="layui-form" style="padding: 20px 0 0 0;">
    <div style="float: right;padding-right: 50px">
        <button class="layui-btn layuiadmin-button-btn" onclick="javascript:location.replace(location.href);">
            <i class="layui-icon layui-icon-refresh-3 layuiadmin-button-btn">
            </i>
        </button>
    </div>
    <form id="formId" onsubmit="return false;">


        <div>
            <label class="layui-form-label"><span style="color: red">*</span>初级签单</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" style="width: 600px;" id="dprimarycms" th:value="${list.dprimarycms}"
                       placeholder="请设置初级会员签单收益(百分比) ">
                <button style="position: absolute;top: 0;right: 0; cursor: pointer;" type="button" class="layui-btn layui-btn-disabled">%</button>
            </div>
        </div>
        <div>
            <label class="layui-form-label"><span style="color: red">*</span>中级签单</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" style="width: 600px;" id="dintercms" th:value="${list.dintercms}"
                       placeholder="请设置中级会员签单收益(百分比) ">
                <button style="position: absolute;top: 0;right: 0; cursor: pointer;" type="button" class="layui-btn layui-btn-disabled">%</button>
            </div>
        </div>
        <div>
            <label class="layui-form-label"><span style="color: red">*</span>高级签单</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" style="width: 600px;" id="dseniorcms" th:value="${list.dseniorcms}"
                       placeholder="请设置高级会员签单收益(百分比) ">
                <button style="position: absolute;top: 0;right: 0; cursor: pointer;" type="button" class="layui-btn layui-btn-disabled">%</button>
            </div>
        </div>



        <div>
            <label class="layui-form-label"><span style="color: red">*</span>初级推荐</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" style="width: 600px;" id="dprimarytj" th:value="${list.dprimarytj}"
                       placeholder="请设置初级会员推荐奖(百分比) ">
                <button style="position: absolute;top: 0;right: 0; cursor: pointer;" type="button" class="layui-btn layui-btn-disabled">%</button>
            </div>
        </div>
        <div>
            <label class="layui-form-label"><span style="color: red">*</span>中级推荐</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" style="width: 600px;" id="dintertj" th:value="${list.dintertj}"
                       placeholder="请设置中级会员推荐奖(百分比) ">
                <button style="position: absolute;top: 0;right: 0; cursor: pointer;" type="button" class="layui-btn layui-btn-disabled">%</button>
            </div>
        </div>
        <div>
            <label class="layui-form-label"><span style="color: red">*</span>高级推荐</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" style="width: 600px;" id="dseniortj" th:value="${list.dseniortj}"
                       placeholder="请设置高级会员推荐奖(百分比) ">
                <button style="position: absolute;top: 0;right: 0; cursor: pointer;" type="button" class="layui-btn layui-btn-disabled">%</button>
            </div>
        </div>



        <div>
            <label class="layui-form-label"><span style="color: red">*</span>团队津贴</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" style="width: 600px;" id="dzcommiss" th:value="${list.dzcommiss}"
                       placeholder="请设置总业绩团队津贴(百分比) ">
                <button style="position: absolute;top: 0;right: 0; cursor: pointer;" type="button" class="layui-btn layui-btn-disabled">%</button>
            </div>
        </div>


        <div>
            <label class="layui-form-label"><span style="color: red">*</span>一级津贴</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" style="width: 600px;" id="dlv1commiss" th:value="${list.dlv1commiss}"
                       placeholder="请设置一级津贴(百分比) ">
                <button style="position: absolute;top: 0;right: 0; cursor: pointer;" type="button" class="layui-btn layui-btn-disabled">%</button>
            </div>

        </div>

        <div>
            <label class="layui-form-label"><span style="color: red">*</span>二级津贴</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" style="width: 600px;" id="dlv2commiss" th:value="${list.dlv2commiss}"
                       placeholder="请设置二级津贴(百分比) ">
                <button style="position: absolute;top: 0;right: 0; cursor: pointer;" type="button" class="layui-btn layui-btn-disabled">%</button>
            </div>

        </div>

        <div>
            <label class="layui-form-label"><span style="color: red">*</span>消费金额</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" style="width: 600px;" id="dxfmoeny" th:value="${list.dxfmoeny}"
                       placeholder="请设置赠送会员累计消费金额">
                <button style="position: absolute;top: 0;right: 0; cursor: pointer;" type="button" class="layui-btn layui-btn-disabled">元</button>
            </div>

        </div>

        <div>
            <label class="layui-form-label"><span style="color: red">*</span>关于我们</label>
            <div class="layui-input-inline">
                <textarea class="layui-input" style="width: 600px;height: 150px;" id="suserule" th:utext="${list.suserule}"
                          placeholder="请输入关于我们"></textarea>
            </div>

        </div>
        <div>
            <label class="layui-form-label"><span style="color: red">*</span>用户协议</label>
            <div class="layui-input-inline">
                <textarea class="layui-input" style="width: 600px;height: 150px;" id="sprotocol" th:utext="${list.sprotocol}"
                          placeholder="请输入用户协议"></textarea>
            </div>
            <div class="layui-input-inline">
                <button class="layui-btn" onclick="save()">保存</button>
            </div>
        </div>


    </form>
</div>
<script>
    var w = ($(window).width() * 0.7);
    var h = ($(window).height() * 0.5);
    $(".layui-input").width(w);
    $("textarea").height(h);
    layui.use('form', function () {
        var form = layui.form;
        form.render();
    });

    function save() {


        var id = '[[${list.id}]]';



        var dprimarycms = $("#dprimarycms").val().trim();
        if (dprimarycms == '') {
            layer.msg("初级会员签单收益不能为空!");
            return false;
        }


        var dintercms = $("#dintercms").val().trim();
        if (dintercms == '') {
            layer.msg("中级会员签单收益不能为空!");
            return false;
        }


        var dseniorcms = $("#dseniorcms").val().trim();
        if (dseniorcms == '') {
            layer.msg("高级会员签单收益不能为空!");
            return false;
        }


        var dprimarytj = $("#dprimarytj").val().trim();
        if (dprimarytj == '') {
            layer.msg("初级会员推荐奖不能为空!");
            return false;
        }


        var dintertj = $("#dintertj").val().trim();
        if (dintertj == '') {
            layer.msg("中级会员推荐奖不能为空!");
            return false;
        }


        var dseniortj = $("#dseniortj").val().trim();
        if (dseniortj == '') {
            layer.msg("高级会员推荐奖不能为空!");
            return false;
        }



        var dzcommiss = $("#dzcommiss").val().trim();
        if (dzcommiss == '') {
            layer.msg("总业务团队津贴不能为空!");
            return false;
        }


        var dlv1commiss = $("#dlv1commiss").val().trim();
        if (dlv1commiss == '') {
            layer.msg("一级津贴不能为空!");
            return false;
        }

        var dlv2commiss = $("#dlv2commiss").val().trim();
        if (dlv2commiss == '') {
            layer.msg("二级津贴不能为空!");
            return false;
        }

        var dxfmoeny = $("#dxfmoeny").val().trim();
        if (dxfmoeny == '') {
            layer.msg("累计金额不能为空!");
            return false;
        }



        var suserule = $("#suserule").val().trim();
        if (suserule == '') {
            layer.msg("关于我们不能为空!");
            return false;
        }

        var sprotocol = $("#sprotocol").val().trim();
        if (sprotocol == '') {
            layer.msg("服务协议不能为空!");
            return false;
        }


        var param = {};
        param.id = id;
        param.dprimarycms = dprimarycms;
        param.dintercms = dintercms;
        param.dseniorcms = dseniorcms;
        param.dprimarytj = dprimarytj;
        param.dintertj = dintertj;
        param.dseniortj = dseniortj;
        param.dzcommiss = dzcommiss;
        param.dlv1commiss = dlv1commiss;
        param.dlv2commiss = dlv2commiss;
        param.dxfmoeny = dxfmoeny;
        param.suserule = suserule;
        param.sprotocol = sprotocol;

        // var form = document.querySelector("#formId");
        // var formdata = new FormData(form);
        // formdata.append("id", id);
        // formdata.append("sprotocol", sprotocol);
        // formdata.append("suserule", suserule);
        $.ajax({
            url: "updateById",
            data: JSON.stringify(param),
            type: "POST",
            dataType: "json",
            contentType: "application/json;charset=utf-8",
            success: function (result) {
                if (result.code == 0) {
                    layer.msg("恭喜您,提交成功");
                } else {
                    layer.msg(result.msg, {icon: 5});
                }
            }
        });
    }



    function xmTanUploadImg(obj, id) {
        var file = obj.files[0];
        var reader = new FileReader();
        //读取文件过程方法
        reader.onloadstart = function (e) {
            console.log("开始读取....");
        }
        reader.onprogress = function (e) {
            console.log("正在读取中....");
        }
        reader.onabort = function (e) {
            console.log("中断读取....");
        }
        reader.onerror = function (e) {
            console.log("读取异常....");
        }
        reader.onload = function (e) {
            console.log("成功读取....");
            var img = document.getElementById(id + 'img');
            img.src = e.target.result;
        }
        reader.readAsDataURL(file);
    }

    function chioceImage(i) {
        $('#file' + i).trigger("click");
    }
</script>
</body>

</html>