vest.php 2.36 KB
<?php
use yii\web\View;

$this->title = '管理后台首页';
?>

<div class="col-md-6">
    <p><span>剩余马甲数:</span><?php echo $imVestNums?></p>
    <div class="panel panel-default">
        <div class="panel-heading">
            <h5 class="panel-title">导入马甲</h5>
        </div>
        <div class="panel-body">

            <form class="form-inline">
                <div class="form-group">
                    <label class="sr-only" for="offset">offset</label>
                    <input type="text" class="form-control" id="offset" placeholder="offset">
                </div><!-- form-group -->

                <div class="form-group">
                    <label class="sr-only" for="limit">limit</label>
                    <input type="text" class="form-control" id="limit" placeholder="limit">
                </div><!-- form-group -->

                <div class="form-group" id="btn_bar">
                    <button type="button" class="btn btn-primary mr5" id="import">导入</button>
                </div>
            </form>

        </div>
    </div>
</div>
<div class="col-md-6">
    马甲库里总共可用马甲为4902条,如果要全部导入,须分5批导入,每批1000条
    offset:导入马甲的起始序号,第一次填0,后面会自动根据导入的批量累加<br>
    limit:每批次导入马甲的数量<br>
    (ps:不会的不要乱添加,复杂后果自负!!!)<br>
</div>
<script>
    $(function(){
        $('#import').live("click",function(){
            var offset = $('#offset').val();
            var limit = $('#limit').val();
            var loading_html = "<img src='/images/loaders/loader6.gif'>";
            var import_html = "<button type='button' class='btn btn-primary mr5' id='import'>导入</button>";
            if(limit > 1000){
                alert('每次导入条数不得超过1000');return;
            }
            $("#btn_bar").html(loading_html);
            $.get("/system/vest",{offset:offset,limit:limit},function(data){
//                alert(stat);return;
                if(data.code==200){
                    $('#offset').val(Number(offset)+Number(limit));
                    alert('成功导入'+data.data+'条');
                }else{
                    alert('设置失败');
                }
                $("#btn_bar").html(import_html);
            },'json');
        });
    });
</script>