mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-06-24 04:01:31 +08:00
1.优化语法层面
2.增加推荐课程|文章|考试widget
This commit is contained in:
parent
cced354b2a
commit
5985576065
@ -12,7 +12,7 @@ use App\Repos\Article as ArticleRepo;
|
||||
class Article extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
protected $lifetime = 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
|
@ -12,7 +12,7 @@ use App\Repos\Chapter as ChapterRepo;
|
||||
class Chapter extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
protected $lifetime = 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
|
@ -12,7 +12,7 @@ use App\Repos\Course as CourseRepo;
|
||||
class Course extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
protected $lifetime = 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
|
@ -13,7 +13,7 @@ use App\Repos\Course as CourseRepo;
|
||||
class CourseCategoryList extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
protected $lifetime = 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
|
@ -13,7 +13,7 @@ use App\Repos\Course as CourseRepo;
|
||||
class CoursePackageList extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
protected $lifetime = 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
|
@ -14,7 +14,7 @@ use Phalcon\Mvc\Model\ResultsetInterface;
|
||||
class CourseRecommendedList extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
protected $lifetime = 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
|
@ -13,7 +13,7 @@ use App\Repos\Course as CourseRepo;
|
||||
class CourseRelatedList extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
protected $lifetime = 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
|
@ -13,7 +13,7 @@ use App\Repos\Course as CourseRepo;
|
||||
class CourseTeacherList extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
protected $lifetime = 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
|
@ -14,7 +14,7 @@ use Phalcon\Mvc\Model\ResultsetInterface;
|
||||
class CourseTopicList extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
protected $lifetime = 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
|
83
app/Caches/FeaturedArticleList.php
Normal file
83
app/Caches/FeaturedArticleList.php
Normal file
@ -0,0 +1,83 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2023 深圳市酷瓜软件有限公司
|
||||
* @license https://opensource.org/licenses/GPL-2.0
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
|
||||
namespace App\Caches;
|
||||
|
||||
use App\Models\Article as ArticleModel;
|
||||
use Phalcon\Mvc\Model\Resultset;
|
||||
use Phalcon\Mvc\Model\ResultsetInterface;
|
||||
|
||||
class FeaturedArticleList extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
$tomorrow = strtotime('tomorrow');
|
||||
|
||||
return $tomorrow - time();
|
||||
}
|
||||
|
||||
public function getKey($id = null)
|
||||
{
|
||||
return 'featured_article_list';
|
||||
}
|
||||
|
||||
public function getContent($id = null)
|
||||
{
|
||||
$limit = 8;
|
||||
|
||||
$articles = $this->findArticles($limit);
|
||||
|
||||
if ($articles->count() == 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($articles as $article) {
|
||||
|
||||
$userCount = $article->user_count;
|
||||
|
||||
if ($article->fake_user_count > $article->user_count) {
|
||||
$userCount = $article->fake_user_count;
|
||||
}
|
||||
|
||||
$result[] = [
|
||||
'id' => $article->id,
|
||||
'title' => $article->title,
|
||||
'cover' => $article->cover,
|
||||
'market_price' => (float)$article->market_price,
|
||||
'vip_price' => (float)$article->vip_price,
|
||||
'user_count' => $userCount,
|
||||
'favorite_count' => $article->favorite_count,
|
||||
'comment_count' => $article->comment_count,
|
||||
'view_count' => $article->view_count,
|
||||
'like_count' => $article->like_count,
|
||||
];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $limit
|
||||
* @return ResultsetInterface|Resultset|ArticleModel[]
|
||||
*/
|
||||
protected function findArticles($limit = 8)
|
||||
{
|
||||
return ArticleModel::query()
|
||||
->where('featured = 1')
|
||||
->andWhere('published = 1')
|
||||
->andWhere('deleted = 0')
|
||||
->orderBy('id DESC')
|
||||
->limit($limit)
|
||||
->execute();
|
||||
}
|
||||
|
||||
}
|
85
app/Caches/FeaturedCourseList.php
Normal file
85
app/Caches/FeaturedCourseList.php
Normal file
@ -0,0 +1,85 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2023 深圳市酷瓜软件有限公司
|
||||
* @license https://opensource.org/licenses/GPL-2.0
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
|
||||
namespace App\Caches;
|
||||
|
||||
use App\Models\Course as CourseModel;
|
||||
use Phalcon\Mvc\Model\Resultset;
|
||||
use Phalcon\Mvc\Model\ResultsetInterface;
|
||||
|
||||
class FeaturedCourseList extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
$tomorrow = strtotime('tomorrow');
|
||||
|
||||
return $tomorrow - time();
|
||||
}
|
||||
|
||||
public function getKey($id = null)
|
||||
{
|
||||
return 'featured_course_list';
|
||||
}
|
||||
|
||||
public function getContent($id = null)
|
||||
{
|
||||
$limit = 8;
|
||||
|
||||
$courses = $this->findCourses($limit);
|
||||
|
||||
if ($courses->count() == 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($courses as $course) {
|
||||
|
||||
$userCount = $course->user_count;
|
||||
|
||||
if ($course->fake_user_count > $course->user_count) {
|
||||
$userCount = $course->fake_user_count;
|
||||
}
|
||||
|
||||
$result[] = [
|
||||
'id' => $course->id,
|
||||
'title' => $course->title,
|
||||
'cover' => $course->cover,
|
||||
'model' => $course->model,
|
||||
'level' => $course->level,
|
||||
'rating' => round($course->rating, 1),
|
||||
'market_price' => (float)$course->market_price,
|
||||
'vip_price' => (float)$course->vip_price,
|
||||
'user_count' => $userCount,
|
||||
'lesson_count' => $course->lesson_count,
|
||||
'review_count' => $course->review_count,
|
||||
'favorite_count' => $course->favorite_count,
|
||||
];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $limit
|
||||
* @return ResultsetInterface|Resultset|CourseModel[]
|
||||
*/
|
||||
protected function findCourses($limit = 8)
|
||||
{
|
||||
return CourseModel::query()
|
||||
->where('featured = 1')
|
||||
->andWhere('published = 1')
|
||||
->andWhere('deleted = 0')
|
||||
->orderBy('id DESC')
|
||||
->limit($limit)
|
||||
->execute();
|
||||
}
|
||||
|
||||
}
|
@ -12,7 +12,7 @@ use App\Repos\FlashSale as FlashSaleRepo;
|
||||
class FlashSale extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
protected $lifetime = 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
|
@ -14,7 +14,7 @@ use Phalcon\Mvc\Model\ResultsetInterface;
|
||||
class HotQuestionList extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
protected $lifetime = 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
|
@ -19,7 +19,7 @@ use Phalcon\Mvc\Model\ResultsetInterface;
|
||||
class IndexFeaturedCourseList extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
protected $lifetime = 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
|
@ -12,7 +12,7 @@ use App\Services\Logic\FlashSale\SaleList;
|
||||
class IndexFlashSaleList extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
protected $lifetime = 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
|
@ -19,7 +19,7 @@ use Phalcon\Mvc\Model\ResultsetInterface;
|
||||
class IndexFreeCourseList extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
protected $lifetime = 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
|
@ -18,7 +18,7 @@ use Phalcon\Mvc\Model\ResultsetInterface;
|
||||
class IndexLiveList extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
protected $lifetime = 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
|
@ -19,7 +19,7 @@ use Phalcon\Mvc\Model\ResultsetInterface;
|
||||
class IndexNewCourseList extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
protected $lifetime = 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
|
@ -17,7 +17,7 @@ use Phalcon\Mvc\Model\ResultsetInterface;
|
||||
class IndexSimpleFeaturedCourseList extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
protected $lifetime = 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
|
@ -17,7 +17,7 @@ use Phalcon\Mvc\Model\ResultsetInterface;
|
||||
class IndexSimpleFreeCourseList extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
protected $lifetime = 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
|
@ -17,7 +17,7 @@ use Phalcon\Mvc\Model\ResultsetInterface;
|
||||
class IndexSimpleNewCourseList extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
protected $lifetime = 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
|
@ -17,7 +17,7 @@ use Phalcon\Mvc\Model\ResultsetInterface;
|
||||
class IndexSimpleVipCourseList extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
protected $lifetime = 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
|
@ -14,7 +14,7 @@ use Phalcon\Mvc\Model\ResultsetInterface;
|
||||
class IndexTeacherList extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 3600;
|
||||
protected $lifetime = 3600;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
|
@ -19,7 +19,7 @@ use Phalcon\Mvc\Model\ResultsetInterface;
|
||||
class IndexVipCourseList extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
protected $lifetime = 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
|
@ -13,7 +13,7 @@ use App\Repos\Package as PackageRepo;
|
||||
class PackageCourseList extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
protected $lifetime = 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
|
@ -12,7 +12,7 @@ use App\Repos\PointGift as PointGiftRepo;
|
||||
class PointGift extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
protected $lifetime = 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
|
@ -19,7 +19,7 @@ class PointHotGiftList extends Cache
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $lifetime = 1 * 86400;
|
||||
protected $lifetime = 86400;
|
||||
|
||||
/**
|
||||
* 显示个数
|
||||
|
@ -12,7 +12,7 @@ use App\Repos\Question as QuestionRepo;
|
||||
class Question extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
protected $lifetime = 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
|
@ -15,7 +15,7 @@ class TaggedArticleList extends Cache
|
||||
|
||||
protected $limit = 5;
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
protected $lifetime = 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
|
@ -15,7 +15,7 @@ class TaggedQuestionList extends Cache
|
||||
|
||||
protected $limit = 5;
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
protected $lifetime = 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
|
@ -16,7 +16,7 @@ use Phalcon\Mvc\Model\ResultsetInterface;
|
||||
class TopAnswererList extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
protected $lifetime = 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
|
@ -16,7 +16,7 @@ use Phalcon\Mvc\Model\ResultsetInterface;
|
||||
class TopAuthorList extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
protected $lifetime = 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
|
@ -12,7 +12,7 @@ use App\Repos\User as UserRepo;
|
||||
class User extends Cache
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
protected $lifetime = 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
|
@ -10,7 +10,7 @@ namespace App\Caches;
|
||||
class UserDailyCounter extends Counter
|
||||
{
|
||||
|
||||
protected $lifetime = 1 * 86400;
|
||||
protected $lifetime = 86400;
|
||||
|
||||
public function getLifetime()
|
||||
{
|
||||
|
@ -8,7 +8,6 @@
|
||||
namespace App\Http\Home\Controllers;
|
||||
|
||||
use App\Http\Home\Services\FullH5Url as FullH5UrlService;
|
||||
use App\Http\Home\Services\Index as IndexService;
|
||||
use App\Services\Logic\Help\HelpInfo as HelpInfoService;
|
||||
use App\Services\Logic\Help\HelpList as HelpListService;
|
||||
|
||||
@ -30,8 +29,6 @@ class HelpController extends Controller
|
||||
return $this->response->redirect($location);
|
||||
}
|
||||
|
||||
$featuredCourses = $this->getFeaturedCourses();
|
||||
|
||||
$service = new HelpListService();
|
||||
|
||||
$items = $service->handle();
|
||||
@ -39,7 +36,6 @@ class HelpController extends Controller
|
||||
$this->seo->prependTitle('帮助');
|
||||
|
||||
$this->view->setVar('items', $items);
|
||||
$this->view->setVar('featured_courses', $featuredCourses);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -66,19 +62,9 @@ class HelpController extends Controller
|
||||
$this->notFound();
|
||||
}
|
||||
|
||||
$featuredCourses = $this->getFeaturedCourses();
|
||||
|
||||
$this->seo->prependTitle(['帮助', $help['title']]);
|
||||
|
||||
$this->view->setVar('help', $help);
|
||||
$this->view->setVar('featured_courses', $featuredCourses);
|
||||
}
|
||||
|
||||
protected function getFeaturedCourses()
|
||||
{
|
||||
$service = new IndexService();
|
||||
|
||||
return $service->getSimpleFeaturedCourses();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,6 +7,8 @@
|
||||
|
||||
namespace App\Http\Home\Controllers;
|
||||
|
||||
use App\Caches\FeaturedArticleList as FeaturedArticleListCache;
|
||||
use App\Caches\FeaturedCourseList as FeaturedCourseListCache;
|
||||
use App\Services\Logic\Article\TopAuthorList as TopAuthorListService;
|
||||
use App\Services\Logic\Question\HotQuestionList as HotQuestionListService;
|
||||
use App\Services\Logic\Question\TopAnswererList as TopAnswererListService;
|
||||
@ -33,6 +35,34 @@ class WidgetController extends Controller
|
||||
$this->view->setVar('tags', $pager->items);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Get("/featured/courses", name="home.widget.featured_courses")
|
||||
*/
|
||||
public function featuredCoursesAction()
|
||||
{
|
||||
$cache = new FeaturedCourseListCache();
|
||||
|
||||
$courses = $cache->get();
|
||||
|
||||
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
|
||||
$this->view->pick('widget/featured_courses');
|
||||
$this->view->setVar('courses', $courses);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Get("/featured/articles", name="home.widget.featured_articles")
|
||||
*/
|
||||
public function featuredArticlesAction()
|
||||
{
|
||||
$cache = new FeaturedArticleListCache();
|
||||
|
||||
$articles = $cache->get();
|
||||
|
||||
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
|
||||
$this->view->pick('widget/featured_articles');
|
||||
$this->view->setVar('articles', $articles);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Get("/hot/questions", name="home.widget.hot_questions")
|
||||
*/
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
{% block content %}
|
||||
|
||||
{{ partial('macros/course') }}
|
||||
{% set courses_url = url({'for':'home.widget.featured_courses'}) %}
|
||||
|
||||
<div class="breadcrumb">
|
||||
<span class="layui-breadcrumb">
|
||||
@ -32,25 +32,23 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="layout-sidebar">
|
||||
{% if featured_courses %}
|
||||
<div class="sidebar">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header">推荐课程</div>
|
||||
<div class="layui-card-body">
|
||||
{% for course in featured_courses %}
|
||||
{{ sidebar_course_card(course) }}
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="sidebar" id="course-list" data-url="{{ courses_url }}"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block include_js %}
|
||||
{% block inline_js %}
|
||||
|
||||
{{ js_include('home/js/help.js') }}
|
||||
<script>
|
||||
layui.use(['jquery', 'helper'], function () {
|
||||
var $ = layui.jquery;
|
||||
var helper = layui.helper;
|
||||
var $courseList = $('#course-list');
|
||||
if ($courseList.length > 0) {
|
||||
helper.ajaxLoadHtml($courseList.data('url'), $courseList.attr('id'));
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
@ -2,10 +2,7 @@
|
||||
|
||||
{% block content %}
|
||||
|
||||
{{ partial('macros/course') }}
|
||||
|
||||
{% set share_url = share_url('help',help.id,auth_user.id) %}
|
||||
{% set qrcode_url = url({'for':'home.qrcode'},{'text':share_url}) %}
|
||||
{% set courses_url = url({'for':'home.widget.featured_courses'}) %}
|
||||
|
||||
<div class="breadcrumb">
|
||||
<span class="layui-breadcrumb">
|
||||
@ -13,11 +10,6 @@
|
||||
<a href="{{ url({'for':'home.help.index'}) }}">帮助中心</a>
|
||||
<a><cite>{{ help.title }}</cite></a>
|
||||
</span>
|
||||
<span class="share">
|
||||
<a class="share-wechat" href="javascript:" title="分享到微信"><i class="layui-icon layui-icon-login-wechat"></i></a>
|
||||
<a class="share-qq" href="javascript:" title="分享到QQ空间"><i class="layui-icon layui-icon-login-qq"></i></a>
|
||||
<a class="share-weibo" href="javascript:" title="分享到微博"><i class="layui-icon layui-icon-login-weibo"></i></a>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="layout-main">
|
||||
@ -27,31 +19,29 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="layout-sidebar">
|
||||
{% if featured_courses %}
|
||||
<div class="sidebar">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header">推荐课程</div>
|
||||
<div class="layui-card-body">
|
||||
{% for course in featured_courses %}
|
||||
{{ sidebar_course_card(course) }}
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="sidebar" id="course-list" data-url="{{ courses_url }}"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-hide">
|
||||
<input type="hidden" name="share.title" value="{{ help.title }}">
|
||||
<input type="hidden" name="share.url" value="{{ share_url }}">
|
||||
<input type="hidden" name="share.qrcode" value="{{ qrcode_url }}">
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block link_css %}
|
||||
|
||||
{{ css_link('home/css/content.css') }}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block inline_js %}
|
||||
|
||||
<script>
|
||||
layui.use(['jquery', 'helper'], function () {
|
||||
var $ = layui.jquery;
|
||||
var helper = layui.helper;
|
||||
var $courseList = $('#course-list');
|
||||
if ($courseList.length > 0) {
|
||||
helper.ajaxLoadHtml($courseList.data('url'), $courseList.attr('id'));
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
@ -2,21 +2,13 @@
|
||||
|
||||
{% block content %}
|
||||
|
||||
{{ partial('macros/course') }}
|
||||
|
||||
{% set share_url = share_url('page',page.id,auth_user.id) %}
|
||||
{% set qrcode_url = url({'for':'home.qrcode'},{'text':share_url}) %}
|
||||
{% set courses_url = url({'for':'home.widget.featured_courses'}) %}
|
||||
|
||||
<div class="breadcrumb">
|
||||
<span class="layui-breadcrumb">
|
||||
<a href="/">首页</a>
|
||||
<a><cite>{{ page.title }}</cite></a>
|
||||
</span>
|
||||
<span class="share">
|
||||
<a class="share-wechat" href="javascript:" title="分享到微信"><i class="layui-icon layui-icon-login-wechat"></i></a>
|
||||
<a class="share-qq" href="javascript:" title="分享到QQ空间"><i class="layui-icon layui-icon-login-qq"></i></a>
|
||||
<a class="share-weibo" href="javascript:" title="分享到微博"><i class="layui-icon layui-icon-login-weibo"></i></a>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="layout-main">
|
||||
@ -26,31 +18,29 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="layout-sidebar">
|
||||
{% if featured_courses %}
|
||||
<div class="sidebar">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header">推荐课程</div>
|
||||
<div class="layui-card-body">
|
||||
{% for course in featured_courses %}
|
||||
{{ sidebar_course_card(course) }}
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="sidebar" id="course-list" data-url="{{ courses_url }}"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-hide">
|
||||
<input type="hidden" name="share.title" value="{{ page.title }}">
|
||||
<input type="hidden" name="share.url" value="{{ share_url }}">
|
||||
<input type="hidden" name="share.qrcode" value="{{ qrcode_url }}">
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block link_css %}
|
||||
|
||||
{{ css_link('home/css/content.css') }}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block inline_js %}
|
||||
|
||||
<script>
|
||||
layui.use(['jquery', 'helper'], function () {
|
||||
var $ = layui.jquery;
|
||||
var helper = layui.helper;
|
||||
var $courseList = $('#course-list');
|
||||
if ($courseList.length > 0) {
|
||||
helper.ajaxLoadHtml($courseList.data('url'), $courseList.attr('id'));
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
20
app/Http/Home/Views/widget/featured_articles.volt
Normal file
20
app/Http/Home/Views/widget/featured_articles.volt
Normal file
@ -0,0 +1,20 @@
|
||||
{% if articles|length > 0 %}
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header">推荐文章</div>
|
||||
<div class="layui-card-body">
|
||||
<div class="sidebar-article-list">
|
||||
{% for article in articles %}
|
||||
{% set article_url = url({'for':'home.article.show','id':article.id}) %}
|
||||
<div class="title">
|
||||
<a href="{{ article_url }}" target="_blank">{{ article.title }}</a>
|
||||
</div>
|
||||
<div class="meta">
|
||||
<span class="view">{{ article.view_count }} 浏览</span>
|
||||
<span class="like">{{ article.like_count }} 点赞</span>
|
||||
<span class="comment">{{ article.comment_count }} 评论</span>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
12
app/Http/Home/Views/widget/featured_courses.volt
Normal file
12
app/Http/Home/Views/widget/featured_courses.volt
Normal file
@ -0,0 +1,12 @@
|
||||
{{ partial('macros/course') }}
|
||||
|
||||
{% if courses|length > 0 %}
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header">推荐课程</div>
|
||||
<div class="layui-card-body">
|
||||
{% for course in courses %}
|
||||
{{ sidebar_course_card(course) }}
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
@ -1,10 +0,0 @@
|
||||
layui.use(['jquery', 'helper'], function () {
|
||||
|
||||
var $ = layui.jquery;
|
||||
var helper = layui.helper;
|
||||
|
||||
$('.btn-cs').on('click', function () {
|
||||
helper.cs();
|
||||
});
|
||||
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user