diff --git a/app/Http/Admin/Controllers/ChapterController.php b/app/Http/Admin/Controllers/ChapterController.php index 6cfc8e7c..d941641b 100644 --- a/app/Http/Admin/Controllers/ChapterController.php +++ b/app/Http/Admin/Controllers/ChapterController.php @@ -5,6 +5,7 @@ namespace App\Http\Admin\Controllers; use App\Http\Admin\Services\Chapter as ChapterService; use App\Http\Admin\Services\ChapterContent as ChapterContentService; use App\Http\Admin\Services\Course as CourseService; +use App\Models\ChapterLive as ChapterLiveModel; use App\Models\Course as CourseModel; /** @@ -104,7 +105,9 @@ class ChapterController extends Controller break; case CourseModel::MODEL_LIVE: $live = $contentService->getChapterLive($chapter->id); + $streamName = ChapterLiveModel::generateStreamName($chapter->id); $this->view->setVar('live', $live); + $this->view->setVar('stream_name', $streamName); break; case CourseModel::MODEL_READ: $read = $contentService->getChapterRead($chapter->id); diff --git a/app/Http/Admin/Views/chapter/edit_lesson_live.volt b/app/Http/Admin/Views/chapter/edit_lesson_live.volt index 8d950041..adaad094 100644 --- a/app/Http/Admin/Views/chapter/edit_lesson_live.volt +++ b/app/Http/Admin/Views/chapter/edit_lesson_live.volt @@ -30,7 +30,7 @@
- +
diff --git a/app/Http/Home/Controllers/ChapterController.php b/app/Http/Home/Controllers/ChapterController.php index 7e2b3212..4e46138e 100644 --- a/app/Http/Home/Controllers/ChapterController.php +++ b/app/Http/Home/Controllers/ChapterController.php @@ -50,11 +50,11 @@ class ChapterController extends Controller $this->view->pick('chapter/read'); } elseif ($chapter['model'] == CourseModel::MODEL_LIVE) { if ($chapter['status'] == LiveModel::STATUS_ACTIVE) { - $this->view->pick('chapter/live_active'); + $this->view->pick('chapter/live/active'); } elseif ($chapter['status'] == LiveModel::STATUS_INACTIVE) { - $this->view->pick('chapter/live_inactive'); + $this->view->pick('chapter/live/inactive'); } elseif ($chapter['status'] == LiveModel::STATUS_FORBID) { - $this->view->pick('chapter/live_forbid'); + $this->view->pick('chapter/live/forbid'); } } diff --git a/app/Http/Home/Controllers/LiveController.php b/app/Http/Home/Controllers/ChapterLiveController.php similarity index 77% rename from app/Http/Home/Controllers/LiveController.php rename to app/Http/Home/Controllers/ChapterLiveController.php index 9f205c26..9261f92b 100644 --- a/app/Http/Home/Controllers/LiveController.php +++ b/app/Http/Home/Controllers/ChapterLiveController.php @@ -2,14 +2,14 @@ namespace App\Http\Home\Controllers; -use App\Http\Home\Services\Live as LiveService; +use App\Http\Home\Services\ChapterLive as ChapterLiveService; use App\Traits\Response as ResponseTrait; use Phalcon\Mvc\View; /** * @RoutePrefix("/live") */ -class LiveController extends Controller +class ChapterLiveController extends Controller { use ResponseTrait; @@ -19,12 +19,12 @@ class LiveController extends Controller */ public function chatsAction($id) { - $service = new LiveService(); + $service = new ChapterLiveService(); $chats = $service->getRecentChats($id); $this->view->setRenderLevel(View::LEVEL_ACTION_VIEW); - $this->view->pick('chapter/live_chats'); + $this->view->pick('chapter/live/chats'); $this->view->setVar('chats', $chats); } @@ -33,7 +33,7 @@ class LiveController extends Controller */ public function statsAction($id) { - $service = new LiveService(); + $service = new ChapterLiveService(); $stats = $service->getStats($id); @@ -45,7 +45,7 @@ class LiveController extends Controller */ public function statusAction($id) { - $service = new LiveService(); + $service = new ChapterLiveService(); $status = $service->getStatus($id); @@ -57,7 +57,7 @@ class LiveController extends Controller */ public function bindUserAction($id) { - $service = new LiveService(); + $service = new ChapterLiveService(); $service->bindUser($id); @@ -69,7 +69,7 @@ class LiveController extends Controller */ public function sendMessageAction($id) { - $service = new LiveService(); + $service = new ChapterLiveService(); $response = $service->sendMessage($id); diff --git a/app/Http/Home/Services/Live.php b/app/Http/Home/Services/ChapterLive.php similarity index 97% rename from app/Http/Home/Services/Live.php rename to app/Http/Home/Services/ChapterLive.php index 686c9ba6..82f5b108 100644 --- a/app/Http/Home/Services/Live.php +++ b/app/Http/Home/Services/ChapterLive.php @@ -5,7 +5,7 @@ namespace App\Http\Home\Services; use App\Services\Logic\ChapterTrait; use GatewayClient\Gateway; -class Live extends Service +class ChapterLive extends Service { use ChapterTrait; @@ -140,12 +140,12 @@ class Live extends Service protected function getRecentChatKey($id) { - return "chapter_recent_chat:{$id}"; + return "recent_live_chat:{$id}"; } protected function getGroupName($id) { - return "chapter_{$id}"; + return "live_{$id}"; } } diff --git a/app/Http/Home/Views/chapter/live.volt b/app/Http/Home/Views/chapter/live.volt deleted file mode 100644 index d60e0724..00000000 --- a/app/Http/Home/Views/chapter/live.volt +++ /dev/null @@ -1,25 +0,0 @@ -{% extends 'templates/main.volt' %} - -{% block content %} - - {% if chapter.status == 'active' %} - {{ partial('live/live_active') }} - {% elseif chapter.status == 'inactive' %} - {{ partial('live/live_inactive') }} - {% elseif chapter.status =='forbid' %} - {{ partial('live/live_forbid') }} - {% endif %} - -{% endblock %} - -{% block include_js %} - - {% if chapter.status == 'active' %} - {{ js_include('https://imgcache.qq.com/open/qcloud/video/vcplayer/TcPlayer-2.3.3.js', false) }} - {{ js_include('home/js/chapter.live.player.js') }} - {{ js_include('home/js/chapter.live.chat.js') }} - {{ js_include('home/js/chapter.action.js') }} - {{ js_include('home/js/course.share.js') }} - {% endif %} - -{% endblock %} \ No newline at end of file diff --git a/app/Http/Home/Views/chapter/live_active.volt b/app/Http/Home/Views/chapter/live/active.volt similarity index 100% rename from app/Http/Home/Views/chapter/live_active.volt rename to app/Http/Home/Views/chapter/live/active.volt diff --git a/app/Http/Home/Views/chapter/live_chats.volt b/app/Http/Home/Views/chapter/live/chats.volt similarity index 100% rename from app/Http/Home/Views/chapter/live_chats.volt rename to app/Http/Home/Views/chapter/live/chats.volt diff --git a/app/Http/Home/Views/chapter/live_forbid.volt b/app/Http/Home/Views/chapter/live/forbid.volt similarity index 69% rename from app/Http/Home/Views/chapter/live_forbid.volt rename to app/Http/Home/Views/chapter/live/forbid.volt index 001a4271..ecf9f326 100644 --- a/app/Http/Home/Views/chapter/live_forbid.volt +++ b/app/Http/Home/Views/chapter/live/forbid.volt @@ -12,4 +12,9 @@
+
+
+
直播已禁止,谢谢关注!
+
+ {% endblock %} \ No newline at end of file diff --git a/app/Http/Home/Views/chapter/live_inactive.volt b/app/Http/Home/Views/chapter/live/inactive.volt similarity index 67% rename from app/Http/Home/Views/chapter/live_inactive.volt rename to app/Http/Home/Views/chapter/live/inactive.volt index 98ff4ed3..db0e5667 100644 --- a/app/Http/Home/Views/chapter/live_inactive.volt +++ b/app/Http/Home/Views/chapter/live/inactive.volt @@ -2,22 +2,31 @@ {% block content %} + {% set course_url = url({'for':'home.course.show','id':chapter.course.id}) %} {% set live_status_url = url({'for':'home.live.status','id':chapter.id}) %} + + {% if time() < chapter.start_time %} -
+
直播倒计时开始啦,敬请关注!
{% elseif chapter.start_time < time() and chapter.end_time > time() %} -
+
-
直播时间到了,主播去哪了?
+
直播时间到了,老师去哪了?
{% else %} -
+
直播已结束,谢谢关注!
diff --git a/app/Http/Home/Views/macros/course.volt b/app/Http/Home/Views/macros/course.volt index f25643db..e6f7dfa9 100644 --- a/app/Http/Home/Views/macros/course.volt +++ b/app/Http/Home/Views/macros/course.volt @@ -4,7 +4,7 @@ {% elseif value == '2' %} 直播 {% elseif value == '3' %} - 图文 + 专栏 {% endif %} {%- endmacro %} diff --git a/app/Models/ChapterLive.php b/app/Models/ChapterLive.php index d7c587d1..b31a2203 100644 --- a/app/Models/ChapterLive.php +++ b/app/Models/ChapterLive.php @@ -92,4 +92,14 @@ class ChapterLive extends Model $this->update_time = time(); } + public static function generateStreamName($id) + { + return "chapter_{$id}"; + } + + public static function parseFromStreamName($streamName) + { + return str_replace('chapter_', '', $streamName); + } + } diff --git a/app/Services/LiveNotify.php b/app/Services/LiveNotify.php index 051172d4..ef1fd11d 100644 --- a/app/Services/LiveNotify.php +++ b/app/Services/LiveNotify.php @@ -137,9 +137,9 @@ class LiveNotify extends Service $redis->expire($key, 86400); } - protected function getChapter($streamId) + protected function getChapter($streamName) { - $id = str_replace('chapter_', '', $streamId); + $id = ChapterLiveModel::parseFromStreamName($streamName); $chapterRepo = new ChapterRepo(); diff --git a/app/Services/Logic/Chapter/BasicInfo.php b/app/Services/Logic/Chapter/BasicInfo.php index e5f66dab..f86ddc86 100644 --- a/app/Services/Logic/Chapter/BasicInfo.php +++ b/app/Services/Logic/Chapter/BasicInfo.php @@ -3,6 +3,7 @@ namespace App\Services\Logic\Chapter; use App\Models\Chapter as ChapterModel; +use App\Models\ChapterLive as ChapterLiveModel; use App\Models\Course as CourseModel; use App\Repos\Chapter as ChapterRepo; use App\Services\ChapterVod as ChapterVodService; @@ -79,9 +80,9 @@ class BasicInfo extends Service { $liveService = new LiveService(); - $stream = $this->getStreamName($chapter->id); + $streamName = ChapterLiveModel::generateStreamName($chapter->id); - $playUrls = $liveService->getPullUrls($stream); + $playUrls = $liveService->getPullUrls($streamName); $chapterRepo = new ChapterRepo(); diff --git a/app/Services/Logic/ChapterTrait.php b/app/Services/Logic/ChapterTrait.php index bb2b7aa3..8323437e 100644 --- a/app/Services/Logic/ChapterTrait.php +++ b/app/Services/Logic/ChapterTrait.php @@ -26,11 +26,6 @@ trait ChapterTrait */ protected $chapterUser; - public function getStreamName($id) - { - return "chapter_{$id}"; - } - public function checkChapterVod($id) { $validator = new ChapterValidator(); diff --git a/app/Services/Logic/Teacher/Console/LivePushUrl.php b/app/Services/Logic/Teacher/Console/LivePushUrl.php index 71406879..210d3a15 100644 --- a/app/Services/Logic/Teacher/Console/LivePushUrl.php +++ b/app/Services/Logic/Teacher/Console/LivePushUrl.php @@ -2,6 +2,7 @@ namespace App\Services\Logic\Teacher\Console; +use App\Models\ChapterLive as ChapterLiveModel; use App\Services\Live as LiveService; use App\Services\Logic\ChapterTrait; use App\Services\Logic\Service; @@ -17,7 +18,7 @@ class LivePushUrl extends Service $service = new LiveService(); - $steamName = $this->getStreamName($chapter->id); + $steamName = ChapterLiveModel::generateStreamName($chapter->id); return $service->getPushUrl($steamName); } diff --git a/config/config.default.php b/config/config.default.php index 8fd72d5e..c813a552 100644 --- a/config/config.default.php +++ b/config/config.default.php @@ -115,7 +115,7 @@ $config['metadata']['lifetime'] = 7 * 86400; /** * statsKey */ -$config['metadata']['statsKey'] = '_PH_METADATA_'; +$config['metadata']['statsKey'] = '_METADATA_'; /** * redis库编号 @@ -130,7 +130,7 @@ $config['annotation']['lifetime'] = 7 * 86400; /** * statsKey */ -$config['annotation']['statsKey'] = '_PH_ANNOTATION_'; +$config['annotation']['statsKey'] = '_ANNOTATION_'; /** * 密钥 diff --git a/public/static/home/css/common.css b/public/static/home/css/common.css index 967e023f..45961c94 100644 --- a/public/static/home/css/common.css +++ b/public/static/home/css/common.css @@ -30,10 +30,6 @@ margin-bottom: 0; } -.padding20 { - padding: 20px; -} - .center { text-align: center; } @@ -77,6 +73,10 @@ text-align: center; } +.layer .pager { + margin-top: 0; +} + .loading { padding: 30px; text-align: center; @@ -127,10 +127,6 @@ font-size: 12px; } -.logo { - -} - .top-nav { margin-left: 100px; } @@ -897,21 +893,21 @@ color: #666; } -.countdown { +.preview { color: #666; margin-top: 30px; text-align: center; } -.countdown .icon { +.preview .icon { margin-bottom: 10px; } -.countdown .icon .layui-icon { +.preview .icon .layui-icon { font-size: 150px; } -.countdown .tips { +.preview .tips { font-size: 16px; margin: 20px 0; }