<!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;
        }

    </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="goodForm" action="#" style="margin-top: 20px">
                <input type="hidden" value="<?php echo $id;?>" name="id"/>
                <input type="hidden" value="rank" name="type"/>
                <header><i class="fa fa-fw fa-file"></i>偷打活动奖励</header>
                <section>
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-sm-12">
                                <button type="button" class="btn btn-success" id="goodsubmitBtn">提交</button>
                            </div>
                        </div>
                    </div>
                    <div class="container-fluid">
                        <?php foreach ($reward as $key => $vl) { ?>
                            <div class="row" style="border: 1px solid #CCC;margin:10px 5px;padding: 5px 0;">
                                <div class="form-group" >
                                    <label class="col-sm-1 control-label">阶段*: </label>
                                    <div class="col-sm-1">
                                        <input type="text" class="form-control" readonly name="reward[<?php echo $vl['stage'];?>][stage]" value="<?php echo $vl['stage'];?>">
                                    </div>
                                    <label class="col-sm-1 control-label">阶段值*: </label>
                                    <div class="col-sm-1">
                                        <input type="text" class="form-control"  name="reward[<?php echo $vl['stage'];?>][max]" value="<?php echo $vl['max'];?>">
                                    </div>
                                    <div class="col-sm-3">
                                        <label class="col-sm-4 control-label">活动类型:</label>
                                        <select class="form-control" name="reward[<?php echo $vl['stage'];?>][type]" style="display: inline-block;width: 50%">
                                            <option value="1" <?php if($vl['type'] == 1){ echo 'selected';}?> >金币</option>
                                            <option value="2" <?php if($vl['type'] == 2){ echo 'selected';}?> >体力</option>
                                        </select>
                                    </div>
                                    <label class="col-sm-1 control-label">奖励数量*: </label>
                                    <div class="col-sm-1">
                                        <input type="text" class="form-control"  name="reward[<?php echo $vl['stage'];?>][num]" value="<?php echo $vl['num'];?>">
                                    </div>
                                </div>
                            </div>
                        <?php } ?>
                    </div>
                </section>
            </form>
        </aside>
    </div>
</div>
</body>

<script>
    function setModel() {
        $.ajax({
            url: rootPath + 'activity/setRankModel',
            type: 'POST',
            data: {
                'model':$('#RankModel').val(),
            },
            dataType: 'json',
            success: function (data) {
                alert(data.msg);
            },
            error: function (data) {
                alert(data.msg);
            }
        }) ;
    }
    $(function () {
        $('#goodsubmitBtn').click(function () {
            var data = new FormData(document.getElementById("goodForm"));
            $.ajax({
                url: rootPath + 'activity/actionConfig',
                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);
                }
            });
        });
        $('#configsubmitBtn').click(function () {
            var data = new FormData(document.getElementById("configForm"));
            $.ajax({
                url: rootPath + 'activity/actionConfig',
                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);
                }
            });
        });
    });
</script>
</html>
