<!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="form1" action="#" style="margin-top: 20px">
                <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="submitBtn1">提交</button>
                            </div>
                        </div>
                    </div>
                    <div class="container-fluid addOrDelControl">
                        <?php foreach ($stealRetWeightV2 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-2">
                                        <input type="text" style="display: inline-block;width: 45%" class="form-control" name="config[<?php echo $vl['id'];?>][slv]" value="<?php echo $vl['slv'];?>">
                                        <input type="text" style="display: inline-block;width: 45%" class="form-control" name="config[<?php echo $vl['id'];?>][elv]" value="<?php echo $vl['elv'];?>">
                                    </div>
                                    <button type="button" class="btn btn-danger deleteParent" >删除</button>
                                </div>
                                <div class="ret-list">
                                <?php foreach ($vl['proportion'] as $i => $vel) {  ?>
                                    <div class="form-group" >
                                        <label class="col-sm-1 control-label">金币百分比*: </label>
                                        <div class="col-sm-1">
                                            <input type="text" class="form-control" name="<?php echo "config[{$vl['id']}][proportion][{$i}]";?>" value="<?php echo $vl['proportion'][$i];?>">
                                        </div>
                                        <label class="col-sm-1 control-label">权重*: </label>
                                        <div class="col-sm-1">
                                            <input type="text" class="form-control" name="<?php echo "config[{$vl['id']}][weight][{$i}]";?>" value="<?php echo $vl['weight'][$i];?>">
                                        </div>
                                        <label class="col-sm-1 control-label">奖励*: </label>
                                        <div class="col-sm-1">
                                            <table class="col-sm-12" style="">
                                                <tr>
                                                    <td class="formPropsRewardsTag" data-value='<?= json_encode($vl['props'][$i]??[]) ?>' data-name='<?php echo "config[{$vl['id']}][props][{$i}]";?>'>
                                                    </td>
                                                    <td class="text-right" style="width: 80px">
                                                        <button type="button"
                                                                class="btn btn-outline btn-success"
                                                                onclick="propsJs.initEdit(this, 'formPropsRewardsTag','func')">
                                                            奖励配置
                                                        </button>
                                                    </td>
                                                </tr>
                                            </table>
                                        </div>
                                    </div>
                                <?php } ?>
                                </div>
                            </div>
                        <?php } ?>
                    </div>
                    <button type="button" class="btn btn-success stealRetWeight" k="<?php echo count($stealRetWeightV2) + 1;?>" style="margin-left: 12px;margin-bottom: 10px;">增加</button>
                </section>
            </form>
        </aside>
    </div>
    <div class="container-fluid">
        <aside>
            <form class="form-horizontal" role="form" method="post" enctype="multipart/form-data"  id="form3" action="#" style="margin-top: 20px">
                <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="submitBtn3">提交</button>
                            </div>
                        </div>
                    </div>
                    <div class="container-fluid addOrDelControl">
                        <?php foreach ($betRetWeightV2 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" name="config[<?php echo $vl['id'];?>][bet]" value="<?php echo $vl['bet'];?>">
                                    </div>
                                    <label class="col-sm-1 control-label">系数a*: </label>
                                    <div class="col-sm-1">
                                        <input type="text" class="form-control" name="config[<?php echo $vl['id'];?>][coefficient][a]" value="<?php echo $vl['coefficient']['a'];?>">
                                    </div>
                                    <label class="col-sm-1 control-label">系数b*: </label>
                                    <div class="col-sm-1">
                                        <input type="text" class="form-control" name="config[<?php echo $vl['id'];?>][coefficient][b]" value="<?php echo $vl['coefficient']['b'];?>">
                                    </div>
                                    <label class="col-sm-1 control-label">系数c*: </label>
                                    <div class="col-sm-1">
                                        <input type="text" class="form-control" name="config[<?php echo $vl['id'];?>][coefficient][c]" value="<?php echo $vl['coefficient']['c'];?>">
                                    </div>
                                    <label class="col-sm-1 control-label">系数d*: </label>
                                    <div class="col-sm-1">
                                        <input type="text" class="form-control" name="config[<?php echo $vl['id'];?>][coefficient][d]" value="<?php echo $vl['coefficient']['d'];?>">
                                    </div>
                                    <button type="button" class="btn btn-danger deleteParent" >删除</button>
                                </div>
                            </div>
                        <?php } ?>
                    </div>
                    <button type="button" class="btn btn-success betRetWeight" k="<?php echo count($betRetWeightV2) + 1;?>" style="margin-left: 12px;margin-bottom: 10px;">增加</button>
                </section>
            </form>
        </aside>
    </div>
    <div class="container-fluid">
        <aside>
            <form class="form-horizontal" role="form" method="post" enctype="multipart/form-data"  id="form4" action="#" style="margin-top: 20px">
                <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="submitBtn4">提交</button>
                            </div>
                        </div>
                    </div>
                    <div class="container-fluid addOrDelControl">
                        <?php foreach ($stealLimitWeight 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-2">
                                        <input type="text" style="display: inline-block;width: 45%" class="form-control" name="config[<?php echo $vl['id'];?>][slv]" value="<?php echo $vl['slv'];?>">
                                        <input type="text" style="display: inline-block;width: 45%" class="form-control" name="config[<?php echo $vl['id'];?>][elv]" value="<?php echo $vl['elv'];?>">
                                    </div>
                                    <button type="button" class="btn btn-danger deleteParent" >删除</button>
                                </div>
                                <div class="form-group" >
                                    <?php foreach ($vl['weight'] as $ke => $vel) {  ?>
                                        <label class="col-sm-1 control-label"><?php echo "次数".($ke+3)."*:";?></label>
                                        <div class="col-sm-1">
                                            <input type="text" class="form-control" name="<?php echo "config[{$vl['id']}][weight][{$ke}]";?>" value="<?php echo $vel;?>">
                                        </div>
                                    <?php } ?>

                                </div>
                            </div>
                        <?php } ?>
                    </div>
                    <button type="button" class="btn btn-success stealLimitWeight" k="<?php echo count($stealLimitWeight) + 1;?>" style="margin-left: 12px;margin-bottom: 10px;">增加</button>
                </section>
            </form>
        </aside>
    </div>
