@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>

                            <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>
                            <table class="table table-bordered">
                                <thead>
                                <tr>
                                    <th width="5%">{{ __('auto.权重') }}</th>
                                    <th width="5%">{{ __('auto.类型') }}</th>
                                    <th width="8%">{{ __('auto.功能名称') }}</th>
                                    <th width="8%">{{ __('auto.发布内容') }}</th>
                                    <th width="8%">{{ __('auto.最后修改日期') }}</th>
                                    <th width="8%">{{ __('auto.开关') }}</th>
                                    <th width="8%">{{ __('auto.操作') }}</th>
                                </tr>
                                </thead>
                                <tbody>
                                @foreach($list as $k=>$v)
                                    <tr>
                                        <td>{{$v->Sort}}</td>
                                        <td>
                                            @if ($v->Type == 1)
                                                {{ __('auto.文本') }}
                                            @else
                                                {{ __('auto.图片') }}
                                            @endif
                                        </td>


                                        <td>{{$v->Title}}</td>
                                        <td>
                                            @if ($v->Type == 1)
                                                <textarea name="" id=""  rows="4" class="form-control" style="float: left;width: 80%">{{$v->Content}}</textarea>
                                            @else
                                                <img src="{{$v->Content}}" alt="" width="80px">
                                            @endif

                                        </td>
                                        <td>{{$v->LastTime}}</td>
                                        <td>
                                            @if ($v->Status == 1)
                                                {{ __('auto.已开启') }}
                                                <button class="btn-sm btn-gradient-dark"
                                                        onclick="switchFunc({{$v->ID}},2)">
                                                    {{ __('auto.关闭') }}
                                                </button>
                                            @else
                                                {{ __('auto.已关闭') }}
                                                <button class="btn-sm btn-gradient-dark"
                                                        onclick="switchFunc({{$v->ID}},1)">
                                                    {{ __('auto.开启') }}
                                                </button>
                                            @endif

                                        </td>
                                        <td>
                                            <button class="btn  btn-sm btn-gradient-dark"
                                                    onclick="update({{$v->ID}})">
                                                {{ __('auto.修改') }}
                                            </button>
                                                <button class="btn btn-sm btn-gradient-primary"
                                                        onclick="del({{$v->ID}})">
                                                    {{ __('auto.删除') }}
                                                </button>
                                        </td>
                                    </tr>
                                @endforeach
                                </tbody>
                            </table>
                            <div class="box-footer clearfix" id="pages">
                                {{ __('auto.总共') }} <b>{{ $list->appends([
                                        'list'=>$list,

])->total() }}</b> {{ __('auto.条,分为') }}<b>{{ $list->lastPage() }}</b>{{ __('auto.页') }}
                                {!! $list->links() !!}
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>

        function switchFunc(ID,Status) {
            myConfirm("{{ __('auto.操作不可逆,是否继续') }}?", function () {
                myRequest("/admin/notice/hall_announcement_switch/" + ID, "post", {Status}, function (res) {
                    layer.msg(res.msg)
                    setTimeout(function () {
                        window.location.reload();
                    }, 2000)
                });
            });
        }

        function del(ID) {
            myConfirm("{{ __('auto.操作不可逆,是否继续') }}?", function () {
                myRequest("/admin/notice/hall_announcement_del/" + ID, "post", {}, function (res) {
                    layer.msg(res.msg)
                    setTimeout(function () {
                        window.location.reload();
                    }, 2000)
                });
            });
        }

        function add() {
            layer.open({
                type: 2,
                title: '{{ __('auto.新增活动') }}',
                shadeClose: true,
                shade: 0.8,
                area: ['70%', '70%'],
                content: '/admin/notice/hall_announcement_add'
            });
        }

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



        function switch_control(id, ChannelIndex, AndroidVersion, type) {

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



    </script>
@endsection
