LivevideoController.class.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <?php
  2. /**
  3. * lionfish 商城系统
  4. *
  5. * ==========================================================================
  6. * @link http://www.liofis.com/
  7. * @copyright Copyright (c) 2015 liofis.com.
  8. * @license http://www.liofis.com/license.html License
  9. * ==========================================================================
  10. * 小程序直播模块
  11. * @author J_da
  12. *
  13. */
  14. namespace Home\Controller;
  15. class LivevideoController extends CommonController {
  16. protected function _initialize()
  17. {
  18. parent::_initialize();
  19. }
  20. /**
  21. * 获取列表
  22. */
  23. public function get_roominfo()
  24. {
  25. $gpc = I('request.');
  26. $pindex = max(1, intval($gpc['page']));
  27. $psize = 5;
  28. $params = array(':uniacid' => $_W['uniacid']);
  29. $offset = ($pindex - 1) * $psize;
  30. $expirtime = S('_inc_live_expirtime_');
  31. // if (time() > 600 + intval($expirtime, 0)) {
  32. // D('Livevideo')->syncRoomList();
  33. // }
  34. $list = M("lionfish_comshop_wxlive")
  35. ->where(array('is_show'=>1))
  36. ->order('is_top desc,start_time desc')
  37. ->limit($offset, $psize)
  38. ->select();
  39. if (!empty($list)) {
  40. foreach ($list as &$row) {
  41. $row['goods_list'] = json_decode($row['goods'], true);
  42. unset($row['goods']);
  43. $row['start_time'] = date('Y-m-d H:i', $row['start_time']);
  44. $row['end_time'] = date('Y-m-d H:i', $row['end_time']);
  45. $replayRes = M("lionfish_comshop_wxlive_replay")->where(array('roomid'=>$row['roomid']))->find();
  46. $row['has_replay'] = 0;
  47. if($replayRes) $row['has_replay'] = 1;
  48. }
  49. }
  50. // 分享信息
  51. $share = array();
  52. $share['name'] = D('Home/Front')->get_config_by_name('live_nav_name');
  53. $share['title'] = D('Home/Front')->get_config_by_name('live_share_title');
  54. $live_share_image = D('Home/Front')->get_config_by_name('live_share_image');
  55. if(!empty($live_share_image)) $share['img'] = tomedia($live_share_image);
  56. $showTabbar = false;
  57. $tabbar_out_type = D('Home/Front')->get_config_by_name('tabbar_out_type');
  58. if($tabbar_out_type==7) $showTabbar = true;
  59. if(count($list))
  60. {
  61. echo json_encode( array('code' => 0, 'data'=>$list, 'showTabbar'=>$showTabbar, 'share'=>$share) );
  62. die();
  63. } else{
  64. echo json_encode( array('code' => 1, 'showTabbar'=>$showTabbar, 'share'=>$share) );
  65. die();
  66. }
  67. }
  68. public function get_replay()
  69. {
  70. $gpc = I('request.');
  71. $roomid = intval($gpc['room_id'], 0);
  72. if(!$roomid) {
  73. echo json_encode( array('code' => 1, 'msg'=>'直播间id错误') );
  74. die();
  75. }
  76. $roomInfo = D('Livevideo')->getRoomInfo($roomid);
  77. if($roomInfo && $roomInfo['live_replay']) {
  78. $live_replay = unserialize($roomInfo['live_replay']);
  79. $roomInfo['goods_list'] = json_decode($roomInfo['goods'], true);
  80. unset($roomInfo['goods']);
  81. unset($roomInfo['live_replay']);
  82. echo json_encode( array('code' => 0, 'data'=>$live_replay, 'roominfo'=>$roomInfo, 'from'=>'sql') );
  83. die();
  84. } else {
  85. $res = D('Livevideo')->syncLiveReplay($roomid);
  86. if($res) {
  87. echo json_encode( array('code' => 0, 'data'=>$res, 'roominfo'=>$roomInfo, 'from'=>'wechat') );
  88. die();
  89. } else {
  90. echo json_encode( array('code' => 1, 'msg'=>'暂无回放') );
  91. die();
  92. }
  93. }
  94. }
  95. function getReqNum()
  96. {
  97. // S('_inc_live_replay_reqnum_', 0);
  98. // S('_inc_live_roominfo_reqnum_', 0);
  99. $replayReqNum = S('_inc_live_replay_reqnum_');
  100. $roominfoReqNum = S('_inc_live_roominfo_reqnum_');
  101. echo json_encode( array('code' => 0, 'replay'=>$replayReqNum, 'roominfo'=>$roominfoReqNum) );
  102. die();
  103. }
  104. }