<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>修改活动</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;
        }
        .tisi{
            color: #c9302c;
        }
    </style>
</head>
<body>

<div class="content_wrapper">
    <div class="content_wrapper " >
        <div class="container-fluid">
            <div class="form-group">
                <label class="col-sm-1 control-label">选择功能</label>
                <div class="col-sm-5">
                    <select class="select2 form-control gmSelector">
                        <?php foreach ($data as $k=>$v){?>
                            <option value="<?=$k?>"><?=$v["name"]?></option>
                        <?php }?>
                    </select>
                </div>
            </div>
        </div>
    </div>

    <div class="container-fluid">
        <?php foreach ($data as $k=>$v){?>
        <aside>
            <form class="form-horizontal <?=$k?> asideForm" role="form" method="post" enctype="multipart/form-data"  action="#" style="margin-top: 20px;border: 1px solid #CCC;display: <?php if($k != 'loginLog') echo 'none';else echo 'block';?>">
                <header><i class="fa fa-fw fa-file"></i><?php echo $v["name"]?></header>

                <div class="content_wrapper returndata-wraper" style="display: none">
                    <div class="container-fluid">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">返回数据</label>
                            <div class="col-sm-8">
                                <pre rows="12" class="  showInfo" name='returndata'  ></pre>
                            </div>
                        </div>
                    </div>
                </div>

                <section>
                    <div class="container-fluid">
                        <div class="row" style="border: 1px solid #CCC;margin:10px 5px;padding: 10px 0;">
                                <input type="hidden" class="form-control"  name="type" value="<?=$v['act']?>">
                                <?php foreach ($v["args"] as $key=>$val){?>
                                    <div class="form-group" >
                                        <label class="col-sm-2 control-label"><?php echo $val["title"]?><spin class="tisi"><?php echo $val["tips"]?></spin></label>
                                        <div class="col-sm-10">
                                            <input type="text" class="form-control"  name="<?php echo $key?>" value="">
                                        </div>
                                    </div>
                                <?php }?>
                        </div>
                    </div>
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-sm-12">
                                <button type="button" class="btn btn-success subSendRequest" >提交</button>
                            </div>
                        </div>
                    </div>
                </section>
            </form>
        </aside>
        <?php }?>
    </div>
</div>
</body>
<script type="text/javascript" src="https://cdn.bootcdn.net/ajax/libs/jquery-jsonview/1.2.3/jquery.jsonview.js"></script>
<script src="<?php echo base_url();?>public/js/vendor/select2/select2.full.min.js"></script>
<script>

    $(".select2").select2();

    $('.select2').change(function(){
        $('.asideForm').hide();
        $('.'+$(this).val()).show()
    })
    $(function () {
        $('.subSendRequest').click(function () {
            var _this = $(this)
            var t=$(this).parents(".form-horizontal").serializeArray();
            var data=new FormData();
            $.each(t, function() {
                data.append(this.name, this.value);
            });
            $(".returndata-wraper").hide()
            _this.parents('form').find(".returndata-wraper").show()
            $.ajax({
                url: rootPath + 'debug/sendRequest',
                type: 'POST',
                data: data,
                dataType: 'json',
                contentType: false,
                processData: false,
                success: function (data) {
                    _this.parents('form').find(".showInfo").JSONView(data.data, {collapsed: false, nl2br: true, recursive_collapser: true });
                    // _this.parents('form').find(".showInfo").html(JSON.stringify(data.data), null, 2);
                    console.log(data);
                    alert(data.msg);
                    // window.location.reload();
                },
                error: function (msg) {
                    alert(data.msg);
                }
            });
        });
    });
</script>
</html>
