<!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}">
    <link rel="stylesheet" th:href="@{/js/layui/css/my.css}">
    <link rel="stylesheet" th:href="@{/js/upload_img/css/index.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>
    <link rel="stylesheet" th:href="@{/js/ueditor/themes/default/css/ueditor.css}" type="text/css"/>
    <script type="text/javascript" th:src="@{/js/ueditor/ueditor.config.js}"></script>
    <script type="text/javascript" th:src="@{/js/ueditor/ueditor.all.js}"></script>
    <script type="text/javascript" th:src="@{/js/ueditor/lang/zh-cn/zh-cn.js}"></script>
    <script src="https://s2.pstatp.com/cdn/expire-1-M/jquery/1.7.1/jquery.min.js"></script>
    <link href="https://cdn.bootcdn.net/ajax/libs/layui/2.5.6/css/layui.min.css" rel="stylesheet">
    <script src="https://cdn.bootcdn.net/ajax/libs/layui/2.5.6/layui.min.js"></script>


    <style>
        .layui-form-label {
            width: 100px;
        }

        #editor {
            height: 600px;
            width: 700px;
        }
    </style>

</head>
<body>
<div class="layui-tab" lay-filter="tab-demo">
    <ul class="layui-tab-title">
        <li class="layui-this">详情</li>
        <li>用户信息</li>
    </ul>
    <div class="layui-tab-content">
        <!--    详情    -->
        <div class="layui-tab-item layui-show">
            <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="text" class="layui-input" name="groupBuyTitle" id="groupBuyTitle"
                                   th:value="${obj.groupBuyTitle}">
                        </div>
                        <label class="layui-form-label">订单号</label>
                        <div class="layui-input-inline">
                            <input type="text" step="1" class="layui-input" name="orderCode" id="orderCode"
                                   th:value="${obj.orderCode}">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">订单实付金额</label>
                        <div class="layui-input-inline">
                            <input type="number" class="layui-input" name="sumDactmoney" id="sumDactmoney"
                                   th:value="${obj.sumDactmoney}">
                        </div>
                        <label class="layui-form-label">订单状态</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="groupStatus" id="groupStatus"
                                   th:value="${obj.groupStatus}">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">成团时间</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="successTime" id="successTime"
                                   th:value="${obj.successTimeStr}">
                        </div>
                        <label class="layui-form-label">小区名称</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="areaName" id="areaName"
                                   th:value="${obj.areaName}">
                        </div>
                    </div>


                    <button class="layui-btn" style="display: none;" id="saveBtn" onclick="save()">保存</button>
                </form>
            </div>
        </div>
        <!--    用户信息    -->
        <div class="layui-tab-item">
            <table class="layui-hide" id="tableId" lay-filter="tableId"></table>
        </div>
    </div>
</div>
<script type="text/javascript" th:src="@{/js/upload_img/js/updateimg.js}"></script>

<script type="text/html" id="table-handle">
    <i class="layui-icon layui-icon-form" lay-event="detail" title="详情"></i>

</script>

<script>
    var id = '[[${id}]]';


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


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


    function chioceImage(i) {
        $('#file' + i).trigger("click");
    }

    layui.use('element', function () {
        var element = layui.element;

        //监听Tab切换，以改变地址hash值
        element.on('tab(tab-demo)', function () {
            location.hash = 'tab-demo=' + this.getAttribute('lay-id');
        });

        //获取hash来切换选项卡，假设当前地址的hash为lay-id对应的值
        var hash = location.hash.replace(/^#tab-demo=/, '');
        element.tabChange('tab-demo', hash);
    });

    var field = {};
    layui.use(['table', 'laydate', 'form'], function () {
            var form = layui.form, table = layui.table;
            //监听搜索
            form.on('submit(The-search)', function (data) {
                field = data.field;
                //执行重载
                table.reload('tableId', {
                    where: field
                    , page: {
                        curr: 1
                    }
                });
            });
            table.render({
                elem: '#tableId'
                , url: 'userList'
                , method: 'post'
                , contentType: "application/json" // 内容编码， json格式
                , height: 500
                , toolbar: '#toolbarUtil' //开启头部工具栏，并为其绑定左侧模板
                , defaultToolbar: ['filter']
                , cellMinWidth: 20 //全局定义常规单元格的最小宽度，layui 2.2.1 新增
                , skin: 'line ' //表格风格 line （行边框风格）row （列边框风格）nob （无边框风格）
                , even: true    //隔行换色
                , limit: 20 //每页默认显示的数量
                , page: true
                , where: {
                    id: id
                }
                , request: {
                    pageName: "curpage", // 页码的参数名称，默认：page
                    limitName: "pagesize" // 每页数据量的参数名，默认：limit
                }
                , response: {
                    statusName: "code", // 规定数据状态的字段名称，默认：code
                    statusCode: 100, // 规定成功的状态码，默认：0
                    msgName: "msg", // 规定状态信息的字段名称，默认：msg
                    countName: "count", // 规定数据总数的字段名称，默认：count
                    dataName: "data" // 规定数据列表的字段名称，默认：data
                }

                , parseData: function (res) { // res 即为原始返回的数据
                    return {
                        "code": res.code, // 解析接口状态
                        "msg": res.desc, // 解析提示文本
                        "count": res.data.pageinfo.totalRecords, // 解析数据长度
                        "data": res.data.items // 解析数据列表
                    };
                }

                , limits: [10, 20, 50, 100]  //每页条数的选择项，默认：[10,20,30,40,50,60,70,80,90]。

                , cols: [
                    [
                        {type: 'checkbox', fixed: "left"}
                        , {field: 'swxnick', title: '用户昵称', fixed: "left"}
                        , {field: 'sorderno', title: '订单号'}
                        , {field: 'dactmoney', title: '实付金额'}
                        , {field: 'tpaytime', title: '付款时间'}
                        , {field: 'scusaddr', title: '收获地址'}
                        , {field: 'sdef1', title: '联系人'}
                        , {field: 'sdef2', title: '联系电话'}
                        , {field: 'sdef3', title: '详细地址'}
                        , {field: 'sremark', title: '备注'}
                        , {field: '', width: 130, title: '操作', toolbar: '#table-handle', fixed: "right"}
                    ]
                ]
            });
            //监听行工具事件
            table.on('tool(tableId)', function (obj) {
                var data = obj.data;
                if (obj.event === 'detail') {
                    var id = obj.data.id;
                    console.log("========== ", id)
                    var w = ($(window).width() * 0.95);
                    var h = ($(window).height() * 0.95);
                    layer.open({
                        type: 2
                        , title: '详情'
                        , content: 'detailList?id=' + id
                        , area: [w + 'px', h + 'px']
                        , fix: false //不固定
                        , maxmin: true
                        , shadeClose: true
                        , shade: 0.4
                        , btn: ['关闭']
                        // , yes: function (index, layero) {
                        //     var body = layer.getChildFrame('body', index); //得到iframe页面层的BODY
                        //     var iframeBtn = body.find('#saveBtn');//得到iframe页面层的提交按钮
                        //     iframeBtn.click();//模拟iframe页面层的提交按钮点击
                        // }
                    });
                }
            });
        }
    );
</script>
</body>

</html>