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

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

<div class="col-md-6">

    <div class="panel panel-default">
        <div class="panel-heading">
            <h5 class="panel-title">导入马甲</h5>
            <p>剩余马甲数:<?php echo $imVestNums?></p>
        </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 class="panel panel-default">
        <div class="panel-heading">
            <h5 class="panel-title">查看观看人数</h5>
        </div>
        <div class="panel-body">
            <div class="form-group">
                <label class="col-sm-3 control-label">请输入房间号:</label>
                <div class="col-sm-3">
                    <input type="text" class="form-control" id="room_id" name="room_id" >
                </div>
                <div class="col-sm-4">
                    <button type="button" class="btn btn-primary mr5" id="search_audi_btn">查询</button>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">观看数:</label>
                <div class="col-sm-2">
                    <input type="text" class="form-control" id="actual_num" disabled>
                </div>
                <div class="col-sm-1">
                    +
                </div>
                <div class="col-sm-2">
                    <input type="text" class="form-control" id="addup_num">
                </div>
                <div class="col-sm-1">
                    *10 =
                </div>
                <div class="col-sm-2">
                    <input type="text" class="form-control" id="result_num" disabled>
                </div>
                <div class="col-sm-1">
                    <button type="button" class="btn btn-primary" id="modify_addup_btn">修改</button>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">点赞数:</label>
                <div class="col-sm-3">
                    <input type="text" class="form-control" id="like_num">
                </div>
                <div class="col-sm-1">
                    <button type="button" class="btn btn-primary" id="modify_like_btn">修改</button>
                </div>
            </div>

        </div>
    </div>
</div>
<div class="col-md-6">
    <p>马甲库里总共可用马甲为4902条,如果要全部导入,须分5批导入,每批1000条</p>
    <p>offset:导入马甲的起始序号,第一次填0,后面会自动根据导入的批量累加</p>
    <p>limit:每批次导入马甲的数量</p>
    <p>(ps:不会的不要乱添加,否则后果自负!!!)</p>
</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');
        });
        //查询房间信息
        $('#search_audi_btn').live("click",function(){

            var room_id = $('#room_id').val();
            if(room_id == '')
                return;
            $.post("/system/getaudnums",{room_id:room_id},function(data){
                if(data.code==200){
                    var values = data.data;
                    $("#actual_num").val(values.audience);
                    $("#addup_num").val(values.addup);
                    $("#result_num").val(Number(values.audience)+Number(values.addup)*10);
                    $("#like_num").val(values.like);
                }
            },'json')
        });
        //修改观看数
        $('#modify_addup_btn').live("click",function(){

            var room_id = $('#room_id').val();
            var addup_num = $('#addup_num').val();
            if(room_id == '')
                return;
            modify_cache(room_id,'addup',addup_num);
        });
        //修改点赞数
        $('#modify_like_btn').live("click",function(){

            var room_id = $('#room_id').val();
            var like_num = $('#like_num').val();
            if(room_id == '')
                return;
            modify_cache(room_id,'like',like_num);
        });
        function modify_cache(room_id,cache_key,cache_val) {
            $.post("/system/modifycache",{room_id:room_id,cache_key:cache_key,cache_val:cache_val},function(data){
                if(data.code==200) {
                    alert(data.msg);
                }else {
                    alert(data.msg);
                }
            },'json')
        }
    });
</script>