@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.包名：') }}{{$ChannelPackageName}}</h4>

                            <h5 style="color: red">{{ __('auto.排序数字越大，游戏排序越靠前') }}</h5>
                            <form class="forms-sample" id="form">
                                <table class="table table-bordered">

                                    <tr>
                                        <th>{{ __('auto.游戏名字') }}</th>
                                        <th>{{ __('auto.是否展示在大厅') }}</th>
                                        <th>{{ __('auto.是否大图标') }}</th>
                                        <th>{{ __('auto.展示大厅排序') }}</th>
                                        <th>{{ __('auto.客户端版本限制（默认0）') }}</th>
                                        <th>VIP</th>
                                    </tr>

                                    @foreach($list as $k=>$v)

                                        <tr id="tr-{{$k}}">

                                            <input type="hidden" name="KindID[{{$k}}]" value="{{$v->KindID}}">


                                            <td>{{$v->KindName}}</td>
                                            <td>

                                                <input type="radio" name="Status[{{$k}}]" value="1"
                                                       @if ($v->Status == 1)
                                                           checked
                                                    @endif> {{ __('auto.开启') }}

                                                <input type="radio" name="Status[{{$k}}]" value="2"
                                                       @if ($v->Status == 2)
                                                           checked
                                                    @endif> {{ __('auto.关闭') }}

                                            </td>
                                            <td>
                                                <input type="radio" name="IconType[{{$k}}]" value="1"
                                                       @if ($v->IconType == 1)
                                                           checked
                                                    @endif> {{ __('auto.大图标') }}

                                                <input type="radio" name="IconType[{{$k}}]" value="0"
                                                       @if ($v->IconType == 0)
                                                           checked
                                                    @endif> {{ __('auto.小图标') }}
                                            </td>
                                            <td>{{ __('auto.排序：') }}<input type="number" name="Sort[{{$k}}]" class="form-control"
                                                                             value="{{$v->Sort}}"></td>


                                            <td>
                                                LimitCV：<input type="number" name="LimitCV[{{$k}}]"
                                                               class="form-control" value="{{$v->LimitCV}}">
                                            </td>
                                            <td>
                                                VIP：<input type="number" name="VIP[{{$k}}]"
                                                           class="form-control" value="{{$v->VIP}}">
                                            </td>


                                        </tr>
                                        @endforeach
                                        </tbody>
                                        @if ($Channel == -1)
                                            <tr>
                                                <td>{{ __('auto.游戏分享链接配置') }}</td>
                                                <td colspan="4"><input name="ShareUrl" value="{{ $GameShareUrl }}"
                                                                       class="form-control"></td>
                                            </tr>
                                        @endif
                                        <tr>
                                            <td>ted{{ __('auto.提现开关') }}</td>
                                            <td>@component('components.radio', [
                                                'name' => 'ted_switch',
                                                'options' => [1 =>__('auto.开启'), 0 => __('auto.关闭') ],
                                                'default' => $tedSwitch ? $tedSwitch->status : 0
                                            ])@endcomponent</td>
                                        </tr>
                                </table>
                                <button type="button" onclick="commit({{$Channel}})"
                                        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 StatusFunc(obj, val, key) {

            Status = 'StatusArr[' + key + ']'
            input = "<input type='hidden' name=" + Status + " value=" + val + ">"
            $("#tr-" + key).append(input)

        }

        function commit(Channel) {

            if (!checkForm()) {
                return false;
            }

            params = ($("#form").serializeObject());

            myRequest("/admin/channel/open_games/" + Channel, "post", params, function (res) {
                if (res.code == '200') {
                    layer.msg(res.msg)
                    setTimeout(function () {
                        parent.location.reload();
                    }, 1500)
                } else {
                    layer.msg(res.msg)
                }
            });
        }

        function cancel() {
            parent.location.reload();
        }


        function add() {
            layer.open({
                type: 2,
                title: '{{ __('auto.添加咖啡档位') }}',
                shadeClose: true,
                shade: 0.8,
                area: ['50%', '50%'],
                content: '/admin/recharge/add'
            });
        }

        function update() {
            layer.open({
                type: 2,
                title: '{{ __('auto.渠道修改') }}',
                shadeClose: true,
                shade: 0.8,
                area: ['50%', '50%'],
                content: '/admin/recharge/update'
            });
        }

        function switch_control(id, config_id, type) {

            console.log(id)
            myConfirm("{{ __('auto.操作不可逆,是否继续') }}?", function () {
                myRequest("/admin/recharge/gear_switch/" + id, "post", {config_id, type}, function (res) {
                    layer.msg(res.msg)
                    setTimeout(function () {
                        parent.location.reload();
                    }, 1500)
                });
            });
        }


    </script>
@endsection
