<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>ios版本开关配置</title>
    <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" href="<?php echo base_url();?>public/js/bootstrap/bootstrap.min.css" >
    <link rel="stylesheet" href="<?php echo base_url();?>public/js/vendor/bootstrap-datepicker/css/bootstrap-datepicker.standalone.min.css">
    <link rel="stylesheet" href="<?php echo base_url();?>public/css/jquery.timepicker.min.css">
    <!-- Select2 -->
    <link rel="stylesheet" href="<?php echo base_url();?>public/js/vendor/select2/select2.min.css">

    <style type="text/css">
        .thumbnail {
            margin:10px;
        }

        .lang-name {
            margin-left:42px;
        }

        .upimg {
            cursor: pointer;
        }

    </style>
</head>
<body>
<div id="msg-tip">

</div>
<div class="content_wrapper">
    <div class="container-fluid">
        <aside>
            <form class="form-horizontal" role="form" method="post" enctype="multipart/form-data"  id="form" action="#" style="margin-top: 20px">
                <header><i class="fa fa-fw fa-file"></i>ios版本兑换码开关配置</header>
                <section>
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-sm-12">
                                <button type="button" class="btn btn-success" id="submitBtn">提交</button>
                            </div>
                        </div>
                    </div>
                    <div class="container-fluid">
                        <div class="row" style="border: 1px solid #CCC;margin:10px 5px;padding: 5px 0;">
                            <div class="form-group" >
                                <label class="col-sm-2 control-label">是否关闭兑换码(1 是；0 否)</label>
                                <div class="col-sm-1">
                                    <input type="text" class="form-control" name="openOline" value="<?php echo $openOline;?>">
                                </div>
                                <label class="col-sm-1 control-label">版本控制</label>
                                <div class="col-sm-1">
                                    <input type="text" class="form-control"  name="openOlineVer" value="<?php echo $openOlineVer;?>">
                                </div>
                                <label class="col-sm-1 control-label">冒险岛开关</label>
                                <div class="col-sm-1">
                                    <input type="text" class="form-control"  name="isOpenMaple" value="<?php echo $isOpenMaple;?>">
                                </div>
                            </div>
                        </div>
                    </div>
                </section>
            </form>
        </aside>
    </div>

    <?php foreach ($types as $type => $text) { ?>
        <div class="container-fluid">
            <aside>
                <form class="form-horizontal" role="form" method="post" enctype="multipart/form-data"  id="form" action="#" style="margin-top: 20px">
                    <header><i class="fa fa-fw fa-file"></i><?=$text?></header>
                    <section>
                        <div class="container-fluid">
                            <div class="row">
                                <div class="col-sm-12">
                                    <button type="button" class="btn btn-success submitBtn" >提交</button>
                                </div>
                            </div>
                        </div>
                        <div class="container-fluid">
                            <div class="row" style="border: 1px solid #CCC;margin:10px 5px;padding: 5px 0;">
                                <input type="hidden" class="form-control" name="type" value="<?=$type?>">
                                <div class="form-group" >
                                    <label class="col-sm-2 control-label">是否关闭(1 是；0 否)</label>
                                    <div class="col-sm-1">
                                        <input type="text" class="form-control" name="<?=$type?>[status]" value="<?php echo $closeSetting[$type]['status'];?>">
                                    </div>
                                    <label class="col-sm-1 control-label">版本控制</label>
                                    <div class="col-sm-1">
                                        <input type="text" class="form-control"  name="<?=$type?>[version]" value="<?php echo $closeSetting[$type]['version'];?>">
                                    </div>
                                </div>
                            </div>
                        </div>
                    </section>
                </form>
            </aside>
        </div>
    <?php }?>
</div>
</body>

<script>
    $(function () {
        $('#submitBtn').click(function () {
            var data = new FormData(document.getElementById("form"));
            $.ajax({
                url: rootPath + 'Config/actionIosOpenOline',
                type: 'POST',
                data: data,
                dataType: 'json',
                contentType: false, //必须
                processData: false, //必须
                success: function (data) {
                    alert(data.msg);
                    window.location.reload();
                },
                error: function (msg) {
                    alert(data.msg);
                }
            });
        });


        $('.submitBtn').click( function(){
            let data = new FormData($(this).parents('form')[0]);
            new Promise((resolve, reject) => {
                $.ajax({
                    url: rootPath + 'Config/saveIosCloseSetting',
                    type: 'POST',
                    data: data,
                    dataType: 'json',
                    contentType: false, //必须
                    processData: false, //必须
                    success: function (data) {
                        resolve(data)
                    },
                    error: function (msg) {
                        reject(msg)
                    }
                });
            }).then(function(data){
                console.log(data)
                alert(data.msg)
                if (data)window.location.reload()
            }, function(err){
                console.log(err)
            })
        })

    });
</script>
</html>
