room.php
5.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<?php
use yii\web\View;
use yii\helpers\Html;
use backend\widgets\LinkPager;
use backend\widgets\YHGImage\Common\Images as CommonImages;
$this->title = $this->params['main_title'].'-'.$this->params['sub_title'];
?>
<?php echo $this->render('@app/views/layouts/websocket');?>
<script type="text/javascript">
<?php $this->beginBlock('javascript');?>
/**
* 推送房间结束直播指令
* @returns {undefined}
*/
function stopLiving(room_id){
if (!confirm('将房间设为直播结束状态,确定?')){
return;
}
callWebsocket(function(){
consoleLog('');
consoleLog('发起房间结束直播指令');
cmd = {cmd:11,room:room_id,msg:'',videoLen:'',uid:''};
cmd = makeSign(cmd);
cmd = JSON.stringify(cmd);
consoleLog('发送消息: '+cmd);
ws.send(cmd);
alert('指令已发送');
},function(){
$.get('/ajax/stopliving',{room_id:room_id},function(json){
console.log(json);
if (json.data){
consoleLog('监听到推送记录: '+json.data);
window.location.reload();
}
},'json');
alert('推送成功');
},function(){
alert('推送失败!');
});
}
<?php
$this->endBlock();
$this->registerJs($this->blocks['javascript'],View::POS_END)
?>
</script>
<div class="panel panel-default">
<div class="panel-body">
<form action="" method="GET" class="form-inline">
<div>
<?=$filter?>
</div>
</form>
</div>
</div>
<div class="form-group">
<label>
<a href="/live/roomcreate" class="btn btn-primary">+ 创建房间</a>
</label>
</div>
<div class="row">
<div class="col-md-12">
<div class="table-responsive">
<table class="table mb30">
<thead>
<tr style="white-space:nowrap">
<th><input type="checkbox" onclick="checkall(this)">选择</th>
<th>房间号</th>
<th>APP</th>
<th>直播标题</th>
<th>头图</th>
<th>主播</th>
<th>预告开始时间</th>
<th>房间密钥</th>
<th>是否精选</th>
<th>马甲状态</th>
<th>直播状态</th>
<th>在线人数</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<?php foreach ($list as $model):?>
<tr data-stock="1" data-source="1" data-status="2" data-id="5011880">
<td><input type="checkbox" value="<?=$model->id?>" name="room[]"></td>
<td><?=$model->room_id?></td>
<td><?=$model->app?></td>
<td><?=$model->title?></td>
<td><img height="70" alt="房间封面图片" src="<?=CommonImages::getImageUrl($model->pic, 70, 70, 2)?>"></td>
<td><?=$model->master ? $model->master->master_id.' '.$model->master->name : '无主播'?></td>
<td style="white-space:nowrap"><?=$model->starting_time ? date('Y-m-d H:i:s',$model->starting_time) : ''?></td>
<td><?=$model->secret?></td>
<td><?=Yii::$app->params['config']['best'][$model->best]?></td>
<td><?=Yii::$app->params['config']['vest'][$model->vest]?></td>
<td><?=Yii::$app->params['config']['room_living'][$model->living]?></td>
<td>
真实:<?=@$model->roomNums->online_num ? :0?>,
马甲:<?=@$model->roomNums->vest_online_num ? :0?>
</td>
<td>
<span>
<?php if ($model->living == 1)://直播中?>
<button type="button" onclick="stopLiving(<?=$model->room_id?>)" class="btn btn-danger btn-metro">结束直播</button>
<?php else:?>
<a onclick="return confirm('将房间设为直播中状态,确定?')" href="/live/roomoperate/<?=$model->id?>?type=start" class="btn btn-success btn-metro">开始直播</a>
<?php endif;?>
</span>
<a href="/live/roomedit/<?=$model->id?>" class="btn btn-default btn-white">编辑</a>
<a href="/forbidden/index?room_id=<?=$model->room_id?>" class="btn btn-default btn-white">禁言</a>
<a href="/product/list/<?=$model->room_id?>" class="btn btn-default btn-white">商品</a>
<span>
<?php if ($model->status == 0)://关闭状态?>
<a onclick="return confirm('启用直播间?')" href="/live/roomoperate/<?=$model->id?>?type=enable" class="btn btn-success btn-metro">启用直播</a>
<a onclick="return confirm('删除直播间?')" href="/live/roomoperate/<?=$model->id?>?type=del" class="btn btn-danger btn-metro">删除</a>
<?php else:?>
<a onclick="return confirm('禁用直播间?')" href="/live/roomoperate/<?=$model->id?>?type=disable" class="btn btn-danger btn-metro">禁用直播</a>
<?php endif;?>
</span>
</td>
</tr>
<?php endforeach;?>
</tbody>
</table>
</div>
<!-- table-responsive -->
<?php echo LinkPager::widget(['pagination' => $pagination]);?>
</div>
<!-- col-md-12 -->
</div>