<?php
  require __DIR__.'/head.html';
  require __DIR__.'/header.html';
  $File_Ming = 'userinfo';
  require __DIR__.'/nav.html';
  ?>
<!-- 主体 -->
<main class="app-content">
    <div class="app-title">
        <ul class="app-breadcrumb breadcrumb side">
            <li class="breadcrumb-item"><i class="fa fa-home fa-lg"></i></li>
            <li class="breadcrumb-item">会员列表</li>
        </ul>
    </div>
    <div class="row">
        <div class="col-md-12">
            <div class="tile">
                <div class="tile-body">
                    <table class="table table-hover table-bordered" id="sampleTable">
                        <thead class="table-space">
                            <tr>
                                <th>ID</th>
                                <th>用户账户</th>
                                <th>用户邮箱</th>
                                <th>余额</th>
                                <th>注册时间</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tbody class="table-space">

                            <?php if(!empty($data)):
                            foreach($data as $k=>$v):?>
                            <tr>
                                <td><?php echo $k+1;?></td>
                                <td><?php echo $v['u_name'];?></td>
                                <td><?php echo $v['u_email'];?></td>
                                <td><?php echo ($v['u_balance']);?>元</td>
                                <td><?php echo $v['u_found_time'];?></td>
                                <td class="api-list-cz">
                                    <a class="btn btn-primary btn-sm" onclick="editRow(this)"
                                        title="<?php echo $v['u_id'];?>">编辑</a>
                                    <a class="btn btn-primary btn-sm" onclick="delRow(this)"
                                        title="<?php echo $v['u_id'];?>">删除</a>
                                </td>
                            </tr>
                            <?php endforeach;
                            endif;?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
    <?php  require __DIR__.'/fooer.html'; ?>
    <script type="text/javascript">
        function editRow(_this) {
            layer.open({
                type: 2,
                title: '接口编辑',
                shadeClose: false,
                shade: true,
                maxmin: false, //开启最大化最小化按钮
                area: ['80%', '80%'],
                content: ['/<?php echo ADMIN_PATH;?>/useredit/' + _this.title]
            });
        }

        //删除
        function delRow(_this) {
            var td = _this.parentNode;
            var tr = td.parentNode;
            var tbody = tr.parentNode;
            //询问框
            layer.confirm('确定删除接口？', {
                title: "提示",
                btn: ['删除', '取消 '] //按钮
            }, function () {
                fd = new FormData();
                fd.append("id", _this.title);
                $.ajax({
                    url: '/admin/deluser',
                    type: "POST",
                    timeout: "3000",
                    dataType: "json",
                    contentType: 'application/x-www-form-urlencoded;charset=utf-8',
                    data: fd,
                    contentType: false,
                    processData: false,
                    success: function (data) {
                        if (data.code == "200") {
                            layer.msg(data.msg);
                            tbody.removeChild(tr);
                        } else {
                            layer.msg(data.msg);
                        }
                    },
                    error: function (XMLResponse) {
                        layer.msg(XMLResponse.error);
                    }
                });
            });
        }

    </script>
    </body>

    </html>