<!DOCTYPE html>
<html>

<head lang="en">
    <meta charset="UTF-8">
    <link rel="stylesheet" href="/static/css/bootstrap.min.css">
    <script src="/static/js/jquery.min.js"></script>
    <script src="/static/js/bootstrap.min.js"></script>
    <title>用户列表</title>

    <style>
        .box {
            width: 80%;
            margin: auto;
            margin-top: 60px;
            padding-left: 10px;
        }
    </style>
</head>

<body>
    <div class="box">
        <div class="row col-md-8">
            <button type="button" class="btn btn-primary">新增</button>
            <table class="table table-bordered">
                <thead>
                    <tr>
                        <th>
                            id
                        </th>
                        <th>
                            用户名
                        </th>
                        <th>
                            创建时间
                        </th>
                        <th>
                            删除
                        </th>
                    </tr>
                </thead>
                <tbody>
                    <?php
                    foreach ($list as $value) {
                    ?>
                        <tr>
                            <td><?php echo $value['id']; ?></td>
                            <td><?php echo $value['username']; ?></td>
                            <td><?php echo date('Y-m-d H:i:s', $value['create_time']); ?></td>
                            <td><a type="button" class="btn btn-danger" href="javascript:del(<?php echo $value['id']; ?>)">
                                <span class="glyphicon glyphicon-trash" aria-hidden="true"></span></a></td>
                        </tr>
                    <?php
                    }
                    ?>
                </tbody>
            </table>
        </div>
    </div>
    


    <script>
        function del(id)
        {
            $.post('/userdelete', {
                   'userid' :  id,
                }, function(res){
                    console.log(res);
                    if (res.code == 0) {
                        alert('操作成功');
                        
                        window.location.reload();
                    } else {
                        alert(res.msg);
                    }
                    return false;
                }, 'json');
        }

    </script>
</body>

</html>