diff --git a/app/Caches/IndexSlideList.php b/app/Caches/IndexSlideList.php
index 1c5b41b2..b98e5b34 100644
--- a/app/Caches/IndexSlideList.php
+++ b/app/Caches/IndexSlideList.php
@@ -47,7 +47,7 @@ class IndexSlideList extends Cache
'id' => $slide->id,
'title' => $slide->title,
'cover' => $slide->cover,
- 'bg_color' => $slide->bg_color,
+ 'style' => $slide->style,
'target' => $slide->target,
'content' => $slide->content,
];
diff --git a/app/Http/Admin/Services/Slide.php b/app/Http/Admin/Services/Slide.php
index 37c4d252..2ddc0a01 100644
--- a/app/Http/Admin/Services/Slide.php
+++ b/app/Http/Admin/Services/Slide.php
@@ -87,8 +87,8 @@ class Slide extends Service
$data['cover'] = $validator->checkCover($post['cover']);
}
- if (isset($post['bg_color'])) {
- $data['bg_color'] = $validator->checkBgColor($post['bg_color']);
+ if (isset($post['style']['bg_color'])) {
+ $data['style']['bg_color'] = $validator->checkBgColor($post['style']['bg_color']);
}
if (isset($post['content'])) {
diff --git a/app/Http/Admin/Views/slide/edit.volt b/app/Http/Admin/Views/slide/edit.volt
index 8d3f913e..2b865374 100644
--- a/app/Http/Admin/Views/slide/edit.volt
+++ b/app/Http/Admin/Views/slide/edit.volt
@@ -32,10 +32,10 @@
diff --git a/app/Http/Web/Views/course/show.volt b/app/Http/Web/Views/course/show.volt
new file mode 100644
index 00000000..c6dce620
--- /dev/null
+++ b/app/Http/Web/Views/course/show.volt
@@ -0,0 +1,58 @@
+{% extends 'templates/base.volt' %}
+
+{% block content %}
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ partial('course/chapters', {'chapters':chapters}) }}
+
+
内容3
+
+
+
+
+ {% if teachers %}
+ {{ partial('course/widget_teacher', {'teachers':teachers}) }}
+ {% endif %}
+
+ {% if topics %}
+ {{ partial('course/widget_topic', {'topics':topics}) }}
+ {% endif %}
+
+ {% if recommended_courses %}
+ {{ partial('course/widget_recommended', {'courses':recommended_courses}) }}
+ {% endif %}
+
+ {% if related_courses %}
+ {{ partial('course/widget_related', {'courses':related_courses}) }}
+ {% endif %}
+
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/app/Http/Web/Views/course/widget_recommended.volt b/app/Http/Web/Views/course/widget_recommended.volt
new file mode 100644
index 00000000..0d047020
--- /dev/null
+++ b/app/Http/Web/Views/course/widget_recommended.volt
@@ -0,0 +1,18 @@
+
\ No newline at end of file
diff --git a/app/Http/Web/Views/course/widget_related.volt b/app/Http/Web/Views/course/widget_related.volt
new file mode 100644
index 00000000..72253d0f
--- /dev/null
+++ b/app/Http/Web/Views/course/widget_related.volt
@@ -0,0 +1,18 @@
+
\ No newline at end of file
diff --git a/app/Http/Web/Views/course/widget_teacher.volt b/app/Http/Web/Views/course/widget_teacher.volt
new file mode 100644
index 00000000..ff80970f
--- /dev/null
+++ b/app/Http/Web/Views/course/widget_teacher.volt
@@ -0,0 +1,14 @@
+
\ No newline at end of file
diff --git a/app/Http/Web/Views/course/widget_topic.volt b/app/Http/Web/Views/course/widget_topic.volt
new file mode 100644
index 00000000..d0f5409c
--- /dev/null
+++ b/app/Http/Web/Views/course/widget_topic.volt
@@ -0,0 +1,8 @@
+
\ No newline at end of file
diff --git a/app/Http/Web/Views/index/index.volt b/app/Http/Web/Views/index/index.volt
index 7bb3a77d..6ec05166 100644
--- a/app/Http/Web/Views/index/index.volt
+++ b/app/Http/Web/Views/index/index.volt
@@ -31,7 +31,7 @@
{% for slide in slides %}
-
+
diff --git a/app/Models/Course.php b/app/Models/Course.php
index e3d8f9c5..b3ccd69f 100644
--- a/app/Models/Course.php
+++ b/app/Models/Course.php
@@ -346,8 +346,9 @@ class Course extends Model
{
return [
'score' => '综合',
- 'rating' => '好评',
- 'pop' => '人气',
+ 'rating' => '评价',
+ 'latest' => '最新',
+ 'popular' => '最热',
];
}
diff --git a/app/Models/Slide.php b/app/Models/Slide.php
index 6353cd79..05d439d3 100644
--- a/app/Models/Slide.php
+++ b/app/Models/Slide.php
@@ -37,11 +37,11 @@ class Slide extends Model
public $cover;
/**
- * 背景色
+ * 样式
*
* @var string
*/
- public $bg_color;
+ public $style;
/**
* 摘要
@@ -123,6 +123,10 @@ class Slide extends Model
if (Text::startsWith($this->cover, 'http')) {
$this->cover = self::getCoverPath($this->cover);
}
+
+ if (is_array($this->style) && !empty($this->style)) {
+ $this->style = kg_json_encode($this->style);
+ }
}
public function beforeUpdate()
@@ -132,6 +136,10 @@ class Slide extends Model
if (Text::startsWith($this->cover, 'http')) {
$this->cover = self::getCoverPath($this->cover);
}
+
+ if (!empty($this->style)) {
+ $this->style = kg_json_encode($this->style);
+ }
}
public function afterFetch()
@@ -139,6 +147,21 @@ class Slide extends Model
if (!Text::startsWith($this->cover, 'http')) {
$this->cover = kg_ci_cover_img_url($this->cover);
}
+
+ if (!empty($this->style)) {
+ $this->style = json_decode($this->style, true);
+ }
+ }
+
+ public static function htmlStyle($style)
+ {
+ $result = [];
+
+ if (isset($style['bg_color'])) {
+ $result[] = "background-color:{$style['bg_color']}";
+ }
+
+ return implode(';', $result);
}
public static function getCoverPath($url)
diff --git a/app/Repos/Course.php b/app/Repos/Course.php
index c5c05c33..fa207495 100644
--- a/app/Repos/Course.php
+++ b/app/Repos/Course.php
@@ -89,7 +89,7 @@ class Course extends Repository
case 'rating':
$orderBy = 'c.rating DESC';
break;
- case 'pop':
+ case 'popular':
$orderBy = 'c.user_count DESC';
break;
default:
diff --git a/app/Services/Frontend/Course/CourseInfo.php b/app/Services/Frontend/Course/CourseInfo.php
index 96d9531d..7009e073 100644
--- a/app/Services/Frontend/Course/CourseInfo.php
+++ b/app/Services/Frontend/Course/CourseInfo.php
@@ -5,7 +5,6 @@ namespace App\Services\Frontend\Course;
use App\Models\Course as CourseModel;
use App\Models\User as UserModel;
use App\Repos\CourseFavorite as CourseFavoriteRepo;
-use App\Services\Category as CategoryService;
use App\Services\Frontend\CourseTrait;
use App\Services\Frontend\Service as FrontendService;
@@ -34,6 +33,8 @@ class CourseInfo extends FrontendService
'summary' => $course->summary,
'details' => $course->details,
'keywords' => $course->keywords,
+ 'category_id' => $course->category_id,
+ 'teacher_id' => $course->teacher_id,
'market_price' => (float)$course->market_price,
'vip_price' => (float)$course->vip_price,
'study_expiry' => $course->study_expiry,
@@ -77,17 +78,9 @@ class CourseInfo extends FrontendService
$me['owned'] = $this->ownedCourse ? 1 : 0;
}
- $result['paths'] = $this->getPaths($course);
$result['me'] = $me;
return $result;
}
- protected function getPaths(CourseModel $course)
- {
- $service = new CategoryService();
-
- return $service->getCategoryPaths($course->category_id);
- }
-
}