12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- <?php
- declare(strict_types=1);
- namespace app\mobile\controller;
- use think\facade\Request;
- use app\model\Employee;
- use app\model\Broadcast as BroadcastModel;
- use xiaohongwu\Vr;
- class Broadcast extends Base
- {
- /**
- * 直播列表
- */
- public function lists()
- {
- $where = [
- ['broadcast_type','=',0],
- ['root_id','=',0],
- ['del','=',0]
- ];
- $list = BroadcastModel::with(['lecturer'=>function($query){
- $query->bind(['lecturer_name'=>'name']);
- }])->where($where)->order('id desc')->limit(2)->select()->toArray();
- if($list){
- foreach ($list as $key => $value) {
- $list[$key]['time'] = date('Y-m-d')==$value['start_date'] ? '今日:'.date('H:i') : date('m-d',strtotime($value['start_date']));
- $list[$key]['start_date'] = date('m月d日 H:i',strtotime($value['start_date']));
- $list[$key]['introduce'] = $value['introduce'] ?: '';
- }
- }
- return json(['code'=>0,'data'=>$list]);
- }
- /**
- * 威哥直播列表
- */
- public function list()
- {
- $where = [
- ['broadcast_type','=',1],
- ['root_id','=',0],
- ['del','=',0]
- ];
- $info = BroadcastModel::where($where)->order('id desc')->limit(2)->findOrEmpty();
-
- if(!$info->isEmpty()){
- //预约人数
- $info['number_count'] = 0;
- $info['time'] = date('Y-m-d')==$info['start_date'] ? '今日:'.date('H:i') : date('m-d',$info->getData('start_date'));
- $info['res'] = time()<$info['start_date'] ? '预告' : (time()<$info['end_date'] ? '直播中' : '直播已结束');
- $info['introduce'] = $info['introduce'] ?: '';
- }
- return json(['code'=>0,'data'=>$info]);
- }
- /**
- * 直播页面 列表
- * 直播中 直播列表 直播回放
- */
- public function getList()
- {
- $param = Request::only(['page'=>1,'limit'=>10,'keyword'=>'','type'=>0]);
- $where = [
- ['broadcast_type','=',0],
- ['root_id','=',0],
- ['del','=',0]
- ];
- if($param['keyword']) $where[] = ['name','like','%'.$param['keyword'].'%'];
- if ($param['type']==1) {
- //直播预告
- $where[] = ['start_date','>',time()];
- }elseif ($param['type']==2) {
- //直播中
- $where[] = ['start_date','<',time()];
- $where[] = ['end_date','>',time()];
- }elseif ($param['type']==3) {
- //直播回放
- $where[] = ['end_date','<',time()];
- }
- $res = BroadcastModel::with(['lecturer'=>function($query){
- $query->bind(['lecturer_name'=>'name']);
- }])->where($where)->order('start_date asc')->select()->toArray();
- foreach ($res as $key => $value) {
- $res[$key]['res'] = time()<strtotime($value['start_date']) ? '预告' : (time()<strtotime($value['end_date']) ? '直播中' : '直播已结束');
- $res[$key]['time'] = date('m月d日 H:i',strtotime($value['start_date']));
- }
- $count = BroadcastModel::where($where)->count();
- return json(['code'=>0,'data'=>$res,'count'=>$count]);
- }
- }
|