<!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;">
    <form id="formId" onsubmit="return false;">

        <div class="layui-form-item">
            <label class="layui-form-label">提现金额</label>
            <div class="layui-input-inline">
                <input type="number" class="layui-input" name="userAskDeposits">
            </div>
        </div>
        <button class="layui-btn" style="display: none;" id="saveBtn" onclick="save()"></button>
    </form>
</div>
<script>

    layui.use('form', function () {
        var form = layui.form;
        form.render();
    });
    var b = true;

    function save() {
        var userAskDeposits = $("#formId input[name='userAskDeposits']").val();
        if (userAskDeposits == '') {
            layer.msg("提现金额不能为空!");
            return false;
        }

        if (!b) {
            return false;
        }
        b = false;
        var form = document.querySelector("#formId");
        var formdata = new FormData(form);
        formdata.append("userId", '[[${id}]]');
        $.ajax({
            url: "askForRebate",
            data: formdata,
            type: "POST",
            dataType: "json",
            processData: false,
            contentType: false,
            success: function (result) {
                b = true;
                if (result.code == 100) {
                    layer.msg(result.msg, {icon: 6, time: 1000}, function () {
                        closeLayer();
                        parent.layui.table.reload('tableId');
                    });
                } else {
                    layer.msg(result.msg, {icon: 5});
                }
            }
        });
    }

    function closeLayer() {
        var index = parent.layer.getFrameIndex(window.name);
        //关闭当前frame
        parent.layer.close(index);
    }

</script>
</body>

</html>