@extends('base.base')
@section('base')
    <!-- 内容区域 -->
    <div class="main-panel">
        <div class="content-wrapper">
            <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="forms-sample" id="form">
                                <div class="form-group">
                                    <label>{{ __('auto.渠道号') }}</label>
                                    <input type="number" class="form-control" name="Channel" value="99">
                                </div>
                                <div class="form-group">
                                    <label>{{ __('auto.包名') }}</label>
                                    <input type="text" class="form-control" name="PackageName">
                                </div>
                                <div class="form-group">
                                    <label>RegionID</label>
                                    <select class="form-control" name="RegionID">
                                        <option value="">None</option>
                                        @php $currentGroup = null; @endphp
                                        @foreach($regionList as $v)
                                            @if($currentGroup !== null && $currentGroup !== $v->GroupID)
                                                <option disabled>----------</option>
                                            @endif
                                            <option value="{{$v->RegionID}}" style="color: {{$groupColors[$v->GroupID] ?? '#000000'}};">{{$v->RegionID}}</option>
                                            @php $currentGroup = $v->GroupID; @endphp
                                        @endforeach
                                    </select>
                                </div>
                                <div class="form-group">
                                    <label>{{ __('auto.备注') }}</label>
                                    <input type="text" class="form-control" name="Remarks">
                                </div>
                                <div class="form-group">
                                    <label>StateNo</label>
                                    <input type="number" class="form-control" name="StateNo" value="1">
                                </div>
                                <div class="form-group">
                                    <label>SpecialMode（特殊功能选择）</label>
                                    <div class="row">
                                        @foreach($specialModes as $val => $label)
                                            <div class="col-sm-6">
                                                <div class="form-check">
                                                    <label class="form-check-label">
                                                        <input type="checkbox" class="form-check-input" name="SpecialMode[]" value="{{$val}}"> {{$label}} ({{$val}})
                                                    </label>
                                                </div>
                                            </div>
                                        @endforeach
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label>RegOpen（注册方式)</label>
                                    <div class="row">
                                        @foreach(['id','phone','sms','mail','guest'] as $v)
                                            <div class="col-sm-2">
                                                <div class="form-check">
                                                    <label class="form-check-label">
                                                        <input type="checkbox" class="form-check-input" name="RegOpen[]" value="{{$v}}" @if($v == 'phone') checked @endif> {{$v}}
                                                    </label>
                                                </div>
                                            </div>
                                        @endforeach
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label>LoginOpen (登录方式)</label>
                                    <div class="row">
                                        @foreach(['id','phone','sms','mail','guest'] as $v)
                                            <div class="col-sm-2">
                                                <div class="form-check">
                                                    <label class="form-check-label">
                                                        <input type="checkbox" class="form-check-input" name="LoginOpen[]" value="{{$v}}" checked> {{$v}}
                                                    </label>
                                                </div>
                                            </div>
                                        @endforeach
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label>PlatformName</label>
                                    <select class="form-control" name="PlatformName">
                                        <option value="">None</option>
                                        <option value="fb">Facebook (fb)</option>
                                        <option value="kwai">海外快手 (kwai)</option>
                                        <option value="tt">Tiktok (tt)</option>
                                        <option value="gg">Google (gg)</option>
                                        <option value="apk">Apk落地页 (apk)</option>
                                    </select>
                                </div>
                                <div class="form-group">
                                    <label>PlatformID (pixel id)</label>
                                    <input type="text" class="form-control" name="PlatformID">
                                </div>
                                <div class="form-group">
                                    <label>PlatformToken (Conversions API Token)</label>
                                    <textarea class="form-control" name="PlatformToken" rows="3" placeholder="长文本 Token，保存在 txt 字段中"></textarea>
                                </div>
                                <div class="form-group">
                                    <label>BonusArr (REG | MOBILE | EMAIL | PWA)</label>
                                    <div class="row">
                                        <div class="col-sm-3">
                                            <input type="number" class="form-control" name="BonusArr_REG" placeholder="REG" value="0">
                                        </div>
                                        <div class="col-sm-3">
                                            <input type="number" class="form-control" name="BonusArr_MOBILE" placeholder="MOBILE" value="0">
                                        </div>
                                        <div class="col-sm-3">
                                            <input type="number" class="form-control" name="BonusArr_EMAIL" placeholder="EMAIL" value="0">
                                        </div>
                                        <div class="col-sm-3">
                                            <input type="number" class="form-control" name="BonusArr_PWA" placeholder="PWA" value="0">
                                        </div>
                                    </div>
                                </div>
                                <div class="form-group" style="display: none">
                                    <label>ShadowChannel (rate%12|rate%13) </label>
                                    <input type="text" class="form-control" name="ShadowChannel">
                                </div>
                                <div class="form-group">
                                    <label>LightApk (twa) 下载URL</label>
                                    <input type="text" class="form-control" name="LightApk">
                                </div>
                                <div class="form-group">
                                    <label>FullApk (apk) 下载URL</label>
                                    <input type="text" class="form-control" name="FullApk">
                                </div>

                                <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() {
            var data = $("#form").serializeObject();
            myRequest("/admin/web_channel_config/add", "post", data, function (res) {
                layer.msg(res.msg)
                if (res.code == 200) {
                    setTimeout(function () {
                        parent.location.reload();
                    }, 1500)
                }
            });
        }
        function cancel() {
            var index = parent.layer.getFrameIndex(window.name);
            parent.layer.close(index);
        }
    </script>
@endsection
