@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>
                            <p class="card-description">
                                <button type="button" class="btn btn-sm btn-gradient-success btn-icon-text"
                                        onclick="add()">
                                    <i class="mdi mdi-plus btn-icon-prepend"></i>
                                    {{ __('auto.充值档位添加') }}
                                </button>
                            </p>

                            <table class="table table-bordered">
                                <thead>
                                <tr>
                                    <th width="5%">{{ __('auto.充值档位') }}</th>
                                    <th width="5%">{{ __('auto.赠送') }}</th>
                                    <th width="15%">{{ __('auto.支持的支付方式') }}</th>
                                    <th width="8%">{{ __('auto.档位显示开关') }}</th>
                                    <th width="8%">{{ __('auto.修改配置') }}</th>
                                </tr>
                                </thead>
                                <tbody>
                                @foreach($list as $k=>$v)
                                    <tr>
                                        <td>{{ $v->money }}{{ env('CONFIG_24680_CURRENCY') }}</td>
                                        <td>{{ $v->give }}{{ env('CONFIG_24680_CURRENCY') }}</td>
                                        <td>{{ $v->gear ?: '-' }}</td>
                                        <td>
                                            @if ($v->status == 1)
                                                <span style="color: #0bb20c">{{ __('auto.已开启') }}</span>
                                                <button type="button" class="btn btn-sm btn-danger"
                                                        onclick="switch_control({{$v->id}},'off')">{{ __('auto.关闭') }}
                                                </button>
                                            @elseif ($v->status == -1)
                                                <span style="color: red">{{ __('auto.已关闭') }}</span>

                                                <button type="button" class="btn btn-sm btn-primary"
                                                        onclick="switch_control({{$v->id}},'on')">{{ __('auto.开启') }}
                                                </button>
                                            @endif
                                        </td>

                                        <td>
                                            <button class="btn btn-sm btn-gradient-dark"
                                                    onclick="update_config({{$v->id}})">{{ __('auto.修改配置') }}
                                            </button>
                                        </td>

                                    </tr>
                                @endforeach
                                @foreach($monthCard as $k => $v)
                                    <tr>
                                        <td>{{$v['CardName']}}-{{$v['Price']}}{{ env('CONFIG_24680_CURRENCY') }}-{{ __('auto.有效期') }}{{$v['TakeEffectDays']}}{{ __('auto.天') }}</td>
                                        <td>{{ __('auto.立即赠送') }}{{$v['FirstReward']}}-{{ __('auto.每天可领') }}{{$v['DayReward']}}</td>

                                        <td>
                                            {{$v['CardState'] == 1 ? __('auto.已开启') : __('auto.已关闭') }}
                                                <a class="layer-switch btn btn-sm
                                                    {{ $v['CardState'] == 1 ? 'btn-danger' : 'btn-primary' }}"
                                                   href="/admin/recharge/month_card_switch/{{$v['CardID']}}">
                                                    {{$v['CardState'] == 0 ?  __('auto.已开启') : __('auto.已关闭') }}</a>
                                        </td>
                                        <td>
                                            <a href="/admin/recharge/month_card_edit/{{$v['CardID']}}"
                                               class="btn btn-sm btn-gradient-dark layer-dialog">{{ __('auto.修改配置') }}</a>
                                        </td>
                                    </tr>
                                @endforeach
                                </tbody>
                            </table>

                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>

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

        function update_config(id) {
            layer.open({
                type: 2,
                title: '{{ __('auto.修改充值档位') }}',
                shadeClose: true,
                shade: 0.8,
                area: ['50%', '50%'],
                content: '/admin/recharge/update_config/' + id
            });
        }

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

        function switch_control(id, type) {

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

        // 推荐充值档位
        function gradeChange(StatusValue) {
            myRequest('/admin/recharge/recomendar_recharge','get',{StatusValue},function (res) {
                layer.msg(res.msg)
            })
        }


    </script>
@endsection
