<div class="content_wrapper">
    <style>
        .btn-name {
            white-space: nowrap;
        }
    </style>
    <div class="container-fluid">
        <div id="msg-tip"></div>
        <div class="row">

            <div class="col-sm-12">
                <aside>
                    <header><i class="fa fa-fw fa-file"></i>广告配置</header>
                    <!--                    <div class="ibox-title" style="border-style: none">-->
                    <!--                        <a type="button" class="btn btn-outline btn-success"  href="#ad/resaveJson/">刷新配置（变更配置后操作）</a>-->
                    <!--                    </div>-->
                    <section>
                        <div class="container-fluid">
                            <div class="row">
                                <div class="col-sm-12">
                                    <div class="table-responsive">
                                        <table id="example" class="table table-striped table-bordered table-hover" cellspacing="0" width="100%">
                                            <thead>
                                            <tr>
                                                <th>广告ID</th>
                                                <th>广告名称</th>
                                                <th>奖品</th>
                                                <th>开关</th>
                                                <th>操作</th>
                                            </tr>
                                            </thead>
                                            <tbody>
                                            <?php
                                            if(!empty($list)){
                                                foreach ($list as $key => $vl) { ?>
                                                    <tr>
                                                        <td><?php echo $vl['id'];?></td>
                                                        <td><?php echo $vl['name'];?></td>

                                                        <td class="rewardShow" data-value='<?=$vl["reward"]?>'></td>
                                                        <td><?php echo $vl['status'] != 0 ?  '<span class="label label-success">开</span>' : '<span class="label label-default">关</span>';?></td>
                                                        <td>
                                                            <a href="#ad/edit/<?php echo $vl['id'];?>" class="btn btn-primary active" role="button">编辑</a>
                                                        </td>
                                                    </tr>
                                                <?php }
                                            } else{?>
                                                <tr>
                                                    <td colspan="10">暂无数据</td>
                                                </tr>
                                            <?php } ?>
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </section>
                </aside>
            </div>
        </div>
    </div>
</div>
<script src="<?php echo base_url(); ?>public/js/common.js"></script>
<script>
    propsJs.initTag('formPropsRewardsTag')
    propsJs.initTag('rewardShow')
    $("#subAdd").click(function (){
        var data = $('#mForm').toObject()
        data["rewards"] = $(".formPropsRewardsTag").data("value")
        // console.log(data)
        $.ajax({
            url: rootPath + 'Customer/sendGameMailReward',
            type: 'POST',
            data: data,
            dataType: 'json',
            success: function (data2) {

                console.log(data2)
                alert(data2.msg);
                // confirm(data.msg);
                window.location.reload();
            },
            error: function (data2) {
                console.log(data2)
                alert(data2.msg);
            }
        });

    })
</script>