<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
    <head>
        <th:block th:include="include :: header('黑名单管理')"/>
        <th:block th:include="include :: bootstrap-fileinput-css" />
        <style>

        </style>
    </head>
    <body>
        <div class="container-div">
            <div class="row">
                <div class="col-sm-12 search-collapse">
                    <form id="formId">
                        <div class="select-list">
                            <ul>
                                <li>
                                    <label>手机号：</label>
                                    <input type="number" name=""/>
                                </li>
                                <li>
                                    <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                            class="fa fa-search"></i>&nbsp;搜索</a>
                                    <!--                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i-->
                                    <!--                                    class="fa fa-refresh"></i>&nbsp;重置</a>-->
                                </li>
                            </ul>
                        </div>
                    </form>
                </div>
                <div class="col-sm-12 select-table table-bordered">
                    <table id="bootstrap-table"></table>
                </div>
            </div>
        </div>
    </body>
    <th:block th:include="include :: footer"/>
    <script type="text/javascript">
        $(function(){
            let options = {
                url: '/smile/user/listByState',
                columns: [
                    {
                        field: 'uid',
                        title: 'ID'
                    },
                    {
                        field: 'name',
                        title: '姓名'
                    },
                    {
                        field: 'sex',
                        title: '性别',
                        formatter:function(value,row,index){
                            return row.sex === 1? '男' : '女'
                        }
                    },
                    {
                        field: 'phone',
                        title: '手机号'
                    },
                    {
                        field: 'idCard',
                        title: '身份证号'
                    },
                    {
                        field: 'province',
                        title: '地区'
                    },
                    {
                        field: 'schoolName',
                        title: '学校'
                    },
                    {
                        field: 'identity',
                        title: '身份',
                        formatter: function(value, row, index) {
                            if (value == 1) {
                                return '在校学生';
                            } else {
                                return '已毕业';
                            }
                        }
                    },
                    {
                        field: 'uid',
                        title: '拉黑原因'
                    },
                    {
                        field: 'updatedDate',
                        title: '拉黑时间'
                    },
                    {
                        title: '操作',
                        formatter:function(value,row,index){
                            var actions = [];
                            actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="goDetail(\''+row.type+'\',\''+row.uid+'\')"><i class="fa fa-edit"></i>查看</a> ');
                            actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="updateUserStateById(\'' + row.uid + '\',\'' + 0 + '\')"><i class="fa fa-edit"></i>恢复</a> ');
                            return actions.join('');
                        }
                    },
                ]
            }
            $.table.init(options);
        })
        function goDetail (type,id) {
            if(type === '5'){
                let url = ctx+'local/specialDetail?id=' + id;
                $.modal.openTab("特邀用户详情", url);
            }else{
                let url = ctx+'local/smileDetail?id=' + id;
                $.modal.openTab("用户详情", url);
            }
        }

        function updateUserStateById(uid,state) {
            let postData = {
                uid: uid,
                state: state
            }
            $.ajax({
                type: 'post',
                url: ctx + 'smile/user/updateUserStateByUid',
                headers: {"Content-Type": "application/json;charset=UTF-8"},
                data: JSON.stringify(postData),
                success: function (e) {
                    // alert(e.msg)
                    location.reload();
                }
            });
        }
    </script>
</html>