@extends('base.base')
@section('base')
    <!-- 内容区域 -->
    <div class="main-panel">
        <div class="content-wrapper">
            <div class="row">
                <div class="col-12 grid-margin stretch-card">
                    <div class="card">
                        <div class="card-body">
                            <h4 class="card-title">{{ __('auto.请修改配置信息') }}</h4>
                            {{--<p class="card-description">--}}
                            {{--Basic form elements--}}
                            {{--</p>--}}
                            <form class="forms-sample" id="form">
                                <div class="form-group">
                                    <label for="exampleInputName1">{{ __('auto.会员') }}ID</label>
                                    <input type="text" value="{{$list->ai_GameID}}"  class="form-control required"  name="UserID" disabled>
                                    <input type="hidden" value="{{$list->UserID}}"  class="form-control required" id="UserID" name="UserID" >
                                </div>
                                <div class="form-group">
                                    <label for="exampleInputName1">{{ __('auto.账户状态') }}</label>
                                    <input type="text"  class="form-control required" value="@if($list->Nullity==0) {{ __('auto.正常') }} @else {{ __('auto.封号中') }} @endif"   disabled>
                                    <br>
                                    <label for="Nullity">{{ __('auto.选择用户状态修改') }}</label>
                                    <select class="custom-select" name="Nullity" value="Nullity" id="Nullity">
                                        <option value="">{{ __('auto.选择类别') }}</option>
                                        <option value="0" @if($list->Nullity==0) selected @endif>{{ __('auto.正常') }}</option>
                                        <option value="1" @if($list->Nullity==1) selected @endif>{{ __('auto.封号') }}</option>
                                    </select>
                                </div>
                                <div class="form-group">
                                    <label >{{ __('auto.游戏昵称') }}</label>
                                    <input type="text"  class="form-control required" value="{{$list->NickName}}" name="NickName" disabled>
                                </div>
{{--                                <div class="form-group">--}}
{{--                                    <label >{{ __('auto.姓名') }}</label>--}}
{{--                                    <input type="text"  class="form-control" id="Compellation" value="{{$list->Compellation}}" name="Compellation" disabled>--}}
{{--                                    <a href="#" id="1" class="xgname" onclick="xgname(this)">{{ __('auto.确定修改姓名') }}</a>--}}
{{--                                </div>--}}
                                <div class="form-group">
                                    <label >{{ __('auto.上级') }}ID</label>

                                    @empty($list->SpreaderID)

                                        <input type="text"    class="form-control"  id="SpreaderID" value=""  name="SpreaderID" disabled>
                                        <a href="#" id="1"  style="float: left;width: 16%" class="xgsj" onclick="xgsj(this)" >{{ __('auto.确定修改上级') }}</a>

{{--                                        <button type="button" class="btn btn-default btn-lg" active disabled="disabled">{{ __('auto.确定修改上级') }}</button>--}}
                                    @else
                                        <input type="text"    class="form-control"  id="SpreaderID" value="{{$list->GameID}}"  name="SpreaderID" disabled >
{{--                                        <button style="float: left;width: 16%"  class="xgsj" disabled>{{ __('auto.确定修改上级') }}</button>--}}

                                    @endempty
                                </div>
                                <div class="form-group">
                                    <label for="Nullity">{{ __('auto.选择修改为官方账号') }} <span style="color: red">*(备注：改为官方账号后无法再改回普通账号)</span></label>
                                    <select class="custom-select" name="official" value="official" id="official">
                                        @if (!empty($IDWhiteUser))
                                            <option value="1" @if (!empty($IDWhiteUser))

                                            selected @endif>{{ __('auto.官方账号') }}</option>
                                        @else
                                            <option value="">{{ __('auto.选择类别') }}</option>
                                            <option value="1" @if (!empty($IDWhiteUser))

                                            selected @endif>{{ __('auto.官方账号') }}</option>
                                            <option value="0" @if (empty($IDWhiteUser))

                                            selected @endif>{{ __('auto.普通账号') }}</option>
                                        @endif



                                    </select>
                                </div>

                                <br><br>
                                <button type="button" onclick="commit()" class="btn btn-sm btn-gradient-primary btn-icon-text">
                                    <i class="mdi mdi-file-check btn-icon-prepend"></i>
                                    {{ __('auto.提交') }}
                                </button>
                                <button type="button" onclick="cancel()" class="btn btn-sm btn-gradient-warning btn-icon-text">
                                    <i class="mdi mdi-reload btn-icon-prepend"></i>
                                    {{ __('auto.取消') }}
                                </button>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>
        function commit(id){
            if(!checkForm()){
                return false;
            }
            var UserID=$('#UserID').val();
            var xg=$(".xgname").attr("id")
            var sj=$('.xgsj').attr('id');
            if(xg==1 && sj==1){
                alert('{{ __('auto.请确定修改按钮') }}');
                return false;
            }
            // var Compellation=$("#Compellation").val();
            var Nullity=$("#Nullity").val();


            var SpreaderID="";

            var official = $('#official').val();
            // if(xg==2){
            //     var Compellation=$('#Compellation').val();
            // }
            if(sj==2){
                var SpreaderID=$('#SpreaderID').val();
            }

           // var data = $("#form").serializeObject();
            myRequest("/admin/global/user_update","post", {UserID,SpreaderID,Nullity,official},function(res){
                layer.msg(res.msg)
                setTimeout(function(){
                    parent.location.reload();
                },1500)
            });
        }
        function cancel() {
            parent.location.reload();
        }
        function xgname(obj) {
            // obj.removeAttribute("id");
            // obj.setAttribute('id','2');
            $("#Compellation").removeAttr("disabled")
        }
        function xgsj(obj) {
            obj.removeAttribute("id");
            obj.setAttribute('id','2');
            $("#SpreaderID").removeAttr("disabled")
            // let val = $("#SpreaderID").val();
            // if (val != ""){
            //
            // }
        }
    </script>
@endsection
