diff --git a/app/Http/Home/Controllers/ChapterController.php b/app/Http/Home/Controllers/ChapterController.php index 4e46138e..dace273d 100644 --- a/app/Http/Home/Controllers/ChapterController.php +++ b/app/Http/Home/Controllers/ChapterController.php @@ -8,6 +8,7 @@ use App\Services\Logic\Chapter\ChapterInfo as ChapterInfoService; use App\Services\Logic\Chapter\ChapterLike as ChapterLikeService; use App\Services\Logic\Chapter\DanmuList as ChapterDanmuListService; use App\Services\Logic\Chapter\Learning as ChapterLearningService; +use App\Services\Logic\Chapter\ResourceList as ChapterResourceListService; use App\Services\Logic\Course\ChapterList as CourseChapterListService; /** @@ -16,6 +17,18 @@ use App\Services\Logic\Course\ChapterList as CourseChapterListService; class ChapterController extends Controller { + /** + * @Get("/{id:[0-9]+}/resources", name="home.chapter.resources") + */ + public function resourcesAction($id) + { + $service = new ChapterResourceListService(); + + $items = $service->handle($id); + + $this->view->setVar('items', $items); + } + /** * @Get("/{id:[0-9]+}", name="home.chapter.show") */ diff --git a/app/Http/Home/Views/chapter/live/active.volt b/app/Http/Home/Views/chapter/live/active.volt index 02858300..5e6b0f86 100644 --- a/app/Http/Home/Views/chapter/live/active.volt +++ b/app/Http/Home/Views/chapter/live/active.volt @@ -4,6 +4,7 @@ {% set full_chapter_url = full_url({'for':'home.chapter.show','id':chapter.id}) %} {% set course_url = url({'for':'home.course.show','id':chapter.course.id}) %} + {% set resources_url = url({'for':'home.chapter.resources','id':chapter.id}) %} {% set learning_url = url({'for':'home.chapter.learning','id':chapter.id}) %} {% set live_chats_url = url({'for':'home.live.chats','id':chapter.id}) %} {% set live_stats_url = url({'for':'home.live.stats','id':chapter.id}) %} @@ -19,8 +20,11 @@ {{ chapter.title }} - + 0 + {% if chapter.resource_count > 0 and chapter.me.owned == 1 %} + + {% endif %} diff --git a/app/Http/Home/Views/chapter/read.volt b/app/Http/Home/Views/chapter/read.volt index 1cd98eb0..53146eeb 100644 --- a/app/Http/Home/Views/chapter/read.volt +++ b/app/Http/Home/Views/chapter/read.volt @@ -4,6 +4,7 @@ {% set full_chapter_url = full_url({'for':'home.chapter.show','id':chapter.id}) %} {% set course_url = url({'for':'home.course.show','id':chapter.course.id}) %} + {% set resources_url = url({'for':'home.chapter.resources','id':chapter.id}) %} {% set learning_url = url({'for':'home.chapter.learning','id':chapter.id}) %} {% set like_url = url({'for':'home.chapter.like','id':chapter.id}) %} {% set consult_url = url({'for':'home.consult.add'},{'chapter_id':chapter.id}) %} @@ -16,9 +17,12 @@ {{ chapter.title }} - + {{ chapter.user_count }} + {% if chapter.resource_count > 0 and chapter.me.owned == 1 %} + + {% endif %} diff --git a/app/Http/Home/Views/chapter/resources.volt b/app/Http/Home/Views/chapter/resources.volt new file mode 100644 index 00000000..9551ee9e --- /dev/null +++ b/app/Http/Home/Views/chapter/resources.volt @@ -0,0 +1,32 @@ +{% extends 'templates/layer.volt' %} + +{% block content %} + + + + + + + + + {% for item in items %} + {% set download_url = url({'for':'home.download','md5':item.md5}) %} + + + + + + + {% endfor %} +
名称类型大小操作
{{ item.name }}{{ item.mime }}{{ item.size|human_size }}下载
+ +{% endblock %} + +{% block inline_js %} + + + +{% endblock %} \ No newline at end of file diff --git a/app/Http/Home/Views/chapter/vod.volt b/app/Http/Home/Views/chapter/vod.volt index 6a054bee..6075ab10 100644 --- a/app/Http/Home/Views/chapter/vod.volt +++ b/app/Http/Home/Views/chapter/vod.volt @@ -4,6 +4,7 @@ {% set full_chapter_url = full_url({'for':'home.chapter.show','id':chapter.id}) %} {% set course_url = url({'for':'home.course.show','id':chapter.course.id}) %} + {% set resources_url = url({'for':'home.chapter.resources','id':chapter.id}) %} {% set learning_url = url({'for':'home.chapter.learning','id':chapter.id}) %} {% set like_url = url({'for':'home.chapter.like','id':chapter.id}) %} {% set qrcode_url = url({'for':'home.qrcode'},{'text':full_chapter_url}) %} @@ -17,9 +18,12 @@ {{ chapter.title }}
- {{ chapter.user_count }} + {{ chapter.user_count }} + {% if chapter.resource_count > 0 and chapter.me.owned == 1 %} + + {% endif %} diff --git a/app/Http/Home/Views/consult/edit.volt b/app/Http/Home/Views/consult/edit.volt index 3717f6be..345c8989 100644 --- a/app/Http/Home/Views/consult/edit.volt +++ b/app/Http/Home/Views/consult/edit.volt @@ -30,6 +30,7 @@
+
diff --git a/app/Http/Home/Views/consult/reply.volt b/app/Http/Home/Views/consult/reply.volt index 97bbdd10..a837c4ca 100644 --- a/app/Http/Home/Views/consult/reply.volt +++ b/app/Http/Home/Views/consult/reply.volt @@ -27,6 +27,7 @@
+
diff --git a/app/Http/Home/Views/consult/show.volt b/app/Http/Home/Views/consult/show.volt index d2d1fe11..76a730b9 100644 --- a/app/Http/Home/Views/consult/show.volt +++ b/app/Http/Home/Views/consult/show.volt @@ -4,7 +4,7 @@ {% set consult.answer = consult.answer ? consult.answer : '请耐心等待回复吧' %} -
+
{% if consult.course.id is defined %}
课程:
diff --git a/app/Http/Home/Views/templates/layer.volt b/app/Http/Home/Views/templates/layer.volt index 45b9c517..76533493 100644 --- a/app/Http/Home/Views/templates/layer.volt +++ b/app/Http/Home/Views/templates/layer.volt @@ -5,7 +5,7 @@ - 即时通讯 + 酷瓜云课堂 {{ icon_link('favicon.ico') }} {{ css_link('lib/layui/css/layui.css') }} {{ css_link('home/css/common.css') }} diff --git a/app/Services/Logic/Chapter/BasicInfo.php b/app/Services/Logic/Chapter/BasicInfo.php index f86ddc86..50e7b66a 100644 --- a/app/Services/Logic/Chapter/BasicInfo.php +++ b/app/Services/Logic/Chapter/BasicInfo.php @@ -71,6 +71,7 @@ class BasicInfo extends Service 'summary' => $chapter->summary, 'model' => $chapter->model, 'play_urls' => $playUrls, + 'resource_count' => $chapter->resource_count, 'user_count' => $chapter->user_count, 'like_count' => $chapter->like_count, ]; @@ -97,6 +98,7 @@ class BasicInfo extends Service 'start_time' => $live->start_time, 'end_time' => $live->end_time, 'status' => $live->status, + 'resource_count' => $chapter->resource_count, 'user_count' => $chapter->user_count, 'like_count' => $chapter->like_count, ]; @@ -114,6 +116,7 @@ class BasicInfo extends Service 'summary' => $chapter->summary, 'model' => $chapter->model, 'content' => $read->content, + 'resource_count' => $chapter->resource_count, 'user_count' => $chapter->user_count, 'like_count' => $chapter->like_count, ]; diff --git a/app/Services/Logic/Chapter/ResourceList.php b/app/Services/Logic/Chapter/ResourceList.php new file mode 100644 index 00000000..6ace34eb --- /dev/null +++ b/app/Services/Logic/Chapter/ResourceList.php @@ -0,0 +1,34 @@ +checkChapter($id); + + $resourceRepo = new ResourceRepo(); + + $resources = $resourceRepo->findByChapterId($chapter->id); + + if ($resources->count() == 0) { + return []; + } + + $builder = new ResourceListBuilder(); + + $relations = $resources->toArray(); + + return $builder->getUploads($relations); + } + +} diff --git a/bootstrap/HttpErrorHandler.php b/bootstrap/HttpErrorHandler.php index d88b1bc0..d49d22a5 100644 --- a/bootstrap/HttpErrorHandler.php +++ b/bootstrap/HttpErrorHandler.php @@ -71,13 +71,7 @@ class HttpErrorHandler extends Component */ protected function report($e) { - $config = $this->getConfig(); - - if ($config->get('env') == ENV_DEV) { - $content = $e->getTraceAsString(); - } else { - $content = sprintf('%s(%d): %s', $e->getFile(), $e->getLine(), $e->getMessage()); - } + $content = sprintf('%s(%d): %s', $e->getFile(), $e->getLine(), $e->getMessage()); $logger = $this->getLogger(); diff --git a/public/static/home/css/common.css b/public/static/home/css/common.css index 9cd749e6..a78ec345 100644 --- a/public/static/home/css/common.css +++ b/public/static/home/css/common.css @@ -1500,14 +1500,15 @@ } .consult-info .item { - clear: both; margin-bottom: 15px; + line-height: 1.5em; + height: 1.5em; + clear: both; } .consult-info .item .label { float: left; width: 50px; - height: 32px; text-align: right; } diff --git a/public/static/home/js/chapter.action.js b/public/static/home/js/chapter.action.js index 6058ad3e..f5a2ee60 100644 --- a/public/static/home/js/chapter.action.js +++ b/public/static/home/js/chapter.action.js @@ -47,4 +47,19 @@ layui.use(['jquery', 'helper'], function () { }); }); + /** + * 资料 + */ + $('.icon-resource').on('click', function () { + var url = $(this).parent().data('url'); + helper.checkLogin(function () { + layer.open({ + type: 2, + title: '资料下载', + content: [url, 'no'], + area: ['640px', '300px'] + }); + }); + }); + }); \ No newline at end of file