<!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;">

        <input type="hidden" class="layui-input"  th:value="${obj.id}" name="id">




        <div class="layui-form-item">
            <label class="layui-form-label">自取地址</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" id="address" th:value="${obj.address}"  name="address" style="width: 600px">
            </div>
        </div>



        <div class="layui-form-item">
            <label class="layui-form-label">地址名称</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" id="title" th:value="${obj.title}"  name="title" >
            </div>
        </div>


        <div class="layui-form-item">
            <label class="layui-form-label">地址电话</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" id="phone" th:value="${obj.phone}" name="phone">

            </div>
        </div>


        <div class="layui-form-item">
            <label class="layui-form-label">经度</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" id="lng" th:value="${obj.lng}" name="lng">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">纬度</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" id="lat" th:value="${obj.lat}" name="lat">
            </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();
    });

    function save() {
        var address = $("#formId input[id='address']").val();
        if (address == '') {
            layer.msg("自取地址不能为空!");
            return false;
        }

        if ($("#phone").val() == '') {
            layer.msg("请填写电话!");
            return false;
        }

        var formdata = $("#formId").serialize()
        $.ajax({
            url: "addMapCoordinate",
            data: formdata,
            type: "POST",
            dataType: "json",
            success: function (result) {
                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>