@extends('base.base')
@section('base')
    <!-- 内容区域 -->
    <div class="main-panel">
        <div class="content-wrapper">
            <div class="page-header">
                <h3 class="page-title">
                     <span class="page-title-icon bg-gradient-primary text-white mr-2">
                        <i class="mdi mdi-settings"></i>
                    </span>
                    {{ __('auto.用户数据') }}
                </h3>
                <nav aria-label="breadcrumb">
                    <ol class="breadcrumb">
                        <li class="breadcrumb-item"><a href="#">{{ __('auto.用户数据') }}</a></li>
                        <li class="breadcrumb-item active" aria-current="page">{{ __('auto.用户数据') }}</li>
                    </ol>
                </nav>
            </div>

            <div class="row">
                <div class="col-lg-12 grid-margin stretch-card">
                    <div class="card">
                        <div class="card-body">

                            <h4 class="card-title">{{ __('auto.用户数据') }}</h4>
                            <form class="well form-inline margin-top-20" method="post" action='/admin/global/userlist'>
                                <div>
                                    @csrf

                                </div>

                            </form>
                            <div>

                                {{ __('auto.在线总人数') }}: <span style="color: red">{{$total}}</span>  <a  href="/admin/global/online_user" class="btn btn-gradient-success btn-sm">{{ __('auto.刷新') }}</a>

                            </div>
                            <table class="table table-bordered">
                                <thead>
                                <tr>
                                    <th width="6%">{{ __('auto.会员') }}ID</th>
                                    <th width="4%">{{ __('auto.昵称') }}</th>
                                    <th width="4%">{{ __('auto.游戏房间') }}</th>
                                </tr>
                                </thead>
                                <tbody class="search_checkbox">
                                @foreach($list as $k=>$item)
                                    <tr>
                                        <td>
                                            <a href="/admin/global/id_find?UserID={{$item->UserID}}">
                                                {{$item->GameID}}
                                            </a>
                                        </td>
                                        <td>{{$item->NickName}}</td>
                                        <td>{{$item->ServerName}}</td>
                                    </tr>
                                @endforeach
                                </tbody>
                            </table>
                            {!! $pages !!}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>
        var search_arr = [];
        var search_arr1 = [];
        var first_str = '';

        function update(id){
            var page = layer.open({
                type: 2,
                title: '{{ __('auto.修改配置') }}',
                shadeClose: true,
                shade: 0.8,
                area: ['70%', '90%'],
                content: '/admin/global/user_update?id='+id
            });
        }
        function del(id){
            myConfirm("{{ __('auto.删除操作不可逆,是否继续') }}?",function(){
                myRequest("/admin/accusation/del/"+id,"post",{},function(res){
                    layer.msg(res.msg)
                    setTimeout(function(){
                        window.location.reload();
                    },1500)
                });
            });
        }
        function checkbox(){
            var num=document.getElementsByName('checkbox');
            for(var i=0;i<num.length;i++){
                if(num[i].checked){
                    num[i].checked=false;
                }else{
                    num[i].checked=true;
                }
            }
        }
        function ban(ban){
            //1封号 2解封
            var num=document.getElementsByName('checkbox');
            var str='';
            for(var i=0;i<num.length;i++){
                if(num[i].checked){
                    str=str+num[i].id+',';
                }
            }
            if (str==''){
                alert('{{ __('auto.请选择要操作的数据') }}');return false;
            }
            var id=str.substr(0,str.length-1);
            myConfirm("{{ __('auto.是否继续账户操作') }}?",function(){
                myRequest("/admin/global/ban","post",{id:id,ban:ban},function(res){
                    layer.msg(res.msg)
                    setTimeout(function(){
                        window.location.reload();
                    },1500)
                });
            });
            return false;
        }
        /*   function rad(obj){
               location.href='/admin/global/userlist?obj='+obj;
           }*/

        function search(value) {
            var start_time   = $("#start_time").val();
            var end_time   = $("#end_time").val();


            if (localStorage.getItem('search') === ''){
                localStorage.setItem('search',value)
            }else {
                if (localStorage.getItem('search') !== null){
                    first_str += localStorage.getItem('search') + ','
                }

            }

            var sub_str = first_str.indexOf(value)
            if (sub_str < 0){
                first_str += value + ','
            }else {
                localStorage.removeItem("search");
                first_str = first_str.replace(value+',','')
            }

            search_arr = first_str.split(',')

            $.ajax({
                type:"get",
                url:"/admin/global/userlist",
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                },
                data:{search:search_arr,start_time:start_time,end_time:end_time},
                success:function(msg){
                    if(msg){
                        $(".main-panel").html(msg)
                    }
                }
            })

            return false;

        }
        function sort_money_func(obj, val) {

            if (val == 'asc') {
                $(".sort_money svg:eq(1)").children('path').attr('fill', '#707071');
                $(obj).children('path').attr('fill', 'red')

            } else {
                $(obj).children('path').attr('fill', 'red')
                $(".sort_money svg:eq(0)").children('path').attr('fill', '#707071');
            }

            $.ajax({
                type: "post",
                url: "/admin/global/userlist",
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                },
                data: {Score: val},
                success: function (msg) {

                    if (msg) {
                        $(".main-panel").html(msg)

                    }
                }
            })
        }

    </script>
@endsection
