MeetingScreen.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <?php
  2. namespace app\h5\controller;
  3. use app\hander\HelpHander;
  4. use think\Controller;
  5. use think\Db;
  6. use think\Exception;
  7. class MeetingScreen extends Controller
  8. {
  9. private $meetingId;
  10. private $token;
  11. public function __construct()
  12. {
  13. parent::__construct();
  14. $this->token = input('token');
  15. if(empty($this->token)){
  16. $this->redirect(url('index/errorPage'));
  17. }
  18. $this->meetingId = think_decrypt($this->token);
  19. if($this->meetingId < 1){
  20. $this->redirect(url('index/errorPage'));
  21. }
  22. }
  23. public function index(){
  24. $info = Db::name('meeting_room')->where('id',$this->meetingId)->find();
  25. $status = $this->curStatus();
  26. $this->assign('info',$info);
  27. $this->assign('status',$status);
  28. $this->assign('meetingId',$this->token);
  29. return $this->fetch();
  30. }
  31. public function meetingList(){
  32. $curTime = date('Y-m-d H:i:s');
  33. $list = Db::name('meeting_apply')
  34. ->where('meeting_room_id',$this->meetingId)
  35. ->where('del',0)
  36. ->where('start_time', '>=',date('Y-m-d 00:00:00'))
  37. ->where('end_time', '<=',date('Y-m-d 23:59:59'))
  38. ->where('status',1)
  39. ->select();
  40. foreach ($list as $k=>$v){
  41. $statusTxt = '';
  42. $st = 0;
  43. if($v['start_time'] > $curTime){
  44. $statusTxt = '未开始';
  45. $st = 1;
  46. } else if($v['start_time'] <= $curTime && $v['end_time'] >= $curTime){
  47. $statusTxt = '会议中';
  48. $st = 2;
  49. }else if($curTime > $v['end_time']){
  50. $statusTxt = '已结束';
  51. $st = 3;
  52. }
  53. $list[$k]['statusTxt'] = $statusTxt;
  54. $list[$k]['st'] = $st;
  55. $list[$k]['user_name'] = Db::name('user')->where('id',$v['user_id'])->value('real_name');
  56. }
  57. $data = [];
  58. foreach ($list as $k=>$v){
  59. if($v['st'] == 2){
  60. $data[$k][] = '<span style="color:#FFDA0A;font-size: 20px">'.($k+1).'</span>';
  61. $data[$k][] = '<span style="color:#FFDA0A;font-size: 20px">'.$v['user_name'].'</span>';
  62. $data[$k][] = '<span style="color:#FFDA0A;font-size: 20px">'.$v['start_time'].'</span>';
  63. $data[$k][] = '<span style="color:#FFDA0A;font-size: 20px">'.$v['end_time'].'</span>';
  64. $data[$k][] = '<span style="color:#FFDA0A;font-size: 20px">'.$v['statusTxt'].'</span>';
  65. }else{
  66. $data[$k][] = '<span style="font-size: 20px">'.($k+1).'</span>';
  67. $data[$k][] = '<span style="font-size: 20px">'.$v['user_name'].'</span>';
  68. $data[$k][] = '<span style="font-size: 20px">'.$v['start_time'].'</span>';
  69. $data[$k][] = '<span style="font-size: 20px">'.$v['end_time'].'</span>';
  70. $data[$k][] = '<span style="font-size: 20px">'.$v['statusTxt'].'</span>';
  71. }
  72. }
  73. HelpHander::success($data);
  74. }
  75. public function meetingStatus(){
  76. $status = $this->curStatus();
  77. HelpHander::success($status);
  78. }
  79. public function curStatus(){
  80. $curTime = date('Y-m-d H:i:s');
  81. $list = Db::name('meeting_apply')
  82. ->where('meeting_room_id',$this->meetingId)
  83. ->where('del',0)
  84. ->where('start_time', '>=',date('Y-m-d 00:00:00'))
  85. ->where('end_time', '<=',date('Y-m-d 23:59:59'))
  86. ->where('status',1)
  87. ->select();
  88. $status = 0;
  89. foreach ($list as $k=>$v){
  90. if($v['start_time'] <= $curTime && $v['end_time'] >= $curTime){
  91. $status = 1;
  92. }
  93. }
  94. return $status;
  95. }
  96. //二维码
  97. public function qrcode() {
  98. $info = Db::name('meeting_room')->where('id', $this->meetingId)->find();
  99. if (!$info) {
  100. exit('数据不存在');
  101. }
  102. $code = get_qrcode_str('meeting', $this->meetingId);
  103. $this->success('','',$code);
  104. }
  105. }