mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-06-27 13:00:23 +08:00
整理前端代码
This commit is contained in:
parent
abdb4e1584
commit
24214e8baa
@ -14,6 +14,7 @@ use App\Services\Frontend\Course\RelatedList as CourseRelatedListService;
|
||||
use App\Services\Frontend\Course\ReviewList as CourseReviewListService;
|
||||
use App\Services\Frontend\Course\TeacherList as CourseTeacherListService;
|
||||
use App\Services\Frontend\Course\TopicList as CourseTopicListService;
|
||||
use Phalcon\Mvc\View;
|
||||
|
||||
/**
|
||||
* @RoutePrefix("/course")
|
||||
@ -70,6 +71,18 @@ class CourseController extends Controller
|
||||
|
||||
$packages = $service->handle($id);
|
||||
|
||||
$service = new CourseReviewListService();
|
||||
|
||||
$reviews = $service->handle($id);
|
||||
|
||||
$reviews->items = kg_array_object($reviews->items);
|
||||
|
||||
$service = new CourseConsultListService();
|
||||
|
||||
$consults = $service->handle($id);
|
||||
|
||||
$consults->items = kg_array_object($consults->items);
|
||||
|
||||
$service = new CourseTeacherListService();
|
||||
|
||||
$teachers = $service->handle($id);
|
||||
@ -89,6 +102,8 @@ class CourseController extends Controller
|
||||
$this->view->setVar('course', $course);
|
||||
$this->view->setVar('chapters', $chapters);
|
||||
$this->view->setVar('packages', $packages);
|
||||
$this->view->setVar('consults', $consults);
|
||||
$this->view->setVar('reviews', $reviews);
|
||||
$this->view->setVar('teachers', $teachers);
|
||||
$this->view->setVar('topics', $topics);
|
||||
$this->view->setVar('recommended_courses', $recommendedCourses);
|
||||
@ -130,7 +145,12 @@ class CourseController extends Controller
|
||||
|
||||
$pager = $service->handle($id);
|
||||
|
||||
return $this->jsonPaginate($pager);
|
||||
$pager->target = $this->request->get('target', 'trim', 'tab-consults');
|
||||
|
||||
$pager->items = kg_array_object($pager->items);
|
||||
|
||||
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
|
||||
$this->view->setVar('pager', $pager);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -142,7 +162,12 @@ class CourseController extends Controller
|
||||
|
||||
$pager = $service->handle($id);
|
||||
|
||||
return $this->jsonPaginate($pager);
|
||||
$pager->target = $this->request->get('target', 'trim', 'tab-reviews');
|
||||
|
||||
$pager->items = kg_array_object($pager->items);
|
||||
|
||||
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
|
||||
$this->view->setVar('pager', $pager);
|
||||
}
|
||||
|
||||
/**
|
||||
|
22
app/Http/Web/Views/course/consults.volt
Normal file
22
app/Http/Web/Views/course/consults.volt
Normal file
@ -0,0 +1,22 @@
|
||||
{% if pager.total_pages > 0 %}
|
||||
<div class="review-list">
|
||||
{% for item in pager.items %}
|
||||
{% set user_url = url({'for':'web.user.show','id':item.id}) %}
|
||||
<div class="review-card clearfix">
|
||||
<div class="avatar">
|
||||
<a href="{{ user_url }}">
|
||||
<img src="{{ item.user.avatar }}" alt="{{ item.user.name }}" title="{{ item.user.name }}">
|
||||
</a>
|
||||
</div>
|
||||
<div class="info">
|
||||
<div class="title">{{ item.question }}</div>
|
||||
<div class="content">{{ item.answer }}</div>
|
||||
<div class="footer">
|
||||
<span>{{ date('Y-m-d H:i',item.create_time) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{{ partial('partials/pager_ajax') }}
|
||||
{% endif %}
|
@ -3,15 +3,20 @@
|
||||
{% block content %}
|
||||
|
||||
{{ partial('partials/macro_course') }}
|
||||
|
||||
{{ partial('course/list_filter') }}
|
||||
|
||||
<div class="course-list clearfix">
|
||||
{% for item in pager.items %}
|
||||
{{ course_card(item) }}
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
{{ partial('partials/pager') }}
|
||||
{% if pager.total_pages > 0 %}
|
||||
<div class="course-list module clearfix">
|
||||
{% for item in pager.items %}
|
||||
{{ course_card(item) }}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{{ partial('partials/pager') }}
|
||||
{% else %}
|
||||
<div class="search-empty module">
|
||||
<div class="icon"><i class="layui-icon layui-icon-face-surprised"></i></div>
|
||||
<div class="text">没有检索到相关课程哦</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
@ -1,9 +1,10 @@
|
||||
<div class="course-filter">
|
||||
<div class="course-filter module">
|
||||
<div class="filter-group">
|
||||
<div class="title">方向</div>
|
||||
<div class="content">
|
||||
{% set tc_val = request.get('tc','int','all') %}
|
||||
{% for category in top_categories %}
|
||||
{% set class = request.get('tc','int','all') == category.id ? 'layui-btn layui-btn-xs' : 'none' %}
|
||||
{% set class = tc_val == category.id ? 'layui-btn layui-btn-xs' : 'none' %}
|
||||
<a class="{{ class }}" href="{{ category.url }}">{{ category.name }}</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
@ -12,8 +13,9 @@
|
||||
<div class="filter-group">
|
||||
<div class="title">分类</div>
|
||||
<div class="content">
|
||||
{% set sc_val = request.get('sc','int','all') %}
|
||||
{% for category in sub_categories %}
|
||||
{% set class = request.get('sc','int','all') == category.id ? 'layui-btn layui-btn-xs' : 'none' %}
|
||||
{% set class = sc_val == category.id ? 'layui-btn layui-btn-xs' : 'none' %}
|
||||
<a class="{{ class }}" href="{{ category.url }}">{{ category.name }}</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
@ -22,8 +24,9 @@
|
||||
<div class="filter-group">
|
||||
<div class="title">类型</div>
|
||||
<div class="content">
|
||||
{% set model_val = request.get('model','trim','all') %}
|
||||
{% for model in models %}
|
||||
{% set class = request.get('model','trim','all') == model.id ? 'layui-btn layui-btn-xs' : 'none' %}
|
||||
{% set class = model_val == model.id ? 'layui-btn layui-btn-xs' : 'none' %}
|
||||
<a class="{{ class }}" href="{{ model.url }}">{{ model.name }}</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
@ -31,8 +34,9 @@
|
||||
<div class="filter-group">
|
||||
<div class="title">难度</div>
|
||||
<div class="content">
|
||||
{% set level_val = request.get('level','trim','all') %}
|
||||
{% for level in levels %}
|
||||
{% set class = request.get('level','trim','all') == level.id ? 'layui-btn layui-btn-xs' : 'none' %}
|
||||
{% set class = level_val == level.id ? 'layui-btn layui-btn-xs' : 'none' %}
|
||||
<a class="{{ class }}" href="{{ level.url }}">{{ level.name }}</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
@ -40,8 +44,9 @@
|
||||
<div class="filter-group">
|
||||
<div class="title">排序</div>
|
||||
<div class="content">
|
||||
{% set sort_val = request.get('sort','trim','score') %}
|
||||
{% for sort in sorts %}
|
||||
{% set class = request.get('sort','trim','score') == sort.id ? 'layui-btn layui-btn-xs' : 'none' %}
|
||||
{% set class = sort_val == sort.id ? 'layui-btn layui-btn-xs' : 'none' %}
|
||||
<a class="{{ class }}" href="{{ sort.url }}">{{ sort.name }}</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
29
app/Http/Web/Views/course/reviews.volt
Normal file
29
app/Http/Web/Views/course/reviews.volt
Normal file
@ -0,0 +1,29 @@
|
||||
{%- macro star_info(rating) %}
|
||||
{% set stars = [1,2,3,4,5] %}
|
||||
{% for val in stars if val <= rating %}
|
||||
<i class="layui-icon layui-icon-star-fill"></i>
|
||||
{% endfor %}
|
||||
{%- endmacro %}
|
||||
|
||||
{% if pager.total_pages > 0 %}
|
||||
<div class="review-list">
|
||||
{% for item in pager.items %}
|
||||
{% set user_url = url({'for':'web.user.show','id':item.id}) %}
|
||||
<div class="review-card clearfix">
|
||||
<div class="avatar">
|
||||
<a href="{{ user_url }}">
|
||||
<img src="{{ item.user.avatar }}" alt="{{ item.user.name }}" title="{{ item.user.name }}">
|
||||
</a>
|
||||
</div>
|
||||
<div class="info">
|
||||
<div class="rating">{{ star_info(item.rating) }}</div>
|
||||
<div class="content">{{ item.content }}</div>
|
||||
<div class="footer">
|
||||
<span>{{ date('Y-m-d H:i',item.create_time) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{{ partial('partials/pager_ajax') }}
|
||||
{% endif %}
|
@ -24,7 +24,7 @@
|
||||
|
||||
<div class="layout-main clearfix">
|
||||
<div class="layout-content module">
|
||||
<div class="layui-tab layui-tab-brief course-info-tab">
|
||||
<div class="layui-tab layui-tab-brief course-tab">
|
||||
<ul class="layui-tab-title">
|
||||
<li class="layui-this">详情</li>
|
||||
<li>目录</li>
|
||||
@ -42,7 +42,7 @@
|
||||
<div class="layui-tab-item layui-show">
|
||||
<div class="course-details">{{ course.details }}</div>
|
||||
</div>
|
||||
<div class="layui-tab-item">
|
||||
<div class="layui-tab-item" id="tab-chapters">
|
||||
{% if course.model == 'vod' %}
|
||||
{{ partial('course/chapters_vod') }}
|
||||
{% elseif course.model == 'live' %}
|
||||
@ -52,13 +52,17 @@
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if show_packages == 1 %}
|
||||
<div class="layui-tab-item">{{ partial('course/packages') }}</div>
|
||||
<div class="layui-tab-item" id="tab-packages">
|
||||
{{ partial('course/packages') }}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if show_consults == 1 %}
|
||||
<div class="layui-tab-item">咨询</div>
|
||||
{% set consult_url = url({'for':'web.course.consults','id':course.id}) %}
|
||||
<div class="layui-tab-item" id="tab-consults" data-url="{{ consult_url }}"></div>
|
||||
{% endif %}
|
||||
{% if show_reviews == 1 %}
|
||||
<div class="layui-tab-item">评价</div>
|
||||
{% set review_url = url({'for':'web.course.reviews','id':course.id}) %}
|
||||
<div class="layui-tab-item" id="tab-reviews" data-url="{{ review_url }}"></div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
@ -67,19 +71,36 @@
|
||||
{% if teachers %}
|
||||
{{ partial('course/sidebar_teachers') }}
|
||||
{% endif %}
|
||||
|
||||
{% if topics %}
|
||||
{{ partial('course/sidebar_topics') }}
|
||||
{% endif %}
|
||||
|
||||
{% if recommended_courses %}
|
||||
{{ partial('course/sidebar_recommended') }}
|
||||
{% endif %}
|
||||
|
||||
{% if related_courses %}
|
||||
{{ partial('course/sidebar_related') }}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block inline_js %}
|
||||
|
||||
<script>
|
||||
|
||||
if ($('#tab-consults').length > 0) {
|
||||
console.log('#tab-consults#');
|
||||
var obj = $('#tab-consults');
|
||||
helper.ajaxPager(obj.attr('data-url'), obj.attr('id'));
|
||||
}
|
||||
|
||||
if ($('#tab-reviews').length > 0) {
|
||||
console.log('#tab-reviews#');
|
||||
var obj = $('#tab-reviews');
|
||||
helper.ajaxPager(obj.attr('data-url'), obj.attr('id'));
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
@ -2,6 +2,8 @@
|
||||
|
||||
{% block content %}
|
||||
|
||||
{{ partial('partials/macro_course') }}
|
||||
|
||||
{%- macro category_courses(courses) %}
|
||||
<div class="layui-tab layui-tab-brief">
|
||||
<ul class="layui-tab-title">
|
||||
@ -14,31 +16,9 @@
|
||||
{% for category in courses %}
|
||||
{% set class = loop.first ? 'layui-tab-item layui-show' : 'layui-tab-item' %}
|
||||
<div class="{{ class }}">
|
||||
<div class="module-course-list clearfix">
|
||||
<div class="index-course-list clearfix">
|
||||
{% for course in category.courses %}
|
||||
<div class="course-card">
|
||||
<div class="cover">
|
||||
<a href="{{ url({'for':'web.course.show','id':course.id}) }}" title="{{ course.title }}">
|
||||
<img lay-src="{{ course.cover }}!cover_270" alt="{{ course.title }}">
|
||||
</a>
|
||||
</div>
|
||||
<div class="title">
|
||||
<a href="{{ url({'for':'web.course.show','id':course.id}) }}" title="{{ course.title }}">{{ substr(course.title,0,15) }}</a>
|
||||
</div>
|
||||
<div class="meta">
|
||||
{% if course.market_price > 0 %}
|
||||
<span class="price">¥{{ course.market_price }}</span>
|
||||
<span class="level">中级</span>
|
||||
<span class="lesson">{{ course.lesson_count }}节课</span>
|
||||
<span class="user">{{ course.user_count }}人购买</span>
|
||||
{% else %}
|
||||
<span class="free">免费</span>
|
||||
<span class="level">中级</span>
|
||||
<span class="lesson">{{ course.lesson_count }}节课</span>
|
||||
<span class="user">{{ course.user_count }}人报名</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{{ course_card(course) }}
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
@ -47,7 +27,7 @@
|
||||
</div>
|
||||
{%- endmacro %}
|
||||
|
||||
<div class="index-module index-carousel">
|
||||
<div class="index-module index-carousel module">
|
||||
<div class="layui-carousel" id="carousel">
|
||||
<div class="carousel" carousel-item>
|
||||
{% for slide in slides %}
|
||||
@ -61,21 +41,21 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="index-module">
|
||||
<div class="index-module module">
|
||||
<div class="header">新上课程</div>
|
||||
<div class="content">
|
||||
{{ category_courses(new_courses) }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="index-module">
|
||||
<div class="index-module module">
|
||||
<div class="header">免费课程</div>
|
||||
<div class="content">
|
||||
{{ category_courses(free_courses) }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="index-module">
|
||||
<div class="index-module module">
|
||||
<div class="header">会员课程</div>
|
||||
<div class="content">
|
||||
{{ category_courses(vip_courses) }}
|
||||
|
@ -25,11 +25,11 @@
|
||||
<div class="course-card">
|
||||
<div class="cover">
|
||||
<a href="{{ course_url }}">
|
||||
<img src="{{ course.cover }}!cover_270" alt="{{ course.title }}">
|
||||
<img src="{{ course.cover }}!cover_270" alt="{{ course.title|e }}" title="{{ course.title|e }}">
|
||||
</a>
|
||||
</div>
|
||||
<div class="title">
|
||||
<a href="{{ course_url }}">{{ substr(course.title,0,15) }}</a>
|
||||
<a href="{{ course_url }}" title="{{ course.title|e }}">{{ substr(course.title,0,15) }}</a>
|
||||
</div>
|
||||
<div class="meta">
|
||||
{% if course.market_price > 0 %}
|
||||
@ -51,11 +51,11 @@
|
||||
{% set course_url = url({'for':'web.course.show','id':course.id}) %}
|
||||
<div class="sidebar-course-card clearfix">
|
||||
<div class="cover">
|
||||
<img src="{{ course.cover }}!cover_270" alt="{{ course.title }}">
|
||||
<img src="{{ course.cover }}!cover_270" alt="{{ course.title|e }}">
|
||||
</div>
|
||||
<div class="info">
|
||||
<div class="title">
|
||||
<a href="{{ course_url }}" title="{{ course.title }}">{{ substr(course.title,0,15) }}</a>
|
||||
<a href="{{ course_url }}" title="{{ course.title|e }}">{{ substr(course.title,0,15) }}</a>
|
||||
</div>
|
||||
<div class="meta">
|
||||
{% if course.market_price > 0 %}
|
||||
|
10
app/Http/Web/Views/partials/pager_ajax.volt
Normal file
10
app/Http/Web/Views/partials/pager_ajax.volt
Normal file
@ -0,0 +1,10 @@
|
||||
{% if pager.total_pages > 1 %}
|
||||
<div class="pager">
|
||||
<div class="layui-box layui-laypage layui-laypage-default">
|
||||
<a href="javascript:" data-target="{{ pager.target }}" data-url="{{ pager.first }}">首页</a>
|
||||
<a href="javascript:" data-target="{{ pager.target }}" data-url="{{ pager.previous }}">上页</a>
|
||||
<a href="javascript:" data-target="{{ pager.target }}" data-url="{{ pager.next }}">下页</a>
|
||||
<a href="javascript:" data-target="{{ pager.target }}" data-url="{{ pager.last }}">尾页</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
@ -1,35 +1,25 @@
|
||||
{% if pager.total_pages > 0 %}
|
||||
<div class="search-course-list">
|
||||
{% for item in pager.items %}
|
||||
<div class="search-course-card clearfix">
|
||||
<div class="cover">
|
||||
<a href="{{ url({'for':'web.course.show','id':item.id}) }}">
|
||||
<img src="{{ item.cover }}!cover_270" alt="{{ item.title|striptags }}">
|
||||
</a>
|
||||
<div class="search-course-list">
|
||||
{% for item in pager.items %}
|
||||
{% set course_url = url({'for':'web.course.show','id':item.id}) %}
|
||||
<div class="search-course-card clearfix">
|
||||
<div class="cover">
|
||||
<a href="{{ course_url }}">
|
||||
<img src="{{ item.cover }}!cover_270" alt="{{ item.title|e }}">
|
||||
</a>
|
||||
</div>
|
||||
<div class="info">
|
||||
<div class="title">
|
||||
<a href="{{ course_url }}">{{ item.title }}</a>
|
||||
</div>
|
||||
<div class="info">
|
||||
<div class="title">
|
||||
<a href="{{ url({'for':'web.course.show','id':item.id}) }}">{{ item.title }}</a>
|
||||
</div>
|
||||
<div class="summary">{{ item.summary }}</div>
|
||||
<div class="meta">
|
||||
<span>分类:{{ item.category.name }}</span>
|
||||
<span>讲师:{{ item.teacher.name }}</span>
|
||||
<span>难度:{{ level_info(item.level) }}</span>
|
||||
<span>课时:{{ item.lesson_count }}</span>
|
||||
<span>学员:{{ item.user_count }}</span>
|
||||
</div>
|
||||
<div class="summary">{{ item.summary }}</div>
|
||||
<div class="meta">
|
||||
<span>分类:{{ item.category.name }}</span>
|
||||
<span>讲师:{{ item.teacher.name }}</span>
|
||||
<span>难度:{{ level_info(item.level) }}</span>
|
||||
<span>课时:{{ item.lesson_count }}</span>
|
||||
<span>学员:{{ item.user_count }}</span>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="search-empty">
|
||||
<div class="icon">
|
||||
<i class="layui-icon layui-icon-face-surprised"></i>
|
||||
</div>
|
||||
<div class="text">
|
||||
没有找到<span class="query">{{ request.get('query') }}</span>相关内容,换个关键字试试吧!
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
@ -3,23 +3,31 @@
|
||||
{% block content %}
|
||||
|
||||
{% set type = request.get('type','trim','course') %}
|
||||
{% set query = request.get('query','striptags','') %}
|
||||
|
||||
{{ partial('partials/macro_course') }}
|
||||
|
||||
<div class="layui-breadcrumb breadcrumb">
|
||||
<a href="/">首页</a>
|
||||
<a href="#">搜索</a>
|
||||
<a><cite>{{ request.get('query')|striptags }}</cite></a>
|
||||
<a><cite>{{ query }}</cite></a>
|
||||
</div>
|
||||
|
||||
<div class="layout-main clearfix">
|
||||
<div class="layout-content module">
|
||||
{% if type == 'course' %}
|
||||
{{ partial('search/content_course') }}
|
||||
{% elseif type == 'other' %}
|
||||
{{ partial('search/content_other') }}
|
||||
{% if pager.total_pages > 0 %}
|
||||
{% if type == 'course' %}
|
||||
{{ partial('search/content_course') }}
|
||||
{% elseif type == 'other' %}
|
||||
{{ partial('search/content_other') }}
|
||||
{% endif %}
|
||||
{{ partial('partials/pager') }}
|
||||
{% else %}
|
||||
<div class="search-empty">
|
||||
<div class="icon"><i class="layui-icon layui-icon-face-surprised"></i></div>
|
||||
<div class="text">没有找到<span class="query">{{ query }}</span>相关内容,换个关键字试试吧!</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{{ partial('partials/pager') }}
|
||||
</div>
|
||||
<div class="layout-sidebar">
|
||||
{{ partial('search/sidebar') }}
|
||||
|
@ -30,70 +30,64 @@ class Course extends Repository
|
||||
{
|
||||
$builder = $this->modelsManager->createBuilder();
|
||||
|
||||
$builder->from(CourseModel::class);
|
||||
|
||||
$builder->where('1 = 1');
|
||||
|
||||
if (!empty($where['category_id'])) {
|
||||
$where['category_id'] = is_array($where['category_id']) ? $where['category_id'] : [$where['category_id']];
|
||||
$builder->addFrom(CourseModel::class, 'c');
|
||||
$builder->join(CourseCategoryModel::class, 'c.id = cc.course_id', 'cc');
|
||||
$builder->inWhere('cc.category_id', $where['category_id']);
|
||||
$where['id'] = $this->getCategoryCourseIds($where['category_id']);
|
||||
} elseif (!empty($where['teacher_id'])) {
|
||||
$where['teacher_id'] = is_array($where['teacher_id']) ? $where['teacher_id'] : [$where['teacher_id']];
|
||||
$builder->addFrom(CourseModel::class, 'c');
|
||||
$builder->join(CourseUserModel::class, 'c.id = cu.course_id', 'cu');
|
||||
$builder->inWhere('cu.user_id', $where['teacher_id']);
|
||||
$builder->andWhere('cu.role_type = :role_type:', ['role_type' => CourseUserModel::ROLE_TEACHER]);
|
||||
} else {
|
||||
$builder->addFrom(CourseModel::class, 'c');
|
||||
$builder->where('1 = 1');
|
||||
$where['id'] = $this->getTeacherCourseIds($where['teacher_id']);
|
||||
}
|
||||
|
||||
if (!empty($where['id'])) {
|
||||
if (is_array($where['id'])) {
|
||||
$builder->inWhere('c.id', $where['id']);
|
||||
$builder->inWhere('id', $where['id']);
|
||||
} else {
|
||||
$builder->andWhere('c.id = :id:', ['id' => $where['id']]);
|
||||
$builder->andWhere('id = :id:', ['id' => $where['id']]);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($where['title'])) {
|
||||
$builder->andWhere('c.title LIKE :title:', ['title' => "%{$where['title']}%"]);
|
||||
$builder->andWhere('title LIKE :title:', ['title' => "%{$where['title']}%"]);
|
||||
}
|
||||
|
||||
if (!empty($where['model'])) {
|
||||
$builder->andWhere('c.model = :model:', ['model' => $where['model']]);
|
||||
$builder->andWhere('model = :model:', ['model' => $where['model']]);
|
||||
}
|
||||
|
||||
if (!empty($where['level'])) {
|
||||
$builder->andWhere('c.level = :level:', ['level' => $where['level']]);
|
||||
$builder->andWhere('level = :level:', ['level' => $where['level']]);
|
||||
}
|
||||
|
||||
if (isset($where['free'])) {
|
||||
if ($where['free'] == 1) {
|
||||
$builder->andWhere('c.market_price = 0');
|
||||
$builder->andWhere('market_price = 0');
|
||||
} else {
|
||||
$builder->andWhere('c.market_price > 0');
|
||||
$builder->andWhere('market_price > 0');
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($where['published'])) {
|
||||
$builder->andWhere('c.published = :published:', ['published' => $where['published']]);
|
||||
$builder->andWhere('published = :published:', ['published' => $where['published']]);
|
||||
}
|
||||
|
||||
if (isset($where['deleted'])) {
|
||||
$builder->andWhere('c.deleted = :deleted:', ['deleted' => $where['deleted']]);
|
||||
$builder->andWhere('deleted = :deleted:', ['deleted' => $where['deleted']]);
|
||||
}
|
||||
|
||||
switch ($sort) {
|
||||
case 'score':
|
||||
$orderBy = 'c.score DESC';
|
||||
$orderBy = 'score DESC';
|
||||
break;
|
||||
case 'rating':
|
||||
$orderBy = 'c.rating DESC';
|
||||
$orderBy = 'rating DESC';
|
||||
break;
|
||||
case 'popular':
|
||||
$orderBy = 'c.user_count DESC';
|
||||
$orderBy = 'user_count DESC';
|
||||
break;
|
||||
default:
|
||||
$orderBy = 'c.id DESC';
|
||||
$orderBy = 'id DESC';
|
||||
break;
|
||||
}
|
||||
|
||||
@ -335,4 +329,34 @@ class Course extends Repository
|
||||
]);
|
||||
}
|
||||
|
||||
protected function getCategoryCourseIds($categoryId)
|
||||
{
|
||||
$categoryIds = is_array($categoryId) ? $categoryId : [$categoryId];
|
||||
|
||||
$repo = new CourseCategory();
|
||||
|
||||
$rows = $repo->findByCategoryIds($categoryIds);
|
||||
|
||||
if ($rows->count() == 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return kg_array_column($rows->toArray(), 'course_id');
|
||||
}
|
||||
|
||||
protected function getTeacherCourseIds($teacherId)
|
||||
{
|
||||
$teacherIds = is_array($teacherId) ? $teacherId : [$teacherId];
|
||||
|
||||
$repo = new CourseUser();
|
||||
|
||||
$rows = $repo->findByTeacherIds($teacherIds);
|
||||
|
||||
if ($rows->count() == 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return kg_array_column($rows->toArray(), 'course_id');
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ class CourseCategory extends Repository
|
||||
* @param array $categoryIds
|
||||
* @return ResultsetInterface|Resultset|CourseCategoryModel[]
|
||||
*/
|
||||
public function findByCategoryIds($categoryIds)
|
||||
public function findByCategoryIds(array $categoryIds)
|
||||
{
|
||||
return CourseCategoryModel::query()
|
||||
->inWhere('category_id', $categoryIds)
|
||||
@ -38,7 +38,7 @@ class CourseCategory extends Repository
|
||||
* @param array $courseIds
|
||||
* @return ResultsetInterface|Resultset|CourseCategoryModel[]
|
||||
*/
|
||||
public function findByCourseIds($courseIds)
|
||||
public function findByCourseIds(array $courseIds)
|
||||
{
|
||||
return CourseCategoryModel::query()
|
||||
->inWhere('course_id', $courseIds)
|
||||
|
@ -5,6 +5,8 @@ namespace App\Repos;
|
||||
use App\Library\Paginator\Adapter\QueryBuilder as PagerQueryBuilder;
|
||||
use App\Models\CourseUser as CourseUserModel;
|
||||
use Phalcon\Mvc\Model;
|
||||
use Phalcon\Mvc\Model\Resultset;
|
||||
use Phalcon\Mvc\Model\ResultsetInterface;
|
||||
|
||||
class CourseUser extends Repository
|
||||
{
|
||||
@ -116,4 +118,18 @@ class CourseUser extends Repository
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $teacherIds
|
||||
* @return ResultsetInterface|Resultset|CourseUserModel[]
|
||||
*/
|
||||
public function findByTeacherIds(array $teacherIds)
|
||||
{
|
||||
$roleType = CourseUserModel::ROLE_TEACHER;
|
||||
|
||||
return CourseUserModel::query()
|
||||
->inWhere('user_id', $teacherIds)
|
||||
->andWhere('role_type = :role_type:', ['role_type' => $roleType])
|
||||
->execute();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -118,8 +118,8 @@ body {
|
||||
width: 320px;
|
||||
}
|
||||
|
||||
.index-module {
|
||||
margin-bottom: 15px;
|
||||
.index-module .layui-tab {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.index-module .layui-tab-title {
|
||||
@ -127,17 +127,17 @@ body {
|
||||
}
|
||||
|
||||
.index-module .layui-tab-content {
|
||||
padding: 20px 0;
|
||||
padding: 20px 0 0 0;
|
||||
}
|
||||
|
||||
.index-module .header {
|
||||
text-align: center;
|
||||
font-size: 20px;
|
||||
line-height: 30px;
|
||||
font-size: 18px;
|
||||
padding-bottom: 15px;
|
||||
border-bottom: 1px solid #f6f6f6;
|
||||
}
|
||||
|
||||
.index-carousel {
|
||||
margin-bottom: 30px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
@ -230,6 +230,7 @@ body {
|
||||
}
|
||||
|
||||
.query-badge {
|
||||
padding: 2px 5px;
|
||||
margin-right: 5px;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
@ -281,7 +282,6 @@ body {
|
||||
|
||||
.filter-group {
|
||||
padding-bottom: 5px;
|
||||
border-bottom: 1px dashed #ccc;
|
||||
height: 40px;
|
||||
line-height: 40px;
|
||||
}
|
||||
@ -327,12 +327,12 @@ body {
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
.course-info-tab {
|
||||
.course-tab {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.course-info-tab .layui-tab-content {
|
||||
padding: 20px 0;
|
||||
.course-tab .layui-tab-content {
|
||||
padding: 30px 0;
|
||||
}
|
||||
|
||||
.lesson-item {
|
||||
@ -384,6 +384,7 @@ body {
|
||||
width: 180px;
|
||||
font-size: 12px;
|
||||
text-align: center;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.package-info span {
|
||||
@ -391,6 +392,7 @@ body {
|
||||
}
|
||||
|
||||
.package-info .title {
|
||||
padding: 0 10px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
@ -416,22 +418,22 @@ body {
|
||||
}
|
||||
|
||||
.package-course-list {
|
||||
width: 580px;
|
||||
width: 560px;
|
||||
height: 170px;
|
||||
overflow-x: auto;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.package-course-card {
|
||||
width: 180px;
|
||||
width: 175px;
|
||||
display: inline-block;
|
||||
margin-right: 10px;
|
||||
margin-right: 5px;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.package-course-card .cover {
|
||||
width: 180px;
|
||||
height: 96px;
|
||||
width: 175px;
|
||||
height: 95px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
@ -445,6 +447,59 @@ body {
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
.review-card {
|
||||
padding-bottom: 10px;
|
||||
margin-bottom: 10px;
|
||||
border-bottom: 1px dashed #ccc;
|
||||
}
|
||||
|
||||
.review-card:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.review-card .avatar {
|
||||
float: left;
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
margin-right: 15px;
|
||||
}
|
||||
|
||||
.review-card .avatar img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border-radius: 60px;
|
||||
}
|
||||
|
||||
.review-card .info {
|
||||
float: left;
|
||||
width: 650px;
|
||||
}
|
||||
|
||||
.review-card .rating {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.review-card .rating .layui-icon {
|
||||
color: orange;
|
||||
}
|
||||
|
||||
.review-card .title {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.review-card .content {
|
||||
margin-bottom: 10px;
|
||||
color: #999;
|
||||
font-size: 12px;
|
||||
word-wrap: break-word;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
.review-card .footer {
|
||||
color: #999;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.sidebar-teacher-card {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
@ -476,9 +531,9 @@ body {
|
||||
}
|
||||
|
||||
.topic-badge {
|
||||
padding: 5px;
|
||||
margin-right: 10px;
|
||||
margin-bottom: 10px;
|
||||
padding: 2px 5px;
|
||||
margin-right: 5px;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.sidebar-course-card {
|
||||
|
@ -20,6 +20,16 @@ util.fixbar({
|
||||
}
|
||||
});
|
||||
|
||||
var helper = {};
|
||||
|
||||
helper.ajaxPager = function (url, target) {
|
||||
var index = layer.load();
|
||||
$.get(url, function (html) {
|
||||
$('#' + target).html(html);
|
||||
layer.close(index);
|
||||
});
|
||||
}
|
||||
|
||||
form.on('submit(go)', function (data) {
|
||||
var submit = $(this);
|
||||
submit.attr('disabled', true).addClass('layui-btn-disabled');
|
||||
@ -74,6 +84,8 @@ $('.kg-delete').on('click', function () {
|
||||
});
|
||||
});
|
||||
|
||||
$('.kg-back').on('click', function () {
|
||||
window.history.back();
|
||||
$('body').on('click', '.layui-laypage > a', function () {
|
||||
var url = $(this).attr('data-url');
|
||||
var target = $(this).attr('data-target');
|
||||
helper.ajaxPager(url, target);
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user