<head>
<title>真老虎机金币配置</title>
<link rel="stylesheet" href="<?php echo base_url();?>public/css/vendor/bootstrap/bootstrap-table.css">
<link rel="stylesheet" href="<?php echo base_url();?>public/css/vendor/bootstrap/table-fix-column.css">

<script src="<?php echo base_url();?>public/js/vendor/bootstrap/src/bootstrap-table.js"></script>
<script src="<?php echo base_url();?>public/js/vendor/bootstrap/src/table-fix-column.js"></script>

<!-- 最新版本的 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;
    }
    table {
        table-layout:fixed !important;
    }

    th{
        background: rgb(146, 208, 80);
    }

    td,th{
        max-width: 400px;
        word-wrap: break-word;
    }

    .table-hover > tbody > tr:hover {
        background-color: #c8bd6d;
    }

    input {
        width:60px;
    }

    #roleTable tr:nth-child(5n){
        background:rgb(198, 239, 206);
    } /**隔五行*/

    .fixed-table-toolbar {
        display: none;
    }
    .fileinput-button {
        position: relative;
        top: -5px;
    }

    .fileinput-button input{
        position:absolute;
        right: 0px;
        top: 0px;
        opacity: 0;
        -ms-filter: 'alpha(opacity=0)';
    }

</style>
</head>


<!--    等级金币配置-->
<div class="container-fluid">
    <div class="row">
    <div class="col-sm-12">
    <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" style="padding-left: 15px;">
                    <span id="upfile_a" class="btn btn-success fileinput-button">
                        <span>导入</span>
                        <input type="file" id="upfile1">
                    </span>
                    <input type="button" style="display: none;margin-bottom: 10px;width: 80px;" class="btn btn-success" value="上传" id="upfileBtn1"/>
                    <a type="button" href="/Export/RealSlotCoin" style="margin-bottom: 10px;width: 80px;" class="btn btn-success">导出</a>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-12">
                    <div class="table-responsive">
                        <table id="roleTable2" class="table table-bordered table-hover"
                               data-toggle="table"
                               data-classes="table table-hover"
                               data-show-columns="true"
                               data-striped="true"
                               data-height="1000">
                            <thead>
                            <tr>
                                <th>用户等级</th>
                                <th>一个金币</th>
                                <th>两个金币</th>
                                <th>三个金币</th>
                                <th>一个金币袋</th>
                                <th>两个金币袋</th>
                                <th>三个金币袋</th>
                            </tr>
                            </thead>
                            <tbody>
                            <?php
                            if(is_array($list)  && !empty($list)){
                                foreach ($list as $key => $vl) {
                                    echo "<tr>";
                                    foreach ($vl as $item){
                                        echo "<td>{$item}</td>";
                                    }
                                    echo"</tr>";
                                }
                            } else{
                                echo '<tr><td colspan="7">暂无数据</td></tr>';
                            } ?>
                            </tbody>
                        </table>
                    </div>
                    <nav>
                        <ul class="pagination">
                            <li class="disabled"><a href="#">共<span class="pagetotal"><?php echo count($list);?></span>条</a></li>
                        </ul>
                    </nav>
                </div>
            </div>
        </section>
        </form>
    </aside>
    </div></div>
</div>

<script>
    $("#upfile_a").on("change", "input[type='file']", function() {
        var filePath = $(this).val();
        //如果仅上传图片 if(filePath.indexOf("jpg") != -1 || filePath.indexOf("png") != -1) {
        if (filePath) {
            $('#upfile_a').hide();
            $("#upfileBtn1").show();
        } else {
            return false
        }
    });
    //导入金币配置
    $("#upfileBtn1").click(function(){
        var formData = new FormData();
        formData.append("file",document.getElementById("upfile1").files[0]);
        $.ajax({
            type: "POST", // 数据提交类型
            url: "Import/RealSlotCoin", // 发送地址
            data: formData, //发送数据
            async: true, // 是否异步
            processData: false, //processData 默认为false，当设置为true的时候,jquery ajax 提交的时候不会序列化 data，而是直接使用data
            contentType: false, //
            success: function(data) { // 成功回调
                data = JSON.parse(data);
                if(data.ret == 0){
                    // console.log(data)
                    alert(data.msg);
                    window.location.reload();
                }else {
                    // msgTip = $('#msg-tip');
                    alert(data.msg);
                    // window.location.reload();
                }
            }
        });
    });
</script>