</div>
</body>
<script src="<?php echo base_url();?>public/js/common.js"></script>
<script>
    propsJs.initTag('formPropsRewardsTag','func')


    $('.addOrDelControl').on("click",'.deleteParent',function(){
        $(this).parent().parent().remove();
    });
    //添加偷占比权重
    $('.stealRetWeight').on("click",function(){
        var k   = $(this).attr('k');
        var info = "";
        for (var i=0;i<4;i++){
            info += '<div class="form-group" >' +
                        '<label class="col-sm-1 control-label">金币百分比*:  </label>' +
                        '<div class="col-sm-1"><input type="text" class="form-control" name="config['+k+'][proportion]['+i+']" value="1"></div>' +
                        '<label class="col-sm-1 control-label">权重*: </label>' +
                        '<div class="col-sm-1"><input type="text" class="form-control" name="config['+k+'][weight]['+i+']" value="1"></div>' +
                        '<label class="col-sm-1 control-label">奖励*: </label>' +
                        '<div class="col-sm-1">' +
                            '<table class="col-sm-12" style="">' +
                                '<tr>' +
                                    '<td class="formPropsRewardsTag" data-value="[]" data-name="config['+k+'][props]['+i+']"></td> ' +
                                    '<td class="text-right" style="width: 80px"> ' +
                                        '<button type="button" class="btn btn-outline btn-success" onclick="propsJs.initEdit(this, \'formPropsRewardsTag\',\'func\')"> 奖励配置 </button> ' +
                                    '</td>' +
                                '</tr>'+
                            '</table>' +
                        '</div>'+
                    '</div>';
        }
        var str = '' +
            '<div class="row lv-list" 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-2">' +
                    '<input type="text" style="display: inline-block;width: 45%" class="form-control" name="config['+k+'][slv]" value="1">' +
                    '<input type="text" style="display: inline-block;width: 45%" class="form-control" name="config['+k+'][elv]" value="2">' +
                    '</div>' +
                    '<button type="button" class="btn btn-danger deleteParent" >删除</button>'+
                '</div>'+
                '<div class="ret-list">'+
                    info+
                '</div>' +
            '</div>';
        $(this).prev().append(str);
        $(this).attr('k',Number(k)+1);
        propsJs.initTag('formPropsRewardsTag','func')
    });
    $('.betRetWeight').on("click",function(){
        var k   = $(this).attr('k');
        var str = '<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" name="config['+k+'][bet]" value="1"></div><label class="col-sm-1 control-label">系数a*: </label><div class="col-sm-1"><input type="text" class="form-control" name="config['+k+'][coefficient][a]" value="1"></div><label class="col-sm-1 control-label">系数b*: </label><div class="col-sm-1"><input type="text" class="form-control" name="config['+k+'][coefficient][b]" value="1"></div><label class="col-sm-1 control-label">系数c*: </label><div class="col-sm-1"><input type="text" class="form-control" name="config['+k+'][coefficient][c]" value="0"></div><label class="col-sm-1 control-label">系数d*: </label><div class="col-sm-1"><input type="text" class="form-control" name="config['+k+'][coefficient][d]" value="1"></div><button type="button" class="btn btn-danger deleteParent" >删除</button></div></div>';
        $(this).prev().append(str);
        $(this).attr('k',Number(k)+1);
    });
    $('.stealLimitWeight').on("click",function(){
        var k   = $(this).attr('k');
        var str2 = ""
        for (var i=0;i<7;i++){
            str2+='' +
                '<label class="col-sm-1 control-label">次数'+(i+3)+'*:</label>'+
                '<div class="col-sm-1">'+
                '<input type="text" class="form-control" name="config['+k+'][weight]['+i+']" value="">'+
                '</div>';
        }
        var str =
                '<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-2">'+
                            '<input type="text" style="display: inline-block;width: 45%" class="form-control" name="config['+k+'][slv]" value="">'+
                            '<input type="text" style="display: inline-block;width: 45%" class="form-control" name="config['+k+'][elv]" value="">'+
                        '</div>'+
                        '<button type="button" class="btn btn-danger deleteParent" >删除</button>' +
                    '</div>' +
                    '<div class="form-group" >'+
                       str2+
                    '</div>'+

                '</div>';
        $(this).prev().append(str);
        $(this).attr('k',Number(k)+1);
    });


    $('#submitBtn1').click(function () {
        var data = new FormData(document.getElementById("form1"));
        $.ajax({
            url: rootPath + 'Slot/actionSlotStealRet/stealRetWeightV2',
            type: 'POST',
            data: data,
            dataType: 'json',
            contentType: false, //必须
            processData: false, //必须
            success: function (data) {
                // console.log(data);
                alert(data.msg);
                if(data.ret == 0){
                    window.location.reload();
                }
            },
            error: function (msg) {
                alert(data.msg);
            }
        });
    });
    $('#submitBtn3').click(function () {
        var data = new FormData(document.getElementById("form3"));
        $.ajax({
            url: rootPath + 'Slot/actionSlotStealRet/betRetWeightV2',
            type: 'POST',
            data: data,
            dataType: 'json',
            contentType: false, //必须
            processData: false, //必须
            success: function (data) {
                alert(data.msg);
                if(data.ret == 0){
                    window.location.reload();
                }
            },
            error: function (msg) {
                alert(data.msg);
            }
        });
    });
    $('#submitBtn4').click(function () {
        var data = new FormData(document.getElementById("form4"));
        $.ajax({
            url: rootPath + 'Slot/actionSlotStealRet/stealLimitWeight',
            type: 'POST',
            data: data,
            dataType: 'json',
            contentType: false, //必须
            processData: false, //必须
            success: function (data) {
                // console.log(data);
                alert(data.msg);
                if(data.ret == 0){
                    window.location.reload();
                }
            },
            error: function (msg) {
                alert(data.msg);
            }
        });
    });
</script>
</html>
