video.php 4.9 KB
<?php 
use backend\widgets\YHGImage\Common\Images as CommonImages;
use backend\widgets\LinkPager;
use yii\helpers\ArrayHelper;

if(!isset($condition['backState']))
{
	$condition['backState'] = -1;
}
?>
<div class="panel panel-default">
    <div class="panel-body">
        <form class="form-inline" method="get" >
            <div>
                <div class="form-group">
                  <label class="control-label">状态:</label>
                   <select id="select-search-state" data-placeholder="" class="width300 select2-offscreen" tabindex="-1" name="backState">
                    <option value="-1" <?php echo $condition['backState'] == -1? 'selected' :''?>>ALL</option>
                    <option value="0" <?php echo $condition['backState'] == 0 ? 'selected' :''?>>未上传回看视频</option>
                    <option value="1" <?php echo $condition['backState'] == 1 ? 'selected' :''?>>已上传回看视频</option>
                </select>
                </div>
                <div class="form-group">
                    <label class="control-label">关键字:</label>
                    <input class="form-control" name="title" value="<?php echo isset($condition['title'])? $condition['title'] :''?>">
                </div>
                <button type="submit" class="btn btn-primary mr5">查询</button>
            </div>
        </form>
    </div>
</div>
<div class="row">
    <div class="col-md-12">
        <div class="table-responsive">
            <table class="table mb30">
                <thead>
                    <tr style="white-space:nowrap">
                        <th>视频ID</th>
                        <th>APP</th>
                        <th>视频标题</th>
                        <th>头图</th>
                        <th>对应直播标题</th>
                        <th>对应直播时间</th>
                        <th>对应主播</th>
                        <th>对应直播房间号</th>
                        <th>腾讯视频连接</th>
                        <th>操作</th>
                        <th>创建时间</th>
                    </tr>
                </thead>
                <tbody>
    			<?php foreach($videoList as $video):?>
    			    <tr>
                        <td><?php echo $video->id;?></td>
                        <td><?=ArrayHelper::getValue(Yii::$app->params['config']['app'], $video->app)?></td>
                        <td><?php echo $video->title;?></td>
                        <td><img src="<?php echo CommonImages::getImageUrl($video->pic, 100, 100)?>" /></td>
                        <td><?php echo $video->live_title;?></td>
                        <td><?php echo date('Y-m-d H:i:s', $video->live_start_time).' --- '.date('Y-m-d H:i:s', $video->live_end_time)?></td>
                        <td>
	                        <?php foreach($masterList as $master) {  
	                        	if($master->master_id == $video->master_id) echo $master->name;
	                        }?>
                   		</td>
                        <td><?php echo $video->room_id;?></td>
                        <td><?php echo $video->url;?></td>
                        <td style="white-space:nowrap">
	                        <div class="form-group" videoId="<?php echo $video->id;?>">
	                       		 <button class="btn btn-primary">编辑</button>
	                       		 <button class="btn btn-warning btn-metro" status="<?php echo $video->status;?>"><?php echo $video->status? '关闭':'开启';?></button>
	                        </div>
                        </td>
                        <td><?php echo date('Y-m-d H:i:s', $video->create_time)?></td>
                    </tr>
    			<?php endforeach;?>
                </tbody>
            </table>
        </div>
        <!-- table-responsive -->
        <?php echo LinkPager::widget(['pagination' => $pagination]);?>
    </div>
    <!-- col-md-12 -->
</div>
<link href="/css/select2.css" rel="stylesheet" postion="3">
<script src="/js/select2.min.js" postion="3"></script>
<script type="text/javascript">
$(function(){
    $('#select-search-state').select2({
        minimumResultsForSearch: -1
    });
	//设置状态
	$(".btn-warning").bind("click", function()
	{
		var videoId = $(this).parent().attr("videoId");
		var status = parseInt($(this).attr("status"));
		var msg = '';
		if(status) {
			msg = '你确定要关闭?';
		} else {
			msg = "你确定要开启?";
		}
		status = status == 1 ? 0 :1;//转换
		if(window.confirm(msg)) {
			$.ajax
			({
				type:"post",
				url:"/live/videosetstate",
				data:{videoId:videoId, status:status},
				dataType:"json",
				success:function(data)
				{
					if(data.code == 200)
					{
						window.location.reload();
					}
					else
					{
						alert("设置失败");
					}
				}
			});
		}
	});

	//编辑
	$(".btn-primary").bind("click", function()
	{
		var videoId = $(this).parent().attr("videoId");
		window.location.href="/live/videoedit?id="+videoId;
	});
});
</script>