<!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">
                        <div class="row AllTypeControl" style="border: 1px solid #CCC;margin:10px 5px;padding: 5px 0;">
                            <div class="form-group">
                                <label class="col-sm-1 control-label" style="color: red">基本配置</label>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label">开关 </label>
                                <div class="col-sm-1">
                                    <select class="form-control" name="gameCfg[status]">
                                        <option value="0" <?php if($info['gameCfg']['status'] == 0){ echo 'selected';}?> >关</option>
                                        <option value="1" <?php if($info['gameCfg']['status'] == 1){ echo 'selected';}?> >开</option>
                                    </select>
                                </div>
                                <label class="col-sm-1 control-label">安卓开关 </label>
                                <div class="col-sm-1">
                                    <select class="form-control" name="gameCfg[androidSet][status]">
                                        <option value="0" <?php if($info['gameCfg']['androidSet']['status'] == 0){ echo 'selected';}?> >关</option>
                                        <option value="1" <?php if($info['gameCfg']['androidSet']['status'] == 1){ 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="gameCfg[androidSet][minVersion]" value="<?php echo $info['gameCfg']['androidSet']['minVersion'];?>">
                                </div>
                                <label class="col-sm-1 control-label">IOS开关 </label>
                                <div class="col-sm-1">
                                    <select class="form-control" name="gameCfg[iosSet][status]">
                                        <option value="0" <?php if($info['gameCfg']['iosSet']['status'] == 0){ echo 'selected';}?> >关</option>
                                        <option value="1" <?php if($info['gameCfg']['iosSet']['status'] == 1){ echo 'selected';}?> >开</option>
                                    </select>
                                </div>
                                <label class="col-sm-1 control-label">IOS-最小开启版本</label>
                                <div class="col-sm-1">
                                    <input type="text" class="form-control" name="gameCfg[iosSet][minVersion]" value="<?php echo $info['gameCfg']['iosSet']['minVersion'];?>">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label">免费次数</label>
                                <div class="col-sm-1">
                                    <input type="text" class="form-control" name="gameCfg[freeLimit]" value="<?php echo $info['gameCfg']['freeLimit'];?>">
                                </div>
                                <label class="col-sm-1 control-label">初始化桌面模式</label>
                                <div class="col-sm-1">
                                    <select class="form-control" name="gameCfg[initTableModel]">
                                        <option value="1" <?php if($info['gameCfg']['initTableModel'] == 1){ 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="gameCfg[buyGameLimit][prize]" value="<?php echo $info['gameCfg']['buyGameLimit']['prize'];?>">
                                </div>
                                <label class="col-sm-1 control-label">购买游戏(次数)</label>
                                <div class="col-sm-1">
                                    <input type="text" class="form-control" name="gameCfg[buyGameLimit][maxNum]" value="<?php echo $info['gameCfg']['buyGameLimit']['maxNum'];?>">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label" style="color: red">道具价格</label>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label">价格(p1)</label>
                                <div class="col-sm-1">
                                    <input type="text" class="form-control" name="gameCfg[buyGameProp][p1][prize]" value="<?php echo $info['gameCfg']['buyGameProp']['p1']['prize'];?>">
                                </div>
                                <label class="col-sm-1 control-label">最大次数(p1)</label>
                                <div class="col-sm-1">
                                    <input type="text" class="form-control" name="gameCfg[buyGameProp][p1][maxNum]" value="<?php echo $info['gameCfg']['buyGameProp']['p1']['maxNum'];?>">
                                </div>
                                <label class="col-sm-1 control-label">价格(p2)</label>
                                <div class="col-sm-1">
                                    <input type="text" class="form-control" name="gameCfg[buyGameProp][p2][prize]" value="<?php echo $info['gameCfg']['buyGameProp']['p2']['prize'];?>">
                                </div>
                                <label class="col-sm-1 control-label">最大次数(p2)</label>
                                <div class="col-sm-1">
                                    <input type="text" class="form-control" name="gameCfg[buyGameProp][p2][maxNum]" value="<?php echo $info['gameCfg']['buyGameProp']['p2']['maxNum'];?>">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label" style="color: red">常规用户</label>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label">开放等级</label>
                                <div class="col-sm-1">
                                    <input type="text" class="form-control" name="gameCfg[commonCfg][openLevel]" value="<?php echo $info['gameCfg']['commonCfg']['openLevel'];?>">
                                </div>
                                <label class="col-sm-1 control-label">体验次数</label>
                                <div class="col-sm-1">
                                    <input type="text" class="form-control" name="gameCfg[commonCfg][freeExpLimit]" value="<?php echo $info['gameCfg']['commonCfg']['freeExpLimit'];?>">
                                </div>
                                <label class="col-sm-1 control-label">体验等级</label>
                                <div class="col-sm-1">
                                    <input type="text" class="form-control" name="gameCfg[commonCfg][expLevel]" value="<?php echo $info['gameCfg']['commonCfg']['expLevel'];?>">
                                </div>
                                <label class="col-sm-1 control-label">开放渠道体验</label>
                                <div class="col-sm-1">
                                    <select class="form-control" name="gameCfg[commonCfg][openExp]">
                                        <option value="0" <?php if($info['gameCfg']['commonCfg']['openExp'] == 0){ echo 'selected';}?> >关</option>
                                        <option value="1" <?php if($info['gameCfg']['commonCfg']['openExp'] == 1){ echo 'selected';}?> >开</option>
                                    </select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label" style="color: red">广告渠道用户</label>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label">开放等级</label>
                                <div class="col-sm-1">
                                    <input type="text" class="form-control" name="gameCfg[specialCfg][openLevel]" value="<?php echo $info['gameCfg']['specialCfg']['openLevel'];?>">
                                </div>
                                <label class="col-sm-1 control-label">体验次数</label>
                                <div class="col-sm-1">
                                    <input type="text" class="form-control" name="gameCfg[specialCfg][freeExpLimit]" value="<?php echo $info['gameCfg']['specialCfg']['freeExpLimit'];?>">
                                </div>
                                <label class="col-sm-1 control-label">体验等级</label>
                                <div class="col-sm-1">
                                    <input type="text" class="form-control" name="gameCfg[specialCfg][expLevel]" value="<?php echo $info['gameCfg']['specialCfg']['expLevel'];?>">
                                </div>
                                <label class="col-sm-1 control-label">开放渠道体验</label>
                                <div class="col-sm-1">
                                    <select class="form-control" name="gameCfg[specialCfg][openExp]">
                                        <option value="0" <?php if($info['gameCfg']['specialCfg']['openExp'] == 0){ echo 'selected';}?> >关</option>
                                        <option value="1" <?php if($info['gameCfg']['specialCfg']['openExp'] == 1){ echo 'selected';}?> >开</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                    </div>
                </section>
            </form>
        </aside>
    </div>

    <div class="container-fluid">
        <aside>
            <form class="form-horizontal" role="form" method="post" enctype="multipart/form-data"  id="form2" 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="submitBtn2">提交</button>
                            </div>
                        </div>
                    </div>
                    <div class="container-fluid addOrDelControl">
                        <?php foreach ($info['exchangeRateCfg'] as $key => $vl) {  ?>
                            <div class="form-group" >
                                <label class="col-sm-1 control-label">关卡*: </label>
                                <div class="col-sm-1">
                                    <input type="text" class="form-control" name="exchangeRateCfg[<?php echo $key;?>][level]" value="<?php echo $vl['level'];?>">
                                </div>
                                <label class="col-sm-1 control-label">汇率*: </label>
                                <div class="col-sm-1">
                                    <input type="text" class="form-control" name="exchangeRateCfg[<?php echo $key;?>][er]" value="<?php echo $vl['er'];?>">
                                </div>
                                <button type="button" class="btn btn-danger deleteParent" >删除</button>
                            </div>
                        <?php } ?>
                    </div>
                    <button type="button" class="btn btn-success addExchangeRateCfg" k="<?php echo count($info['exchangeRateCfg']);?>" 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">
                        <?php foreach ($info['siteProbCfg'] as $key => $vl) {  ?>
                            <div class="form-group" >
                                <label class="col-sm-1 control-label">关卡*: </label>
                                <div class="col-sm-1">
                                    <input type="text" class="form-control" name="siteProbCfg[<?php echo $key;?>][id]" value="<?php echo $vl['id'];?>">
                                </div>
                                <label class="col-sm-1 control-label">权重*: </label>
                                <div class="col-sm-1">
                                    <input type="text" class="form-control" name="siteProbCfg[<?php echo $key;?>][weight]" value="<?php echo $vl['weight'];?>">
                                </div>
                            </div>
                        <?php } ?>
                    </div>
                </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 ($info['propDropRule'] as $key => $vl) {  ?>
                            <div class="form-group" >
                                <label class="col-sm-1 control-label">关卡*: </label>
                                <div class="col-sm-1">
                                    <input type="text" class="form-control" name="propDropRule[<?php echo $key;?>][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="propDropRule[<?php echo $key;?>][everyNum]" value="<?php echo $vl['everyNum'];?>">
                                </div>
                                <label class="col-sm-1 control-label">掉落数量*: </label>
                                <div class="col-sm-1">
                                    <input type="text" class="form-control" name="propDropRule[<?php echo $key;?>][dropNum]" value="<?php echo $vl['dropNum'];?>">
                                </div>
                                <button type="button" class="btn btn-danger deleteParent" >删除</button>
                            </div>
                        <?php } ?>
                    </div>
                    <button type="button" class="btn btn-success propDropRule" k="<?php echo count($info['propDropRule']);?>" 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="form5" 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="submitBtn5">提交</button>
                            </div>
                        </div>
                    </div>
                    <div class="container-fluid addOrDelControl">
                        <?php foreach ($info['propProbCfg'] as $key => $vl) {  ?>
                            <div class="form-group" >
                                <label style="width: 5%;" class="col-sm-1 control-label">关卡*: </label>
                                <div style="width: 5%;" class="col-sm-1">
                                    <input type="text" class="form-control" name="propProbCfg[<?php echo $key;?>][id]" value="<?php echo $vl['id'];?>">
                                </div>
                                <label style="width: 5%;" class="col-sm-1 control-label">权重*: </label>
                                <div class="col-sm-1">
                                    <input type="text" class="form-control" name="propProbCfg[<?php echo $key;?>][weight]" value="<?php echo $vl['weight'];?>">
                                </div>
                                <label class="col-sm-1 control-label">道具*: </label>
                                <div class="col-sm-1">
                                    <select class="form-control" name="propProbCfg[<?php echo $key;?>][type]">
                                        <?php foreach ($props as $propsId=>$p) {  ?>
                                            <option value="<?php echo $propsId;?>" <?php if($vl['type'] == $propsId){ echo 'selected';}?> ><?php echo $p['msg'];?></option>
                                        <?php } ?>
                                    </select>
                                </div>
                                <label class="col-sm-1 control-label">固定/随机*: </label>
                                <div class="col-sm-1">
                                    <select class="form-control" name="propProbCfg[<?php echo $key;?>][rtype]">
                                        <option value="2" <?php if($vl['rtype'] == 2){ echo 'selected';}?> >随机</option>
                                        <option value="1" <?php if($vl['rtype'] == 1){ 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="propProbCfg[<?php echo $key;?>][snum]" value="<?php echo $vl['snum'];?>">
                                </div>
                                <label class="col-sm-1 control-label">区间(末)*: </label>
                                <div class="col-sm-1">
                                    <input type="text" class="form-control" name="propProbCfg[<?php echo $key;?>][enum]" value="<?php echo $vl['enum'];?>">
                                </div>
                                <button type="button" class="btn btn-danger deleteParent" >删除</button>
                            </div>
                        <?php } ?>
                    </div>
                    <button type="button" class="btn btn-success propProbCfg" k="<?php echo count($info['propProbCfg']);?>" style="margin-left: 12px;margin-bottom: 10px;">增加</button>
                </section>
            </form>
        </aside>
    </div>
</div>
</body>

<script>
    var idData = JSON.parse('<?php echo json_encode($props); ?>');
    $('.addOrDelControl').on("click",'.deleteParent',function(){
        $(this).parent().remove();
    });
    $('.addExchangeRateCfg').on("click",function(){
        var k   = $(this).attr('k');
        var str = '';
        str += '<div class="form-group" ><label class="col-sm-1 control-label">关卡*: </label><div class="col-sm-1">';
        str += '<input type="text" class="form-control" name="exchangeRateCfg['+k+'][level]" value="1"> </div><label class="col-sm-1 control-label">汇率*: </label><div class="col-sm-1"><input type="text" class="form-control" name="exchangeRateCfg['+k+'][er]" value="1"></div><button type="button" class="btn btn-danger deleteParent" >删除</button></div>';
        $(this).prev().append(str);
        $(this).attr('k',Number(k)+1);
    });
    $('.propDropRule').on("click",function(){
        var k   = $(this).attr('k');
        var str = '';
        str += '<div class="form-group" ><label class="col-sm-1 control-label">关卡*:</label><div class="col-sm-1"> <input type="text" class="form-control" name="propDropRule['+k+'][stage]" value="1"> </div> <label class="col-sm-1 control-label">间隔次数*: </label> <div class="col-sm-1"> <input type="text" class="form-control" name="propDropRule['+k+'][everyNum]" value="1"> </div> <label class="col-sm-1 control-label">掉落数量*: </label>';
        str += '<div class="col-sm-1"> <input type="text" class="form-control" name="propDropRule['+k+'][dropNum]" value="1"> </div> <button type="button" class="btn btn-danger deleteParent" >删除</button></div>';
        $(this).prev().append(str);
        $(this).attr('k',Number(k)+1);
    });
    $('.propProbCfg').on("click",function(){
        var k   = $(this).attr('k');
        var str = '<div class="form-group"><label style="width: 5%;" class="col-sm-1 control-label">关卡*: </label><div style="width: 5%;" class="col-sm-1"><input type="text" class="form-control" name="propProbCfg['+k+'][id]" value="1"></div><label style="width: 5%;" class="col-sm-1 control-label">权重*: </label><div class="col-sm-1"><input type="text" class="form-control" name="propProbCfg['+k+'][weight]" value="1"></div><label class="col-sm-1 control-label">道具*: </label><div class="col-sm-1"><select class="form-control" name="propProbCfg['+k+'][type]">';
        for(var x in idData) {
            str += '<option value="'+x+'">'+idData[x]['msg']+'</option>';
        }
        str += '</select></div><label class="col-sm-1 control-label">固定/随机*: </label><div class="col-sm-1"><select class="form-control" name="propProbCfg['+k+'][rtype]"><option value="2">随机</option><option value="1">固定</option></select></div><label class="col-sm-1 control-label">区间(始)*: </label><div class="col-sm-1"><input type="text" class="form-control" name="propProbCfg['+k+'][snum]" value="1">';
        str += '</div><label class="col-sm-1 control-label">区间(末)*: </label><div class="col-sm-1"><input type="text" class="form-control" name="propProbCfg['+k+'][enum]" value="1"></div><button type="button" class="btn btn-danger deleteParent" >删除</button></div>';
        $(this).prev().append(str);
        $(this).attr('k',Number(k)+1);
    });
    $('#submitBtn1').click(function () {
        var data = new FormData(document.getElementById("form1"));
        $.ajax({
            url: rootPath + 'Config/actionCoinDozer/gameCfg',
            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);
            }
        });
    });

    $('#submitBtn2').click(function () {
        var data = new FormData(document.getElementById("form2"));
        $.ajax({
            url: rootPath + 'Config/actionCoinDozer/exchangeRateCfg',
            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);
            }
        });
    });
    $('#submitBtn3').click(function () {
        var data = new FormData(document.getElementById("form3"));
        $.ajax({
            url: rootPath + 'Config/actionCoinDozer/siteProbCfg',
            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);
            }
        });
    });

    $('#submitBtn4').click(function () {
        var data = new FormData(document.getElementById("form4"));
        $.ajax({
            url: rootPath + 'Config/actionCoinDozer/propDropRule',
            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);
            }
        });
    });
    $('#submitBtn5').click(function () {
        var data = new FormData(document.getElementById("form5"));
        $.ajax({
            url: rootPath + 'Config/actionCoinDozer/propProbCfg',
            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>
