comment.php 2.27 KB
<?php
use yii\helpers\Html;
use backend\widgets\LinkPager;

?>
<div class="col-md-12">
    <div class="row">
        <div class="col-md-12">
            <div class="table-responsive">
                <table class="table table-dark mb30">
                    <thead>
                    <tr>
                        <th>用户昵称</th>
                        <th>内容</th>
                        <th>时间</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <?php foreach($list as $v):?>
                        <tr>
                            <td><?php echo $v['name']."(".$v['uid'].")"?></td>
                            <td>
                                <?php
                                if($v['cmd']==5){
                                    echo  $v['comment'];
                                }elseif($v['cmd']==4){
                                    echo  '@'.$v['name'].'加入了房间';
                                }
                                ?>
                            </td>
                            <td><?php echo date('Y-m-d H:i:s',$v['create_time'])?></td>
                            <td><button class="btn btn-danger jinyan" uid="<?php echo $v['uid']?>" name="<?php echo $v['name']?>" room_id="<?php echo $v['room_id']?>">禁言</button></td>
                        </tr>
                    <?php endforeach;?>
                    </tbody>
                </table>
            </div>
            <!-- table-responsive -->
            <?php echo LinkPager::widget(['pagination' => $pagination]);?>
        </div>
        <!-- col-md-12 -->
    </div>
</div>
<script>

    $(function(){
        //5s自动刷新页面
        setInterval(function(){
            window.location.reload();
        },10000);//1000为1秒钟

        //禁言按钮
        $('.jinyan').click(function(){
            if(confirm('禁言该用户?')){
                var uid = $(this).attr('uid');
                var room_id = $(this).attr('room_id');
                var name = $(this).attr('name');
                $.post("/forbidden/create",{uid:uid,name:name,room_id:room_id},function(data){
                    alert(data.message);
                },'json');
            }
        });
    })
</script>