From e5869e1e8f9b8b3bd6d30104d60897ced0b46729 Mon Sep 17 00:00:00 2001 From: xiaochong0302 Date: Thu, 10 Apr 2025 22:35:16 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BC=98=E5=8C=96=E8=AF=BE=E7=A8=8B=E7=9B=AE?= =?UTF-8?q?=E5=BD=95UI=202.=E4=BC=98=E5=8C=96=E6=94=B6=E8=97=8FUI=203.?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E6=94=B6=E8=B4=B9=E8=AF=BE=E7=A8=8B=E8=AF=95?= =?UTF-8?q?=E5=90=AC=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Home/Views/chapter/catalog.volt | 34 +++-- app/Http/Home/Views/chapter/live/active.volt | 8 +- app/Http/Home/Views/course/show_catalog.volt | 109 ++++++++-------- app/Http/Home/Views/course/sticky.volt | 4 +- app/Services/Logic/Course/ChapterList.php | 23 +++- app/Services/Logic/Course/CourseInfo.php | 2 +- public/static/home/css/common.css | 123 +++++++++++-------- public/static/home/js/course.show.js | 4 +- 8 files changed, 179 insertions(+), 128 deletions(-) diff --git a/app/Http/Home/Views/chapter/catalog.volt b/app/Http/Home/Views/chapter/catalog.volt index 1f31f6c5..edf3dd3c 100644 --- a/app/Http/Home/Views/chapter/catalog.volt +++ b/app/Http/Home/Views/chapter/catalog.volt @@ -1,35 +1,45 @@ +{%- macro model_icon(model) %} + {% if model == 1 %} + + {% elseif model == 2 %} + + {% elseif model == 3 %} + + {% elseif model == 4 %} + + {% endif %} +{%- endmacro %} + + {%- macro show_lesson_list(parent,chapter) %} {%- endmacro %} - diff --git a/app/Http/Home/Views/chapter/live/active.volt b/app/Http/Home/Views/chapter/live/active.volt index 393d7e69..360f14b5 100644 --- a/app/Http/Home/Views/chapter/live/active.volt +++ b/app/Http/Home/Views/chapter/live/active.volt @@ -35,11 +35,7 @@
- {% if auth_user.id > 0 %} - - {% else %} - - {% endif %} +
@@ -80,4 +76,4 @@ {{ js_include('home/js/course.share.js') }} {{ js_include('home/js/copy.js') }} -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/app/Http/Home/Views/course/show_catalog.volt b/app/Http/Home/Views/course/show_catalog.volt index 815ee561..70d02305 100644 --- a/app/Http/Home/Views/course/show_catalog.volt +++ b/app/Http/Home/Views/course/show_catalog.volt @@ -1,103 +1,116 @@ {%- macro show_lesson_list(chapter) %} {%- endmacro %} {%- macro vod_lesson_info(lesson) %} - {% set url = lesson.me.owned ? url({'for':'home.chapter.show','id':lesson.id}) : '' %} - {% set priv = lesson.me.owned ? 'allow' : 'deny' %} - - +
+ {{ lesson.title }} - {% if lesson.free == 1 %} - - {% endif %} {% if lesson.me.duration > 0 %} {% endif %} - {% if priv == 'deny' %} - + {% if lesson.me.owned == 0 %} + {% endif %} + {% if lesson.free == 1 %} + 试听 + {% endif %} +
+
{{ lesson.attrs.duration|duration }} - +
{%- endmacro %} {%- macro live_lesson_info(lesson) %} - {% set url = lesson.me.owned ? url({'for':'home.chapter.show','id':lesson.id}) : '' %} - {% set priv = lesson.me.owned ? 'allow' : 'deny' %} - - +
+ {{ lesson.title }} - {% if lesson.free == 1 %} - - {% endif %} {% if lesson.me.duration > 0 %} {% endif %} - {% if priv == 'deny' %} - + {% if lesson.me.owned == 0 %} + {% endif %} - {{ live_status_info(lesson) }} - + {% if lesson.attrs.playback.ready == 1 %} + 回放 + {% endif %} + {% if lesson.free == 1 %} + 试听 + {% endif %} +
+
+ {{ live_status_info(lesson) }} + {{ date('Y-m-d H:i',lesson.attrs.start_time) }} +
{%- endmacro %} {%- macro read_lesson_info(lesson) %} - {% set url = lesson.me.owned ? url({'for':'home.chapter.show','id':lesson.id}) : '' %} - {% set priv = lesson.me.owned ? 'allow' : 'deny' %} - - +
+ {{ lesson.title }} - {% if lesson.free == 1 %} - - {% endif %} {% if lesson.me.duration > 0 %} {% endif %} - {% if priv == 'deny' %} - + {% if lesson.me.owned == 0 %} + {% endif %} - + {% if lesson.free == 1 %} + 试读 + {% endif %} +
+
+ +
{%- endmacro %} {%- macro offline_lesson_info(lesson) %} - - +
+ {{ lesson.title }} - {% if lesson.free == 1 %} - 试听 + {% if lesson.me.owned == 0 %} + {% endif %} - {{ offline_status_info(lesson) }} - + {% if lesson.free == 1 %} + 试听 + {% endif %} +
+
+ {{ offline_status_info(lesson) }} + {{ date('Y-m-d H:i',lesson.attrs.start_time) }} +
{%- endmacro %} {%- macro live_status_info(lesson) %} {% if lesson.attrs.stream.status == 'active' %} - {{ date('m月d日 H:i',lesson.attrs.start_time) }} 直播中 + 直播中 {% elseif lesson.attrs.start_time > time() %} - {{ date('m月d日 H:i',lesson.attrs.start_time) }} 倒计时 + 倒计时 {% elseif lesson.attrs.end_time < time() %} - {{ date('m月d日 H:i',lesson.attrs.start_time) }} 已结束 + 已结束 {% endif %} {%- endmacro %} {%- macro offline_status_info(lesson) %} {% if lesson.attrs.start_time < time() and lesson.attrs.end_time > time() %} - {{ date('m月d日 H:i',lesson.attrs.start_time) }} 授课中 + 授课中 {% elseif lesson.attrs.start_time > time() %} - {{ date('m月d日 H:i',lesson.attrs.start_time) }} 未开始 + 未开始 {% elseif lesson.attrs.end_time < time() %} - {{ date('m月d日 H:i',lesson.attrs.start_time) }} 已结束 + 已结束 {% endif %} {%- endmacro %} @@ -119,4 +132,4 @@ {% else %} {{ show_lesson_list(chapters[0]) }} {% endif %} -{% endif %} \ No newline at end of file +{% endif %} diff --git a/app/Http/Home/Views/course/sticky.volt b/app/Http/Home/Views/course/sticky.volt index 8cc9e637..773f1e99 100644 --- a/app/Http/Home/Views/course/sticky.volt +++ b/app/Http/Home/Views/course/sticky.volt @@ -26,8 +26,8 @@ {% endif %}
- +
{{ course.favorite_count }}
- \ No newline at end of file + diff --git a/app/Services/Logic/Course/ChapterList.php b/app/Services/Logic/Course/ChapterList.php index 3d23dae9..feee57ac 100644 --- a/app/Services/Logic/Course/ChapterList.php +++ b/app/Services/Logic/Course/ChapterList.php @@ -39,10 +39,10 @@ class ChapterList extends LogicService if (count($chapters) == 0) return []; - if ($user->id > 0 && $this->courseUser) { + if ($user->id > 0) { $chapters = $this->handleLoginUserChapters($chapters, $course, $user); } else { - $chapters = $this->handleGuestUserChapters($chapters); + $chapters = $this->handleGuestUserChapters($chapters, $course); } return $chapters; @@ -50,7 +50,11 @@ class ChapterList extends LogicService protected function handleLoginUserChapters(array $chapters, CourseModel $course, UserModel $user) { - $mappings = $this->getLearningMappings($course->id, $user->id, $this->courseUser->plan_id); + $mappings = []; + + if ($this->courseUser) { + $mappings = $this->getLearningMappings($course->id, $user->id, $this->courseUser->plan_id); + } foreach ($chapters as &$chapter) { foreach ($chapter['children'] as &$lesson) { @@ -61,23 +65,30 @@ class ChapterList extends LogicService 'owned' => $owned ? 1 : 0, 'logged' => 1, ]; + // 如果课程是免费的,但又设置了课时试听,清除试听标识 + if ($course->market_price == 0 && $lesson['free'] == 1) { + $lesson['free'] = 0; + } } } return $chapters; } - protected function handleGuestUserChapters(array $chapters) + protected function handleGuestUserChapters(array $chapters, CourseModel $course) { foreach ($chapters as &$chapter) { foreach ($chapter['children'] as &$lesson) { - $owned = ($this->ownedCourse || $lesson['free'] == 1) && $lesson['published'] == 1; $lesson['me'] = [ 'progress' => 0, 'duration' => 0, 'logged' => 0, - 'owned' => $owned ? 1 : 0, + 'owned' => 0, ]; + // 如果课程是免费的,但又设置了课时试听,清除试听标识 + if ($course->market_price == 0 && $lesson['free'] == 1) { + $lesson['free'] = 0; + } } } diff --git a/app/Services/Logic/Course/CourseInfo.php b/app/Services/Logic/Course/CourseInfo.php index 518755fd..5714b7aa 100644 --- a/app/Services/Logic/Course/CourseInfo.php +++ b/app/Services/Logic/Course/CourseInfo.php @@ -100,7 +100,7 @@ class CourseInfo extends LogicService if ($this->courseUser) { $me['reviewed'] = $this->courseUser->reviewed ? 1 : 0; - $me['progress'] = $this->courseUser->progress ? 1 : 0; + $me['progress'] = $this->courseUser->progress; $me['plan_id'] = $this->courseUser->plan_id; } } diff --git a/public/static/home/css/common.css b/public/static/home/css/common.css index 09b01224..224d38fa 100644 --- a/public/static/home/css/common.css +++ b/public/static/home/css/common.css @@ -1039,50 +1039,73 @@ font-size: 30px; } -.lesson-item { - position: relative; - padding: 0 10px; - line-height: 35px; +.lesson-list .allow { + cursor: pointer; } -.lesson-item a { - display: block; -} - -.lesson-item .deny { +.lesson-list .deny { cursor: default; - color: gray; } -.lesson-item .title { - margin: 0 5px; -} - -.lesson-item .icon-trial { - color: red; - font-size: 24px; - margin-right: 5px; -} - -.lesson-item .duration, .lesson-item .live { - top: 0; - right: 10px; - position: absolute; - color: #666; -} - -.lesson-item .live .active { - color: red; -} - -.lesson-item .study-time { - color: green; +.lesson-item { + display: flex; + justify-content: space-between; + line-height: 35px; + padding: 0 10px; } .lesson-item:hover { background-color: #f2f2f2; } +.lesson-item .title { + margin-right: 5px; +} + +.lesson-item .model { + margin-right: 5px; +} + +.lesson-item .lock { + margin-right: 5px; +} + +.lesson-item .study-time { + margin-right: 5px; + color: green; +} + +.lesson-item .flag { + padding: 2px 3px; + margin-right: 5px; + font-size: 12px; +} + +.lesson-item .flag-free { + border: 1px solid red; + color: red; +} + +.lesson-item .flag-playback { + border: 1px solid orange; + color: orange; +} + +.lesson-item .flag-pending { + border: 1px solid green; + color: green; +} + +.lesson-item .flag-active { + border: 1px solid red; + color: red; +} + +.lesson-item .flag-finished { + border: 1px solid gray; + color: gray; +} + .package-item { display: flex; margin-bottom: 20px; @@ -1173,15 +1196,13 @@ white-space: normal; } -.review-card, -.consult-card, -.answer-card { +.review-card .info, +.consult-card .info { position: relative; } .review-card .rating, -.consult-card .more, -.answer-card .accepted { +.consult-card .more { position: absolute; top: 0; right: 0; @@ -1205,11 +1226,6 @@ font-size: 12px; } -.review-card .more { - color: #666; - cursor: pointer; -} - .sidebar-card .layui-card-header { text-align: center; } @@ -1305,25 +1321,30 @@ overflow-y: auto; } -.sidebar-chapter-list .chapter-title { + .sidebar-chapter { padding-top: 10px; margin-bottom: 10px; color: #333; } -.sidebar-lesson-list { - margin-left: 10px; -} - -.sidebar-lesson-list .lesson-title { +.sidebar-lesson { + padding: 0 10px; line-height: 30px; } -.lesson-title .active { +.sidebar-lesson:hover { + background-color: #f2f2f2; +} + +.sidebar-lesson a { + display: block; +} + +.sidebar-lesson .active { color: red; } -.lesson-title .deny { +.sidebar-lesson .deny { color: gray; } diff --git a/public/static/home/js/course.show.js b/public/static/home/js/course.show.js index 67a0097e..749d4a18 100644 --- a/public/static/home/js/course.show.js +++ b/public/static/home/js/course.show.js @@ -62,7 +62,7 @@ layui.use(['jquery', 'layer', 'helper'], function () { /** * 浏览章节 */ - $('body').on('click', '.view-lesson', function () { + $('body').on('click', '.lesson-item', function () { if ($(this).hasClass('deny')) { return false; } @@ -140,4 +140,4 @@ layui.use(['jquery', 'layer', 'helper'], function () { helper.ajaxLoadHtml($sdRelated.data('url'), $sdRelated.attr('id')); } -}); \ No newline at end of file +});