mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-08-05 14:01:39 +08:00
整理分享功能
This commit is contained in:
parent
949a94ace9
commit
23e19cd279
@ -28,7 +28,7 @@ class ChapterTreeList extends Builder
|
||||
$list[] = [
|
||||
'id' => $chapter->id,
|
||||
'title' => $chapter->title,
|
||||
'priority' => $chapter->priority,
|
||||
'model' => $chapter->model,
|
||||
'children' => $this->handleChildren($chapter),
|
||||
];
|
||||
}
|
||||
@ -64,6 +64,7 @@ class ChapterTreeList extends Builder
|
||||
$list[] = [
|
||||
'id' => $lesson->id,
|
||||
'title' => $lesson->title,
|
||||
'model' => $lesson->model,
|
||||
'free' => $lesson->free,
|
||||
'attrs' => $attrs,
|
||||
];
|
||||
|
@ -5,6 +5,7 @@ namespace App\Http\Web\Controllers;
|
||||
use App\Http\Web\Services\CourseQuery as CourseQueryService;
|
||||
use App\Services\Frontend\Course\ChapterList as CourseChapterListService;
|
||||
use App\Services\Frontend\Course\ConsultList as CourseConsultListService;
|
||||
use App\Services\Frontend\Course\CourseBasic as CourseBasicService;
|
||||
use App\Services\Frontend\Course\CourseInfo as CourseInfoService;
|
||||
use App\Services\Frontend\Course\CourseList as CourseListService;
|
||||
use App\Services\Frontend\Course\Favorite as CourseFavoriteService;
|
||||
@ -58,7 +59,7 @@ class CourseController extends Controller
|
||||
$pager->target = 'course-list';
|
||||
|
||||
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
|
||||
$this->view->pick('course/list_pager');
|
||||
$this->view->pick('course/ajax_pager');
|
||||
$this->view->setVar('pager', $pager);
|
||||
}
|
||||
|
||||
@ -75,26 +76,44 @@ class CourseController extends Controller
|
||||
|
||||
$course['category_paths'] = $service->handleCategoryPaths($course['category_id']);
|
||||
|
||||
$service = new CourseChapterListService();
|
||||
|
||||
$chapters = $service->handle($id);
|
||||
|
||||
$service = new CourseTeacherListService();
|
||||
|
||||
$teachers = $service->handle($id);
|
||||
|
||||
$service = new RewardOptionList();
|
||||
|
||||
$rewardOptions = $service->handle();
|
||||
$rewards = $service->handle();
|
||||
|
||||
$this->siteSeo->prependTitle($course['title']);
|
||||
$this->siteSeo->setKeywords($course['keywords']);
|
||||
$this->siteSeo->setDescription($course['summary']);
|
||||
|
||||
$this->view->setVar('course', $course);
|
||||
$this->view->setVar('chapters', $chapters);
|
||||
$this->view->setVar('rewards', $rewards);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Get("/{id:[0-9]+}/teachers", name="web.course.teachers")
|
||||
*/
|
||||
public function teachersAction($id)
|
||||
{
|
||||
$service = new CourseTeacherListService();
|
||||
|
||||
$teachers = $service->handle($id);
|
||||
|
||||
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
|
||||
$this->view->pick('course/ajax_teachers');
|
||||
$this->view->setVar('teachers', $teachers);
|
||||
$this->view->setVar('reward_options', $rewardOptions);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Get("/{id:[0-9]+}/chapters", name="web.course.chapters")
|
||||
*/
|
||||
public function chaptersAction($id)
|
||||
{
|
||||
$service = new CourseChapterListService();
|
||||
|
||||
$chapters = $service->handle($id);
|
||||
|
||||
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
|
||||
$this->view->pick('course/ajax_chapters');
|
||||
$this->view->setVar('chapters', $chapters);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -107,7 +126,7 @@ class CourseController extends Controller
|
||||
$packages = $service->handle($id);
|
||||
|
||||
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
|
||||
$this->view->pick('course/show_packages');
|
||||
$this->view->pick('course/ajax_packages');
|
||||
$this->view->setVar('packages', $packages);
|
||||
}
|
||||
|
||||
@ -123,7 +142,7 @@ class CourseController extends Controller
|
||||
$pager->target = 'tab-consults';
|
||||
|
||||
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
|
||||
$this->view->pick('course/show_consults');
|
||||
$this->view->pick('course/ajax_consults');
|
||||
$this->view->setVar('pager', $pager);
|
||||
}
|
||||
|
||||
@ -139,7 +158,7 @@ class CourseController extends Controller
|
||||
$pager->target = 'tab-reviews';
|
||||
|
||||
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
|
||||
$this->view->pick('course/show_reviews');
|
||||
$this->view->pick('course/ajax_reviews');
|
||||
$this->view->setVar('pager', $pager);
|
||||
}
|
||||
|
||||
@ -153,7 +172,7 @@ class CourseController extends Controller
|
||||
$courses = $service->handle($id);
|
||||
|
||||
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
|
||||
$this->view->pick('course/show_recommended');
|
||||
$this->view->pick('course/ajax_recommended');
|
||||
$this->view->setVar('courses', $courses);
|
||||
}
|
||||
|
||||
@ -167,7 +186,7 @@ class CourseController extends Controller
|
||||
$courses = $service->handle($id);
|
||||
|
||||
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
|
||||
$this->view->pick('course/show_related');
|
||||
$this->view->pick('course/ajax_related');
|
||||
$this->view->setVar('courses', $courses);
|
||||
}
|
||||
|
||||
@ -181,7 +200,7 @@ class CourseController extends Controller
|
||||
$topics = $service->handle($id);
|
||||
|
||||
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
|
||||
$this->view->pick('course/show_topics');
|
||||
$this->view->pick('course/ajax_topics');
|
||||
$this->view->setVar('topics', $topics);
|
||||
}
|
||||
|
||||
@ -190,7 +209,7 @@ class CourseController extends Controller
|
||||
*/
|
||||
public function ratingAction($id)
|
||||
{
|
||||
$service = new CourseInfoService();
|
||||
$service = new CourseBasicService();
|
||||
|
||||
$course = $service->handle($id);
|
||||
|
||||
|
@ -38,6 +38,33 @@ class ImController extends LayerController
|
||||
return $this->jsonSuccess(['data' => ['list' => $list]]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Get("/msgbox", name="web.im.msgbox")
|
||||
*/
|
||||
public function msgboxAction()
|
||||
{
|
||||
$service = new ImService();
|
||||
|
||||
$pager = $service->getSystemMessages();
|
||||
|
||||
$this->view->pick('im/msgbox');
|
||||
$this->view->setVar('pager', $pager);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Get("/chatlog", name="web.im.chatlog")
|
||||
*/
|
||||
public function chatlogAction()
|
||||
{
|
||||
$service = new ImService();
|
||||
|
||||
$pager = $service->getChatMessages();
|
||||
|
||||
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
|
||||
$this->view->pick('im/chatlog');
|
||||
$this->view->setVar('pager', $pager);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Get("/msg/friend/unread", name="web.im.unread_friend_msg")
|
||||
*/
|
||||
@ -62,19 +89,6 @@ class ImController extends LayerController
|
||||
return $this->jsonSuccess(['count' => $count]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Get("/msg/box", name="web.im.msg_box")
|
||||
*/
|
||||
public function messageBoxAction()
|
||||
{
|
||||
$service = new ImService();
|
||||
|
||||
$pager = $service->getSystemMessages();
|
||||
|
||||
$this->view->pick('im/msg_box');
|
||||
$this->view->setVar('pager', $pager);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Get("/msg/sys", name="web.im.sys_msg")
|
||||
*/
|
||||
@ -114,20 +128,6 @@ class ImController extends LayerController
|
||||
return $this->jsonSuccess(['status' => $status]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Get("/chat/log", name="web.im.chat_log")
|
||||
*/
|
||||
public function chatLogAction()
|
||||
{
|
||||
$service = new ImService();
|
||||
|
||||
$pager = $service->getChatMessages();
|
||||
|
||||
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
|
||||
$this->view->pick('im/chat_log');
|
||||
$this->view->setVar('pager', $pager);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Get("/chat/history", name="web.im.chat_history")
|
||||
*/
|
||||
|
@ -31,7 +31,7 @@ class TeacherController extends Controller
|
||||
$pager->target = 'teacher-list';
|
||||
|
||||
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
|
||||
$this->view->pick('teacher/list_pager');
|
||||
$this->view->pick('teacher/ajax_pager');
|
||||
$this->view->setVar('pager', $pager);
|
||||
}
|
||||
|
||||
|
@ -29,15 +29,14 @@ class TopicController extends Controller
|
||||
*/
|
||||
public function coursesAction($id)
|
||||
{
|
||||
$target = $this->request->get('target', 'trim', 'course-list');
|
||||
|
||||
$service = new TopicCourseListService();
|
||||
|
||||
$pager = $service->handle($id);
|
||||
$pager->items = kg_array_object($pager->items);
|
||||
$pager->target = $target;
|
||||
$pager->target = 'course-list';
|
||||
|
||||
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
|
||||
$this->view->pick('topic/ajax_courses');
|
||||
$this->view->setVar('pager', $pager);
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,7 @@ class UserController extends Controller
|
||||
$pager->target = 'tab-courses';
|
||||
|
||||
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
|
||||
$this->view->pick('user/ajax_courses');
|
||||
$this->view->setVar('pager', $pager);
|
||||
}
|
||||
|
||||
@ -53,6 +54,7 @@ class UserController extends Controller
|
||||
$pager->target = 'tab-favorites';
|
||||
|
||||
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
|
||||
$this->view->pick('user/ajax_favorites');
|
||||
$this->view->setVar('pager', $pager);
|
||||
}
|
||||
|
||||
@ -68,6 +70,7 @@ class UserController extends Controller
|
||||
$pager->target = 'tab-friends';
|
||||
|
||||
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
|
||||
$this->view->pick('user/ajax_friends');
|
||||
$this->view->setVar('pager', $pager);
|
||||
}
|
||||
|
||||
|
@ -135,7 +135,7 @@ class Im extends Service
|
||||
|
||||
$groupRepo = new ImGroupRepo();
|
||||
|
||||
$users = $groupRepo->findGroupUsers($group->id);
|
||||
$users = $groupRepo->findUsers($group->id);
|
||||
|
||||
if ($users->count() == 0) {
|
||||
return [];
|
||||
@ -170,7 +170,7 @@ class Im extends Service
|
||||
|
||||
$userRepo = new ImUserRepo();
|
||||
|
||||
$messages = $userRepo->findUnreadImFriendMessages($friend->id, $user->id);
|
||||
$messages = $userRepo->findUnreadFriendMessages($friend->id, $user->id);
|
||||
|
||||
if ($messages->count() == 0) {
|
||||
return;
|
||||
@ -212,7 +212,7 @@ class Im extends Service
|
||||
|
||||
$userRepo = new ImUserRepo();
|
||||
|
||||
return $userRepo->countUnreadImSystemMessages($user->id);
|
||||
return $userRepo->countUnreadSystemMessages($user->id);
|
||||
}
|
||||
|
||||
public function getSystemMessages()
|
||||
@ -306,7 +306,7 @@ class Im extends Service
|
||||
|
||||
$userRepo = new ImUserRepo();
|
||||
|
||||
$chatGroups = $userRepo->findImGroups($user->id);
|
||||
$chatGroups = $userRepo->findGroups($user->id);
|
||||
|
||||
if ($chatGroups->count() > 0) {
|
||||
foreach ($chatGroups as $group) {
|
||||
@ -385,7 +385,7 @@ class Im extends Service
|
||||
|
||||
$validator = new ImGroupUserValidator();
|
||||
|
||||
$relation = $validator->checkGroupUser($user->id, $to['id']);
|
||||
$relation = $validator->checkGroupUser($to['id'], $user->id);
|
||||
|
||||
/**
|
||||
* 被对方屏蔽,忽略消息
|
||||
@ -423,7 +423,7 @@ class Im extends Service
|
||||
|
||||
$userRepo = new ImUserRepo();
|
||||
|
||||
$messages = $userRepo->findUnreadImSystemMessages($user->id);
|
||||
$messages = $userRepo->findUnreadSystemMessages($user->id);
|
||||
|
||||
if ($messages->count() > 0) {
|
||||
foreach ($messages as $message) {
|
||||
@ -506,7 +506,7 @@ class Im extends Service
|
||||
|
||||
$userRepo = new ImUserRepo();
|
||||
|
||||
$friendUsers = $userRepo->findImFriendUsers($user->id);
|
||||
$friendUsers = $userRepo->findFriendUsers($user->id);
|
||||
|
||||
if ($friendUsers->count() == 0) {
|
||||
return;
|
||||
@ -534,8 +534,8 @@ class Im extends Service
|
||||
{
|
||||
$userRepo = new ImUserRepo();
|
||||
|
||||
$friendGroups = $userRepo->findImFriendGroups($user->id);
|
||||
$friendUsers = $userRepo->findImFriendUsers($user->id);
|
||||
$friendGroups = $userRepo->findFriendGroups($user->id);
|
||||
$friendUsers = $userRepo->findFriendUsers($user->id);
|
||||
|
||||
$items = [];
|
||||
|
||||
@ -600,7 +600,7 @@ class Im extends Service
|
||||
{
|
||||
$userRepo = new ImUserRepo();
|
||||
|
||||
$groups = $userRepo->findImGroups($user->id);
|
||||
$groups = $userRepo->findGroups($user->id);
|
||||
|
||||
if ($groups->count() == 0) {
|
||||
return [];
|
||||
|
@ -127,7 +127,7 @@ Trait ImFriendTrait
|
||||
|
||||
$itemType = ImSystemMessageModel::TYPE_FRIEND_REQUEST;
|
||||
|
||||
$message = $userRepo->findImSystemMessage($receiver->id, $itemType);
|
||||
$message = $userRepo->findSystemMessage($receiver->id, $itemType);
|
||||
|
||||
if ($message) {
|
||||
$expired = time() - $message->create_time > 7 * 86400;
|
||||
|
@ -30,8 +30,8 @@ Trait ImGroupTrait
|
||||
$group = $validator->checkGroup($post['group_id']);
|
||||
$remark = $validator->checkRemark($post['remark']);
|
||||
|
||||
$validator->checkIfJoined($user->id, $group->id);
|
||||
$validator->checkIfBlocked($user->id, $group->id);
|
||||
$validator->checkIfJoined($group->id, $user->id);
|
||||
$validator->checkIfBlocked($group->id, $user->id);
|
||||
|
||||
$this->handleApplyGroupNotice($user, $group, $remark);
|
||||
}
|
||||
@ -64,7 +64,7 @@ Trait ImGroupTrait
|
||||
|
||||
$groupUserRepo = new ImGroupUserRepo();
|
||||
|
||||
$groupUser = $groupUserRepo->findGroupUser($applicant->id, $group->id);
|
||||
$groupUser = $groupUserRepo->findGroupUser($group->id, $applicant->id);
|
||||
|
||||
if (!$groupUser) {
|
||||
$groupUserModel = new ImGroupUserModel();
|
||||
@ -130,7 +130,7 @@ Trait ImGroupTrait
|
||||
|
||||
$itemType = ImSystemMessageModel::TYPE_GROUP_REQUEST;
|
||||
|
||||
$message = $userRepo->findImSystemMessage($receiver->id, $itemType);
|
||||
$message = $userRepo->findSystemMessage($receiver->id, $itemType);
|
||||
|
||||
if ($message) {
|
||||
$expired = time() - $message->create_time > 7 * 86400;
|
||||
@ -236,7 +236,7 @@ Trait ImGroupTrait
|
||||
{
|
||||
$groupRepo = new ImGroupRepo();
|
||||
|
||||
$users = $groupRepo->findGroupUsers($group->id);
|
||||
$users = $groupRepo->findUsers($group->id);
|
||||
|
||||
if ($users->count() == 0) {
|
||||
return;
|
||||
|
@ -72,6 +72,7 @@
|
||||
|
||||
{{ js_include('web/js/chapter.live.player.js') }}
|
||||
{{ js_include('web/js/chapter.live.im.js') }}
|
||||
{{ js_include('web/js/chapter.like.js') }}
|
||||
{{ js_include('web/js/course.share.js') }}
|
||||
|
||||
{% endblock %}
|
@ -48,6 +48,7 @@
|
||||
{% block include_js %}
|
||||
|
||||
{{ js_include('web/js/chapter.read.js') }}
|
||||
{{ js_include('web/js/chapter.like.js') }}
|
||||
{{ js_include('web/js/course.share.js') }}
|
||||
|
||||
{% endblock %}
|
@ -114,6 +114,7 @@
|
||||
{{ js_include('lib/jquery.min.js') }}
|
||||
{{ js_include('lib/jquery.danmu.min.js') }}
|
||||
{{ js_include('web/js/course.share.js') }}
|
||||
{{ js_include('web/js/chapter.like.js') }}
|
||||
{{ js_include('web/js/chapter.vod.player.js') }}
|
||||
|
||||
{% endblock %}
|
@ -53,11 +53,11 @@
|
||||
<div class="layui-colla-content layui-show">
|
||||
<ul class="lesson-list">
|
||||
{% for lesson in chapter.children %}
|
||||
{% if course.model == 'vod' %}
|
||||
{% if lesson.model == 'vod' %}
|
||||
<li class="lesson-item clearfix">{{ vod_lesson_info(lesson) }}</li>
|
||||
{% elseif course.model == 'live' %}
|
||||
{% elseif lesson.model == 'live' %}
|
||||
<li class="lesson-item clearfix">{{ live_lesson_info(lesson) }}</li>
|
||||
{% elseif course.model == 'read' %}
|
||||
{% elseif lesson.model == 'read' %}
|
||||
<li class="lesson-item clearfix">{{ read_lesson_info(lesson) }}</li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
@ -13,7 +13,7 @@
|
||||
<div class="title">{{ item.question }}</div>
|
||||
<div class="content">{{ item.answer }}</div>
|
||||
<div class="footer">
|
||||
<span class="time">{{ date('Y-m-d H:i',item.create_time) }}</span>
|
||||
<span class="time">{{ time_ago('Y-m-d',item.create_time) }}</span>
|
||||
<a href="javascript:" class="like" title="点赞" data-url="{{ like_url }}">
|
||||
<i class="layui-icon layui-icon-praise icon-praise"></i>
|
||||
<em class="like-count">{{ item.like_count }}</em>
|
@ -8,7 +8,7 @@
|
||||
{% 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}) %}
|
||||
{% set user_url = url({'for':'web.user.show','id':item.user.id}) %}
|
||||
{% set like_url = url({'for':'web.review.like','id':item.id}) %}
|
||||
<div class="review-card clearfix">
|
||||
<div class="avatar">
|
||||
@ -21,7 +21,7 @@
|
||||
</div>
|
||||
<div class="content">{{ item.content }}</div>
|
||||
<div class="footer">
|
||||
<span class="time">{{ date('Y-m-d H:i',item.create_time) }}</span>
|
||||
<span class="time">{{ date('Y-m-d',item.create_time) }}</span>
|
||||
<a href="javascript:" class="like" title="点赞" data-url="{{ like_url }}">
|
||||
<i class="layui-icon layui-icon-praise icon-praise"></i>
|
||||
<em class="like-count">{{ item.like_count }}</em>
|
@ -20,6 +20,7 @@
|
||||
|
||||
<div class="layout-main clearfix">
|
||||
|
||||
{% set show_tab_chapters = course.lesson_count > 0 ? 1 : 0 %}
|
||||
{% set show_tab_packages = course.package_count > 0 ? 1 : 0 %}
|
||||
{% set show_tab_consults = course.consult_count > 0 ? 1 : 0 %}
|
||||
{% set show_tab_reviews = course.review_count > 0 ? 1 : 0 %}
|
||||
@ -29,24 +30,27 @@
|
||||
<div class="layui-tab layui-tab-brief course-tab">
|
||||
<ul class="layui-tab-title">
|
||||
<li class="layui-this">详情</li>
|
||||
<li>目录</li>
|
||||
{% if show_tab_chapters == 1 %}
|
||||
<li>目录<span class="tab-count">{{ course.lesson_count }}</span></li>
|
||||
{% endif %}
|
||||
{% if show_tab_packages == 1 %}
|
||||
<li>套餐<span class="tab-count package-count">{{ course.package_count }}</span></li>
|
||||
<li>套餐<span class="tab-count">{{ course.package_count }}</span></li>
|
||||
{% endif %}
|
||||
{% if show_tab_consults == 1 %}
|
||||
<li>咨询<span class="tab-count consult-count">{{ course.consult_count }}</span></li>
|
||||
<li>咨询<span class="tab-count">{{ course.consult_count }}</span></li>
|
||||
{% endif %}
|
||||
{% if show_tab_reviews == 1 %}
|
||||
<li>评价<span class="tab-count review-count">{{ course.review_count }}</span></li>
|
||||
<li>评价<span class="tab-count">{{ course.review_count }}</span></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
<div class="layui-tab-content">
|
||||
<div class="layui-tab-item layui-show">
|
||||
<div class="course-details">{{ course.details }}</div>
|
||||
</div>
|
||||
<div class="layui-tab-item">
|
||||
{{ partial('course/show_chapters') }}
|
||||
</div>
|
||||
{% if show_tab_chapters == 1 %}
|
||||
{% set chapters_url = url({'for':'web.course.chapters','id':course.id}) %}
|
||||
<div class="layui-tab-item" id="tab-chapters" data-url="{{ chapters_url }}"></div>
|
||||
{% endif %}
|
||||
{% if show_tab_packages == 1 %}
|
||||
{% set packages_url = url({'for':'web.course.packages','id':course.id}) %}
|
||||
<div class="layui-tab-item" id="tab-packages" data-url="{{ packages_url }}"></div>
|
||||
@ -71,7 +75,10 @@
|
||||
|
||||
<div class="layout-sidebar">
|
||||
{{ partial('course/show_order') }}
|
||||
{{ partial('course/show_teachers') }}
|
||||
{% if show_sidebar_teachers %}
|
||||
{% set teachers_url = url({'for':'web.course.teachers','id':course.id}) %}
|
||||
<div class="sidebar" id="sidebar-teachers" data-url="{{ teachers_url }}"></div>
|
||||
{% endif %}
|
||||
{% if show_sidebar_topics %}
|
||||
{% set topics_url = url({'for':'web.course.topics','id':course.id}) %}
|
||||
<div class="sidebar" id="sidebar-topics" data-url="{{ topics_url }}"></div>
|
||||
|
@ -45,7 +45,7 @@
|
||||
</div>
|
||||
|
||||
<div class="share">
|
||||
<a href="javascript:" title="收藏" data-url="{{ favorite_url }}"><i class="layui-icon layui-icon-heart icon-heart"></i></a>
|
||||
<a href="javascript:" title="收藏" data-url="{{ favorite_url }}"><i class="layui-icon layui-icon-star icon-star"></i></a>
|
||||
<a href="javascript:" title="分享到微信" data-url="{{ qrcode_url }}"><i class="layui-icon layui-icon-login-wechat icon-wechat"></i></a>
|
||||
<a href="javascript:" title="分享到QQ空间"><i class="layui-icon layui-icon-login-qq icon-qq"></i></a>
|
||||
<a href="javascript:" title="分享到微博"><i class="layui-icon layui-icon-login-weibo icon-weibo"></i></a>
|
||||
|
@ -1,30 +1,19 @@
|
||||
{% if course.me.owned == 0 and course.market_price > 0 %}
|
||||
<div class="sidebar-order wrap">
|
||||
<div class="order">
|
||||
{% set order_url = url({'for':'web.order.confirm'},{'item_id':course.id,'item_type':'course'}) %}
|
||||
<a class="layui-btn layui-btn-fluid layui-bg-red" href="{{ order_url }}">立即购买</a>
|
||||
</div>
|
||||
<div class="consult">
|
||||
<a class="layui-btn layui-btn-fluid layui-bg-blue" href="javascript:">课程咨询</a>
|
||||
</div>
|
||||
{% set order_url = url({'for':'web.order.confirm'},{'item_id':course.id,'item_type':'course'}) %}
|
||||
<a class="layui-btn layui-btn-fluid layui-bg-red btn-buy" href="javascript:" data-url="{{ order_url }}">立即购买</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% set rating_url = url({'for':'web.course.rating','id':course.id}) %}
|
||||
|
||||
<div class="sidebar-rating wrap">
|
||||
<a class="layui-btn layui-btn-fluid layui-bg-green rating-btn" href="javascript:" data-url="{{ rating_url }}">课程评价</a>
|
||||
</div>
|
||||
|
||||
{% if course.market_price == 0 %}
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header">赞赏支持</div>
|
||||
<div class="layui-card-body">
|
||||
<div class="sidebar-order">
|
||||
{% for option in reward_options %}
|
||||
{% set item_id = [course.id,option.id]|join('-') %}
|
||||
{% for reward in rewards %}
|
||||
{% set item_id = [course.id,reward.id]|join('-') %}
|
||||
{% set order_url = url({'for':'web.order.confirm'},{'item_id':item_id,'item_type':'reward'}) %}
|
||||
<a class="layui-btn layui-btn-xs reward-btn" href="{{ order_url }}">{{ option.title }}</a>
|
||||
<a class="layui-btn layui-btn-xs btn-reward" href="javascript:" data-url="{{ order_url }}">{{ reward.title }}</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
|
@ -3,13 +3,11 @@
|
||||
{% block content %}
|
||||
|
||||
<div class="im-search-wrap">
|
||||
<div class="im-search">
|
||||
<form class="layui-form" method="get" action="{{ url({'for':'web.im.search'}) }}">
|
||||
<input class="layui-input" type="text" name="query" placeholder="请输入关键字...">
|
||||
<button class="layui-hide" type="submit" lay-submit="true" lay-filter="im_search">搜索</button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="find-tab">
|
||||
<form class="layui-form im-search-form" method="get" action="{{ url({'for':'web.im.search'}) }}">
|
||||
<input class="layui-input" type="text" name="query" placeholder="请输入关键字...">
|
||||
<button class="layui-hide" type="submit" lay-submit="true" lay-filter="im_search">搜索</button>
|
||||
</form>
|
||||
<div class="im-search-tab">
|
||||
<div class="layui-tab layui-tab-brief user-tab">
|
||||
<ul class="layui-tab-title">
|
||||
<li class="layui-this">成员</li>
|
||||
|
@ -4,7 +4,7 @@
|
||||
{% for item in pager.items %}
|
||||
<div class="layui-col-md2">
|
||||
<div class="user-card">
|
||||
{% if item.vip == 0 %}
|
||||
{% if item.vip == 1 %}
|
||||
<span class="vip">会员</span>
|
||||
{% endif %}
|
||||
<div class="avatar">
|
||||
|
@ -2,16 +2,17 @@
|
||||
|
||||
{% set item_type = item.item_type %}
|
||||
{% set item_info = item.item_info %}
|
||||
{% set sender = item_info.sender %}
|
||||
{% set sender_url = url({'for':'web.user.show','id':sender.id}) %}
|
||||
|
||||
{% if item_type == '1' %}
|
||||
{% set sender = item_info.sender %}
|
||||
{% set group = item_info.group %}
|
||||
{% set remark = item_info.remark ? '附言:' ~ item_info.remark : '' %}
|
||||
<li data-id="{{ item.id }}">
|
||||
<a href="#" target="_blank"><img src="{{ sender.avatar }}" class="layui-circle layim-msgbox-avatar"></a>
|
||||
<a href="{{ sender_url }}" target="_blank"><img src="{{ sender.avatar }}" class="layui-circle layim-msgbox-avatar"></a>
|
||||
<p class="layim-msgbox-user" data-id="{{ sender.id }}" data-name="{{ sender.name }}" data-avatar="{{ sender.avatar }}" data-group="{{ group.id }}">
|
||||
<a href="#" target="_blank">{{ sender.name }}</a>
|
||||
<span>{{ date('Y-m-d H:i:s',item.create_time) }}</span>
|
||||
<a href="{{ sender_url }}" target="_blank">{{ sender.name }}</a>
|
||||
<span>{{ item.create_time|time_ago }}</span>
|
||||
</p>
|
||||
<p class="layim-msgbox-content">申请添加你为好友 <span>{{ remark }}</span></p>
|
||||
<p class="layim-msgbox-btn">
|
||||
@ -27,19 +28,27 @@
|
||||
</li>
|
||||
{% elseif item_type == '2' %}
|
||||
<li class="layim-msgbox-system">
|
||||
<p><em>系统:</em>{{ item_info.sender.name }} 接受了你的好友申请<span>{{ date('Y-m-d H:i:s',item.create_time) }}</span></p>
|
||||
<p>
|
||||
<em>系统:</em>
|
||||
<a href="{{ sender_url }}" target="_blank">{{ sender.name }}</a>
|
||||
接受了你的好友申请<span>{{ item.create_time|time_ago }}</span>
|
||||
</p>
|
||||
</li>
|
||||
{% elseif item_type == '3' %}
|
||||
<li class="layim-msgbox-system">
|
||||
<p><em>系统:</em>{{ item_info.sender.name }} 拒绝了你的好友申请<span>{{ date('Y-m-d H:i:s',item.create_time) }}</span></p>
|
||||
<p>
|
||||
<em>系统:</em>
|
||||
<a href="{{ sender_url }}" target="_blank">{{ sender.name }}</a>
|
||||
拒绝了你的好友申请<span>{{ item.create_time|time_ago }}</span>
|
||||
</p>
|
||||
</li>
|
||||
{% elseif item_type == '4' %}
|
||||
{% set remark = item_info.remark ? '附言:' ~ item_info.remark : '' %}
|
||||
<li data-id="{{ item.id }}">
|
||||
<a href="#" target="_blank"><img src="{{ item_info.sender.avatar }}" class="layui-circle layim-msgbox-avatar"></a>
|
||||
<a href="{{ sender_url }}" target="_blank"><img src="{{ sender.avatar }}" class="layui-circle layim-msgbox-avatar"></a>
|
||||
<p class="layim-msgbox-user">
|
||||
<a href="#" target="_blank">{{ item_info.sender.name }}</a>
|
||||
<span>{{ date('Y-m-d H:i:s',item.create_time) }}</span>
|
||||
<a href="{{ sender_url }}" target="_blank">{{ sender.name }}</a>
|
||||
<span>{{ item.create_time|time_ago }}</span>
|
||||
</p>
|
||||
<p class="layim-msgbox-content">申请加入群组 <span>{{ remark }}</span></p>
|
||||
<p class="layim-msgbox-btn">
|
||||
@ -55,11 +64,19 @@
|
||||
</li>
|
||||
{% elseif item_type == '5' %}
|
||||
<li class="layim-msgbox-system">
|
||||
<p><em>系统:</em>{{ item_info.sender.name }} 接受了你的入群申请<span>{{ date('Y-m-d H:i:s',item.create_time) }}</span></p>
|
||||
<p>
|
||||
<em>系统:</em>
|
||||
<a href="{{ sender_url }}" target="_blank">{{ sender.name }}</a>
|
||||
接受了你的入群申请<span>{{ item.create_time|time_ago }}</span>
|
||||
</p>
|
||||
</li>
|
||||
{% elseif item_type == '6' %}
|
||||
<li class="layim-msgbox-system">
|
||||
<p><em>系统:</em>{{ item_info.sender.name }} 拒绝了你的入群申请<span>{{ date('Y-m-d H:i:s',item.create_time) }}</span></p>
|
||||
<p>
|
||||
<em>系统:</em>
|
||||
<a href="{{ sender_url }}" target="_blank">{{ sender.name }}</a>
|
||||
拒绝了你的入群申请<span>{{ item.create_time|time_ago }}</span>
|
||||
</p>
|
||||
</li>
|
||||
{% endif %}
|
||||
{%- endmacro %}
|
||||
|
@ -4,7 +4,7 @@
|
||||
{% for item in pager.items %}
|
||||
<div class="layui-col-md2">
|
||||
<div class="user-card">
|
||||
{% if item.vip == 0 %}
|
||||
{% if item.vip == 1 %}
|
||||
<span class="vip">会员</span>
|
||||
{% endif %}
|
||||
<div class="avatar">
|
@ -228,6 +228,29 @@ function kg_human_number($number)
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化之前时间
|
||||
*
|
||||
* @param int $time
|
||||
* @return string
|
||||
*/
|
||||
function kg_time_ago($time)
|
||||
{
|
||||
$diff = time() - $time;
|
||||
|
||||
if ($diff > 7 * 86400) {
|
||||
return date('Y-m-d', $time);
|
||||
} elseif ($diff > 86400) {
|
||||
return floor($diff / 86400) . '天前';
|
||||
} elseif ($diff > 3600) {
|
||||
return floor($diff / 3600) . '小时前';
|
||||
} elseif ($diff > 60) {
|
||||
return floor($diff / 60) . '分钟前';
|
||||
} else {
|
||||
return $diff . '秒前';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 播放时长
|
||||
*
|
||||
|
@ -5,6 +5,7 @@ namespace App\Library\Paginator\Adapter;
|
||||
use App\Library\Paginator\Query;
|
||||
use Phalcon\Paginator\Adapter as PaginatorAdapter;
|
||||
use Phalcon\Paginator\Exception as PaginatorException;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -65,7 +66,7 @@ class XunSearch extends PaginatorAdapter
|
||||
$this->params = $query->getParams();
|
||||
}
|
||||
|
||||
public function paginate()
|
||||
public function paginate(): stdClass
|
||||
{
|
||||
/**
|
||||
* @var \XS $xs
|
||||
@ -102,7 +103,7 @@ class XunSearch extends PaginatorAdapter
|
||||
|
||||
$totalPages = ceil($totalCount / $limit);
|
||||
|
||||
$pager = new \stdClass();
|
||||
$pager = new stdClass();
|
||||
|
||||
$pager->first = 1;
|
||||
$pager->previous = $page > 1 ? $page - 1 : 1;
|
||||
@ -120,7 +121,7 @@ class XunSearch extends PaginatorAdapter
|
||||
return $pager;
|
||||
}
|
||||
|
||||
public function getPaginate()
|
||||
public function getPaginate(): stdClass
|
||||
{
|
||||
return $this->paginate();
|
||||
}
|
||||
|
@ -49,6 +49,13 @@ class Consult extends Model
|
||||
*/
|
||||
public $like_count;
|
||||
|
||||
/**
|
||||
* 优先级
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $priority;
|
||||
|
||||
/**
|
||||
* 私密标识
|
||||
*
|
||||
|
@ -77,6 +77,13 @@ class Review extends Model
|
||||
*/
|
||||
public $like_count;
|
||||
|
||||
/**
|
||||
* 匿名标识
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $anonymous;
|
||||
|
||||
/**
|
||||
* 发布标识
|
||||
*
|
||||
|
@ -66,6 +66,10 @@ class Volt extends Provider
|
||||
return 'kg_human_number(' . $resolvedArgs . ')';
|
||||
});
|
||||
|
||||
$compiler->addFilter('time_ago', function ($resolvedArgs) {
|
||||
return 'kg_time_ago(' . $resolvedArgs . ')';
|
||||
});
|
||||
|
||||
return $volt;
|
||||
});
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ class Category extends Repository
|
||||
|
||||
public function countChildCategories($categoryId)
|
||||
{
|
||||
return CategoryModel::count([
|
||||
return (int)CategoryModel::count([
|
||||
'conditions' => 'parent_id = :parent_id: AND published = 1',
|
||||
'bind' => ['parent_id' => $categoryId],
|
||||
]);
|
||||
@ -98,8 +98,7 @@ class Category extends Repository
|
||||
|
||||
public function countCourses($categoryId)
|
||||
{
|
||||
$phql = 'SELECT COUNT(*) AS total FROM %s cc JOIN %s c ON cc.course_id = c.id
|
||||
WHERE cc.category_id = :category_id: AND c.published = 1 AND c.published = 1';
|
||||
$phql = 'SELECT COUNT(*) AS total FROM %s cc JOIN %s c ON cc.course_id = c.id WHERE cc.category_id = :category_id: AND c.published = 1';
|
||||
|
||||
$phql = sprintf($phql, CourseCategoryModel::class, CourseModel::class);
|
||||
|
||||
@ -107,7 +106,7 @@ class Category extends Repository
|
||||
|
||||
$record = $this->modelsManager->executeQuery($phql, $bind)->getFirst();
|
||||
|
||||
return $record['total'];
|
||||
return (int)$record['total'];
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ class Chapter extends Repository
|
||||
|
||||
public function maxChapterPriority($courseId)
|
||||
{
|
||||
return ChapterModel::maximum([
|
||||
return (int)ChapterModel::maximum([
|
||||
'column' => 'priority',
|
||||
'conditions' => 'course_id = :course_id: AND parent_id = 0',
|
||||
'bind' => ['course_id' => $courseId],
|
||||
@ -130,7 +130,7 @@ class Chapter extends Repository
|
||||
|
||||
public function maxLessonPriority($chapterId)
|
||||
{
|
||||
return ChapterModel::maximum([
|
||||
return (int)ChapterModel::maximum([
|
||||
'column' => 'priority',
|
||||
'conditions' => 'parent_id = :parent_id:',
|
||||
'bind' => ['parent_id' => $chapterId],
|
||||
@ -139,7 +139,7 @@ class Chapter extends Repository
|
||||
|
||||
public function countLessons($chapterId)
|
||||
{
|
||||
return ChapterModel::count([
|
||||
return (int)ChapterModel::count([
|
||||
'conditions' => 'parent_id = :chapter_id: AND deleted = 0',
|
||||
'bind' => ['chapter_id' => $chapterId],
|
||||
]);
|
||||
@ -147,7 +147,7 @@ class Chapter extends Repository
|
||||
|
||||
public function countUsers($chapterId)
|
||||
{
|
||||
return ChapterUserModel::count([
|
||||
return (int)ChapterUserModel::count([
|
||||
'conditions' => 'chapter_id = :chapter_id: AND deleted = 0',
|
||||
'bind' => ['chapter_id' => $chapterId],
|
||||
]);
|
||||
@ -155,7 +155,7 @@ class Chapter extends Repository
|
||||
|
||||
public function countComments($chapterId)
|
||||
{
|
||||
return CommentModel::count([
|
||||
return (int)CommentModel::count([
|
||||
'conditions' => 'chapter_id = :chapter_id: AND deleted = 0',
|
||||
'bind' => ['chapter_id' => $chapterId],
|
||||
]);
|
||||
@ -163,7 +163,7 @@ class Chapter extends Repository
|
||||
|
||||
public function countLikes($chapterId)
|
||||
{
|
||||
return ChapterLikeModel::count([
|
||||
return (int)ChapterLikeModel::count([
|
||||
'conditions' => 'chapter_id = :chapter_id: AND deleted = 0',
|
||||
'bind' => ['chapter_id' => $chapterId],
|
||||
]);
|
||||
|
@ -87,9 +87,14 @@ class Comment extends Repository
|
||||
->execute();
|
||||
}
|
||||
|
||||
public function countComments()
|
||||
{
|
||||
return (int)CommentModel::count(['conditions' => 'deleted = 0']);
|
||||
}
|
||||
|
||||
public function countReplies($commentId)
|
||||
{
|
||||
return CommentModel::count([
|
||||
return (int)CommentModel::count([
|
||||
'conditions' => 'parent_id = :parent_id: AND deleted = 0',
|
||||
'bind' => ['parent_id' => $commentId],
|
||||
]);
|
||||
@ -97,7 +102,7 @@ class Comment extends Repository
|
||||
|
||||
public function countLikes($commentId)
|
||||
{
|
||||
return CommentLikeModel::count([
|
||||
return (int)CommentLikeModel::count([
|
||||
'conditions' => 'comment_id = :comment_id: AND deleted = 0',
|
||||
'bind' => ['comment_id' => $commentId],
|
||||
]);
|
||||
|
@ -45,6 +45,9 @@ class Consult extends Repository
|
||||
}
|
||||
|
||||
switch ($sort) {
|
||||
case 'priority':
|
||||
$orderBy = 'priority ASC, id DESC';
|
||||
break;
|
||||
default:
|
||||
$orderBy = 'id DESC';
|
||||
break;
|
||||
@ -83,9 +86,14 @@ class Consult extends Repository
|
||||
->execute();
|
||||
}
|
||||
|
||||
public function countConsults()
|
||||
{
|
||||
return (int)ConsultModel::count(['conditions' => 'deleted = 0']);
|
||||
}
|
||||
|
||||
public function countLikes($consultId)
|
||||
{
|
||||
return ConsultLikeModel::count([
|
||||
return (int)ConsultLikeModel::count([
|
||||
'conditions' => 'consult_id = :consult_id: AND deleted = 0',
|
||||
'bind' => ['consult_id' => $consultId],
|
||||
]);
|
||||
|
@ -245,9 +245,14 @@ class Course extends Repository
|
||||
->execute();
|
||||
}
|
||||
|
||||
public function countCourses()
|
||||
{
|
||||
return (int)CourseModel::count(['conditions' => 'deleted = 0']);
|
||||
}
|
||||
|
||||
public function countLessons($courseId)
|
||||
{
|
||||
return ChapterModel::count([
|
||||
return (int)ChapterModel::count([
|
||||
'conditions' => 'course_id = :course_id: AND parent_id > 0 AND deleted = 0',
|
||||
'bind' => ['course_id' => $courseId],
|
||||
]);
|
||||
@ -255,7 +260,7 @@ class Course extends Repository
|
||||
|
||||
public function countPackages($courseId)
|
||||
{
|
||||
return CoursePackageModel::count([
|
||||
return (int)CoursePackageModel::count([
|
||||
'conditions' => 'course_id = :course_id:',
|
||||
'bind' => ['course_id' => $courseId],
|
||||
]);
|
||||
@ -263,7 +268,7 @@ class Course extends Repository
|
||||
|
||||
public function countUsers($courseId)
|
||||
{
|
||||
return CourseUserModel::count([
|
||||
return (int)CourseUserModel::count([
|
||||
'conditions' => 'course_id = :course_id: AND deleted = 0',
|
||||
'bind' => ['course_id' => $courseId],
|
||||
]);
|
||||
@ -271,7 +276,7 @@ class Course extends Repository
|
||||
|
||||
public function countConsults($courseId)
|
||||
{
|
||||
return ConsultModel::count([
|
||||
return (int)ConsultModel::count([
|
||||
'conditions' => 'course_id = :course_id: AND published = 1',
|
||||
'bind' => ['course_id' => $courseId],
|
||||
]);
|
||||
@ -279,7 +284,7 @@ class Course extends Repository
|
||||
|
||||
public function countReviews($courseId)
|
||||
{
|
||||
return ReviewModel::count([
|
||||
return (int)ReviewModel::count([
|
||||
'conditions' => 'course_id = :course_id: AND published = 1',
|
||||
'bind' => ['course_id' => $courseId],
|
||||
]);
|
||||
@ -287,7 +292,7 @@ class Course extends Repository
|
||||
|
||||
public function countComments($courseId)
|
||||
{
|
||||
return CommentModel::count([
|
||||
return (int)CommentModel::count([
|
||||
'conditions' => 'course_id = :course_id: AND published = 1',
|
||||
'bind' => ['course_id' => $courseId],
|
||||
]);
|
||||
@ -295,15 +300,15 @@ class Course extends Repository
|
||||
|
||||
public function countFavorites($courseId)
|
||||
{
|
||||
return CourseFavoriteModel::count([
|
||||
'conditions' => 'course_id = :course_id: AND published = 1',
|
||||
return (int)CourseFavoriteModel::count([
|
||||
'conditions' => 'course_id = :course_id: AND deleted = 0',
|
||||
'bind' => ['course_id' => $courseId],
|
||||
]);
|
||||
}
|
||||
|
||||
public function averageRating($courseId)
|
||||
{
|
||||
return ReviewModel::average([
|
||||
return (int)ReviewModel::average([
|
||||
'column' => 'rating',
|
||||
'conditions' => 'course_id = :course_id: AND published = 1',
|
||||
'bind' => ['course_id' => $courseId],
|
||||
@ -318,11 +323,13 @@ class Course extends Repository
|
||||
|
||||
$rows = $repo->findByCategoryIds($categoryIds);
|
||||
|
||||
if ($rows->count() == 0) {
|
||||
return [];
|
||||
$result = [];
|
||||
|
||||
if ($rows->count() > 0) {
|
||||
$result = kg_array_column($rows->toArray(), 'course_id');
|
||||
}
|
||||
|
||||
return kg_array_column($rows->toArray(), 'course_id');
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function getTeacherCourseIds($teacherId)
|
||||
@ -333,11 +340,13 @@ class Course extends Repository
|
||||
|
||||
$rows = $repo->findByTeacherIds($teacherIds);
|
||||
|
||||
$result = [];
|
||||
|
||||
if ($rows->count() == 0) {
|
||||
return [];
|
||||
$result = kg_array_column($rows->toArray(), 'course_id');
|
||||
}
|
||||
|
||||
return kg_array_column($rows->toArray(), 'course_id');
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ class CourseCategory extends Repository
|
||||
* @param array $categoryIds
|
||||
* @return ResultsetInterface|Resultset|CourseCategoryModel[]
|
||||
*/
|
||||
public function findByCategoryIds(array $categoryIds)
|
||||
public function findByCategoryIds($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(array $courseIds)
|
||||
public function findByCourseIds($courseIds)
|
||||
{
|
||||
return CourseCategoryModel::query()
|
||||
->inWhere('course_id', $courseIds)
|
||||
|
@ -136,7 +136,7 @@ class CourseUser extends Repository
|
||||
* @param array $teacherIds
|
||||
* @return ResultsetInterface|Resultset|CourseUserModel[]
|
||||
*/
|
||||
public function findByTeacherIds(array $teacherIds)
|
||||
public function findByTeacherIds($teacherIds)
|
||||
{
|
||||
$roleType = CourseUserModel::ROLE_TEACHER;
|
||||
|
||||
|
@ -121,4 +121,9 @@ class Danmu extends Repository
|
||||
return $query->execute();
|
||||
}
|
||||
|
||||
public function countDanmus()
|
||||
{
|
||||
return (int)DanmuModel::count(['conditions' => 'deleted = 0']);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -76,15 +76,22 @@ class ImFriendGroup extends Repository
|
||||
* @param int $groupId
|
||||
* @return ResultsetInterface|Resultset|UserModel[]
|
||||
*/
|
||||
public function findGroupUsers($groupId)
|
||||
public function findUsers($groupId)
|
||||
{
|
||||
return $this->modelsManager->createBuilder()
|
||||
->columns('u.*')
|
||||
->addFrom(UserModel::class, 'u')
|
||||
->join(ImFriendUserModel::class, 'u.id = f.user_id', 'f')
|
||||
->where('f.group_id = :group_id:', ['group_id' => $groupId])
|
||||
->andWhere('u.deleted = 0')
|
||||
->join(ImFriendUserModel::class, 'u.id = fu.user_id', 'fu')
|
||||
->where('fu.group_id = :group_id:', ['group_id' => $groupId])
|
||||
->getQuery()->execute();
|
||||
}
|
||||
|
||||
public function countUsers($groupId)
|
||||
{
|
||||
return (int)ImFriendUserModel::count([
|
||||
'conditions' => 'group_id = :group_id: AND blocked = 0',
|
||||
'bind' => ['group_id' => $groupId],
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -79,15 +79,27 @@ class ImGroup extends Repository
|
||||
* @param int $groupId
|
||||
* @return ResultsetInterface|Resultset|ImUserModel[]
|
||||
*/
|
||||
public function findGroupUsers($groupId)
|
||||
public function findUsers($groupId)
|
||||
{
|
||||
return $this->modelsManager->createBuilder()
|
||||
->columns('u.*')
|
||||
->addFrom(ImUserModel::class, 'u')
|
||||
->join(ImGroupUserModel::class, 'u.id = gu.user_id', 'gu')
|
||||
->where('gu.group_id = :group_id:', ['group_id' => $groupId])
|
||||
->andWhere('u.deleted = 0')
|
||||
->getQuery()->execute();
|
||||
}
|
||||
|
||||
public function countGroups()
|
||||
{
|
||||
return (int)ImGroupModel::count(['conditions' => 'deleted = 0']);
|
||||
}
|
||||
|
||||
public function countUsers($groupId)
|
||||
{
|
||||
return (int)ImGroupUserModel::count([
|
||||
'conditions' => 'group_id = :group_id: AND blocked = 0',
|
||||
'bind' => ['group_id' => $groupId],
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -9,15 +9,15 @@ class ImGroupUser extends Repository
|
||||
{
|
||||
|
||||
/**
|
||||
* @param int $userId
|
||||
* @param int $groupId
|
||||
* @param int $userId
|
||||
* @return ImGroupUserModel|Model|bool
|
||||
*/
|
||||
public function findGroupUser($userId, $groupId)
|
||||
public function findGroupUser($groupId, $userId)
|
||||
{
|
||||
return ImGroupUserModel::findFirst([
|
||||
'conditions' => 'user_id = ?1 AND group_id = ?2',
|
||||
'bind' => [1 => $userId, 2 => $groupId],
|
||||
'conditions' => 'group_id = ?1 AND user_id = ?2',
|
||||
'bind' => [1 => $groupId, 2 => $userId],
|
||||
'order' => 'id DESC',
|
||||
]);
|
||||
}
|
||||
|
@ -73,8 +73,4 @@ class ImSystemMessage extends Repository
|
||||
->execute();
|
||||
}
|
||||
|
||||
public function findUserMessage($userId, $itemType)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ class ImUser extends Repository
|
||||
* @param int $userId
|
||||
* @return ResultsetInterface|Resultset|ImFriendUserModel[]
|
||||
*/
|
||||
public function findImFriendUsers($userId)
|
||||
public function findFriendUsers($userId)
|
||||
{
|
||||
return ImFriendUserModel::query()
|
||||
->where('user_id = :user_id:', ['user_id' => $userId])
|
||||
@ -91,7 +91,7 @@ class ImUser extends Repository
|
||||
* @param int $userId
|
||||
* @return ResultsetInterface|Resultset|ImFriendGroupModel[]
|
||||
*/
|
||||
public function findImFriendGroups($userId)
|
||||
public function findFriendGroups($userId)
|
||||
{
|
||||
return ImFriendGroupModel::query()
|
||||
->where('user_id = :user_id:', ['user_id' => $userId])
|
||||
@ -103,7 +103,7 @@ class ImUser extends Repository
|
||||
* @param int $userId
|
||||
* @return ResultsetInterface|Resultset|ImGroupModel[]
|
||||
*/
|
||||
public function findImGroups($userId)
|
||||
public function findGroups($userId)
|
||||
{
|
||||
return $this->modelsManager->createBuilder()
|
||||
->columns('g.*')
|
||||
@ -119,7 +119,7 @@ class ImUser extends Repository
|
||||
* @param int $userId
|
||||
* @return ResultsetInterface|Resultset|ImFriendMessageModel[]
|
||||
*/
|
||||
public function findUnreadImFriendMessages($friendId, $userId)
|
||||
public function findUnreadFriendMessages($friendId, $userId)
|
||||
{
|
||||
return ImFriendMessageModel::find([
|
||||
'conditions' => 'sender_id = ?1 AND receiver_id = ?2 AND viewed = ?3',
|
||||
@ -130,9 +130,9 @@ class ImUser extends Repository
|
||||
/**
|
||||
* @param int $userId
|
||||
* @param int $itemType
|
||||
* @return Model|bool|ImSystemMessageModel
|
||||
* @return ImSystemMessageModel|Model|bool
|
||||
*/
|
||||
public function findImSystemMessage($userId, $itemType)
|
||||
public function findSystemMessage($userId, $itemType)
|
||||
{
|
||||
return ImSystemMessageModel::findFirst([
|
||||
'conditions' => 'receiver_id = ?1 AND item_type = ?2',
|
||||
@ -145,7 +145,7 @@ class ImUser extends Repository
|
||||
* @param int $userId
|
||||
* @return ResultsetInterface|Resultset|ImFriendMessageModel[]
|
||||
*/
|
||||
public function findUnreadImSystemMessages($userId)
|
||||
public function findUnreadSystemMessages($userId)
|
||||
{
|
||||
return ImSystemMessageModel::find([
|
||||
'conditions' => 'receiver_id = ?1 AND viewed = ?2',
|
||||
@ -153,9 +153,9 @@ class ImUser extends Repository
|
||||
]);
|
||||
}
|
||||
|
||||
public function countUnreadImSystemMessages($userId)
|
||||
public function countUnreadSystemMessages($userId)
|
||||
{
|
||||
return ImSystemMessageModel::count([
|
||||
return (int)ImSystemMessageModel::count([
|
||||
'conditions' => 'receiver_id = ?1 AND viewed = ?2',
|
||||
'bind' => [1 => $userId, 2 => 0],
|
||||
]);
|
||||
|
@ -69,8 +69,8 @@ class Nav extends Repository
|
||||
|
||||
public function countChildNavs($navId)
|
||||
{
|
||||
return NavModel::count([
|
||||
'conditions' => 'parent_id = :parent_id: AND published = 1 AND deleted = 0',
|
||||
return (int)NavModel::count([
|
||||
'conditions' => 'parent_id = :parent_id: AND published = 1',
|
||||
'bind' => ['parent_id' => $navId],
|
||||
]);
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ class Order extends Repository
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $orderId
|
||||
* @param int $orderId
|
||||
* @return ResultsetInterface|Resultset|OrderStatusModel[]
|
||||
*/
|
||||
public function findStatusHistory($orderId)
|
||||
@ -202,4 +202,9 @@ class Order extends Repository
|
||||
]);
|
||||
}
|
||||
|
||||
public function countOrders()
|
||||
{
|
||||
return (int)OrderModel::count(['conditions' => 'deleted = 0']);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ class Package extends Repository
|
||||
|
||||
public function countCourses($packageId)
|
||||
{
|
||||
return CoursePackageModel::count([
|
||||
return (int)CoursePackageModel::count([
|
||||
'conditions' => 'package_id = :package_id:',
|
||||
'bind' => ['package_id' => $packageId],
|
||||
]);
|
||||
|
@ -36,7 +36,7 @@ class RefreshToken extends Repository
|
||||
|
||||
public function countByUserId($userId)
|
||||
{
|
||||
return RefreshTokenModel::count([
|
||||
return (int)RefreshTokenModel::count([
|
||||
'conditions' => 'user_id = :user_id: AND deleted = 0',
|
||||
'bind' => ['user_id' => $userId],
|
||||
]);
|
||||
|
@ -106,6 +106,11 @@ class Review extends Repository
|
||||
->execute();
|
||||
}
|
||||
|
||||
public function countReviews()
|
||||
{
|
||||
return (int)ReviewModel::count(['conditions' => 'deleted = 0']);
|
||||
}
|
||||
|
||||
public function countLikes($reviewId)
|
||||
{
|
||||
return ReviewLikeModel::count([
|
||||
|
@ -87,9 +87,14 @@ class Topic extends Repository
|
||||
->getQuery()->execute();
|
||||
}
|
||||
|
||||
public function countTopics()
|
||||
{
|
||||
return (int)TopicModel::count(['conditions' => 'deleted = 0']);
|
||||
}
|
||||
|
||||
public function countCourses($topicId)
|
||||
{
|
||||
return CourseTopicModel::count([
|
||||
return (int)CourseTopicModel::count([
|
||||
'conditions' => 'topic_id = :topic_id:',
|
||||
'bind' => ['topic_id' => $topicId],
|
||||
]);
|
||||
|
@ -111,4 +111,9 @@ class User extends Repository
|
||||
->execute();
|
||||
}
|
||||
|
||||
public function countUsers()
|
||||
{
|
||||
return (int)UserModel::count(['conditions' => 'deleted = 0']);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -180,8 +180,10 @@ class Chapter extends Validator
|
||||
|
||||
$like = $repo->findChapterLike($chapterId, $userId);
|
||||
|
||||
if ($like && time() - $like->create_time > 5 * 60) {
|
||||
throw new BadRequestException('chapter.has_liked');
|
||||
if ($like) {
|
||||
if ($like->deleted == 0 && time() - $like->create_time > 5 * 60) {
|
||||
throw new BadRequestException('chapter.has_liked');
|
||||
}
|
||||
}
|
||||
|
||||
return $like;
|
||||
|
@ -82,8 +82,10 @@ class Comment extends Validator
|
||||
|
||||
$like = $repo->findCommentLike($chapterId, $userId);
|
||||
|
||||
if ($like && time() - $like->create_time > 5 * 60) {
|
||||
throw new BadRequestException('comment.has_liked');
|
||||
if ($like) {
|
||||
if ($like->deleted == 0 && time() - $like->create_time > 5 * 60) {
|
||||
throw new BadRequestException('comment.has_liked');
|
||||
}
|
||||
}
|
||||
|
||||
return $like;
|
||||
|
@ -87,8 +87,10 @@ class Consult extends Validator
|
||||
|
||||
$like = $repo->findConsultLike($chapterId, $userId);
|
||||
|
||||
if ($like && time() - $like->create_time > 5 * 60) {
|
||||
throw new BadRequestException('consult.has_liked');
|
||||
if ($like) {
|
||||
if ($like->deleted == 0 && time() - $like->create_time > 5 * 60) {
|
||||
throw new BadRequestException('consult.has_liked');
|
||||
}
|
||||
}
|
||||
|
||||
return $like;
|
||||
|
@ -249,8 +249,10 @@ class Course extends Validator
|
||||
|
||||
$favorite = $repo->findCourseFavorite($courseId, $userId);
|
||||
|
||||
if ($favorite && time() - $favorite->create_time > 5 * 60) {
|
||||
throw new BadRequestException('course.has_favorited');
|
||||
if ($favorite) {
|
||||
if ($favorite->deleted == 0 && time() - $favorite->create_time > 5 * 60) {
|
||||
throw new BadRequestException('course.has_favorited');
|
||||
}
|
||||
}
|
||||
|
||||
return $favorite;
|
||||
|
@ -35,11 +35,11 @@ class ImGroupUser extends Validator
|
||||
return $remark;
|
||||
}
|
||||
|
||||
public function checkGroupUser($userId, $groupId)
|
||||
public function checkGroupUser($groupId, $userId)
|
||||
{
|
||||
$repo = new ImGroupUserRepo();
|
||||
|
||||
$record = $repo->findGroupUser($userId, $groupId);
|
||||
$record = $repo->findGroupUser($groupId, $userId);
|
||||
|
||||
if (!$record) {
|
||||
throw new BadRequestException('im_group_user.not_found');
|
||||
@ -48,22 +48,22 @@ class ImGroupUser extends Validator
|
||||
return $record;
|
||||
}
|
||||
|
||||
public function checkIfJoined($userId, $groupId)
|
||||
public function checkIfJoined($groupId, $userId)
|
||||
{
|
||||
$repo = new ImGroupUserRepo();
|
||||
|
||||
$record = $repo->findGroupUser($userId, $groupId);
|
||||
$record = $repo->findGroupUser($groupId, $userId);
|
||||
|
||||
if ($record && $record->blocked == 0) {
|
||||
throw new BadRequestException('im_group_user.has_joined');
|
||||
}
|
||||
}
|
||||
|
||||
public function checkIfBlocked($userId, $groupId)
|
||||
public function checkIfBlocked($groupId, $userId)
|
||||
{
|
||||
$repo = new ImGroupUserRepo();
|
||||
|
||||
$record = $repo->findGroupUser($userId, $groupId);
|
||||
$record = $repo->findGroupUser($groupId, $userId);
|
||||
|
||||
if ($record && $record->blocked == 1) {
|
||||
throw new BadRequestException('im_group_user.blocked');
|
||||
|
@ -71,8 +71,10 @@ class Review extends Validator
|
||||
|
||||
$like = $repo->findReviewLike($reviewId, $userId);
|
||||
|
||||
if ($like && time() - $like->create_time > 5 * 60) {
|
||||
throw new BadRequestException('review.has_liked');
|
||||
if ($like) {
|
||||
if ($like->deleted == 0 && time() - $like->create_time > 5 * 60) {
|
||||
throw new BadRequestException('review.has_liked');
|
||||
}
|
||||
}
|
||||
|
||||
return $like;
|
||||
|
@ -17,12 +17,12 @@ layui.define(['jquery', 'element', 'layer'], function (exports) {
|
||||
});
|
||||
};
|
||||
|
||||
helper.checkLogin = function () {
|
||||
helper.checkLogin = function (callback) {
|
||||
if (window.koogua.user.id === '0') {
|
||||
layer.msg('继续操作前请登录或者注册', {icon: 2, anim: 6});
|
||||
layer.msg('继续操作前请先登录', {icon: 2, anim: 6});
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
callback();
|
||||
};
|
||||
|
||||
helper.getRequestId = function () {
|
||||
|
@ -720,11 +720,7 @@ body {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.sidebar-order .order {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.sidebar-order .reward-btn {
|
||||
.sidebar-order .btn-reward {
|
||||
width: 84px;
|
||||
margin: 5px;
|
||||
}
|
||||
@ -1013,7 +1009,6 @@ body {
|
||||
|
||||
.cart-course-card .info {
|
||||
float: left;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.cart-course-card span {
|
||||
@ -1421,10 +1416,14 @@ body {
|
||||
background-color: #f2f2f2;
|
||||
}
|
||||
|
||||
.im-search {
|
||||
.im-search-form {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.im-search-tab .layui-tab-content {
|
||||
min-height: 300px;
|
||||
}
|
||||
|
||||
.im-user-list .user-card {
|
||||
height: 150px;
|
||||
font-size: 12px;
|
||||
|
29
public/static/web/js/chapter.like.js
Normal file
29
public/static/web/js/chapter.like.js
Normal file
@ -0,0 +1,29 @@
|
||||
layui.use(['jquery', 'helper'], function () {
|
||||
|
||||
var $ = layui.jquery;
|
||||
var helper = layui.helper;
|
||||
|
||||
$('.icon-praise').on('click', function () {
|
||||
var $this = $(this);
|
||||
var $likeCount = $this.next();
|
||||
var likeCount = parseInt($likeCount.text());
|
||||
helper.checkLogin(function () {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: $this.parent().data('url'),
|
||||
success: function () {
|
||||
if ($this.hasClass('active')) {
|
||||
$this.removeClass('active');
|
||||
$likeCount.text(likeCount - 1);
|
||||
likeCount -= 1;
|
||||
} else {
|
||||
$this.addClass('active');
|
||||
$likeCount.text(likeCount + 1);
|
||||
likeCount += 1;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
@ -1,7 +1,8 @@
|
||||
layui.use(['jquery', 'layer'], function () {
|
||||
layui.use(['jquery', 'layer', 'helper'], function () {
|
||||
|
||||
var $ = layui.jquery;
|
||||
var layer = layui.layer;
|
||||
var helper = layui.helper;
|
||||
|
||||
var myShare = {
|
||||
title: $('input[name="share.title"]').val(),
|
||||
@ -10,39 +11,26 @@ layui.use(['jquery', 'layer'], function () {
|
||||
qrcode: $('input[name="share.qrcode"]').val()
|
||||
};
|
||||
|
||||
$('.icon-heart').on('click', function () {
|
||||
var $this = $(this);
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: $this.parent().data('url'),
|
||||
success: function () {
|
||||
if ($this.hasClass('active')) {
|
||||
$this.removeClass('active');
|
||||
} else {
|
||||
$this.addClass('active');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('.icon-praise').on('click', function () {
|
||||
var $this = $(this);
|
||||
var $likeCount = $this.next();
|
||||
var likeCount = parseInt($likeCount.text());
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: $this.parent().data('url'),
|
||||
success: function () {
|
||||
if ($this.hasClass('active')) {
|
||||
$this.removeClass('active');
|
||||
$likeCount.text(likeCount - 1);
|
||||
likeCount -= 1;
|
||||
} else {
|
||||
$this.addClass('active');
|
||||
$likeCount.text(likeCount + 1);
|
||||
likeCount += 1;
|
||||
helper.checkLogin(function () {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: $this.parent().data('url'),
|
||||
success: function () {
|
||||
if ($this.hasClass('active')) {
|
||||
$this.removeClass('active');
|
||||
$likeCount.text(likeCount - 1);
|
||||
likeCount -= 1;
|
||||
} else {
|
||||
$this.addClass('active');
|
||||
$likeCount.text(likeCount + 1);
|
||||
likeCount += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -4,7 +4,40 @@ layui.use(['jquery', 'layer', 'helper'], function () {
|
||||
var layer = layui.layer;
|
||||
var helper = layui.helper;
|
||||
|
||||
$('.rating-btn').on('click', function () {
|
||||
$('.icon-star').on('click', function () {
|
||||
var $this = $(this);
|
||||
helper.checkLogin(function () {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: $this.parent().data('url'),
|
||||
success: function () {
|
||||
if ($this.hasClass('layui-icon-star-fill')) {
|
||||
$this.removeClass('layui-icon-star-fill');
|
||||
$this.addClass('layui-icon-star');
|
||||
} else {
|
||||
$this.removeClass('layui-icon-star');
|
||||
$this.addClass('layui-icon-star-fill');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
$('.btn-reward').on('click', function () {
|
||||
var url = $(this).data('url');
|
||||
helper.checkLogin(function () {
|
||||
window.location.href = url;
|
||||
});
|
||||
});
|
||||
|
||||
$('.btn-buy').on('click', function () {
|
||||
var url = $(this).data('url');
|
||||
helper.checkLogin(function () {
|
||||
window.location.href = url;
|
||||
});
|
||||
});
|
||||
|
||||
$('.btn-rating').on('click', function () {
|
||||
var url = $(this).data('url');
|
||||
layer.open({
|
||||
type: 2,
|
||||
@ -18,23 +51,30 @@ layui.use(['jquery', 'layer', 'helper'], function () {
|
||||
var $this = $(this);
|
||||
var $likeCount = $this.next();
|
||||
var likeCount = parseInt($likeCount.text());
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: $this.parent().data('url'),
|
||||
success: function () {
|
||||
if ($this.hasClass('active')) {
|
||||
$this.removeClass('active');
|
||||
$likeCount.text(likeCount - 1);
|
||||
likeCount -= 1;
|
||||
} else {
|
||||
$this.addClass('active');
|
||||
$likeCount.text(likeCount + 1);
|
||||
likeCount += 1;
|
||||
helper.checkLogin(function () {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: $this.parent().data('url'),
|
||||
success: function () {
|
||||
if ($this.hasClass('active')) {
|
||||
$this.removeClass('active');
|
||||
$likeCount.text(likeCount - 1);
|
||||
likeCount -= 1;
|
||||
} else {
|
||||
$this.addClass('active');
|
||||
$likeCount.text(likeCount + 1);
|
||||
likeCount += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
if ($('#tab-chapters').length > 0) {
|
||||
var $tabChapters = $('#tab-chapters');
|
||||
helper.ajaxLoadHtml($tabChapters.data('url'), $tabChapters.attr('id'));
|
||||
}
|
||||
|
||||
if ($('#tab-packages').length > 0) {
|
||||
var $tabPackages = $('#tab-packages');
|
||||
helper.ajaxLoadHtml($tabPackages.data('url'), $tabPackages.attr('id'));
|
||||
@ -50,6 +90,11 @@ layui.use(['jquery', 'layer', 'helper'], function () {
|
||||
helper.ajaxLoadHtml($tabReviews.data('url'), $tabReviews.attr('id'));
|
||||
}
|
||||
|
||||
if ($('#sidebar-teachers').length > 0) {
|
||||
var $sdTeachers = $('#sidebar-teachers');
|
||||
helper.ajaxLoadHtml($sdTeachers.data('url'), $sdTeachers.attr('id'));
|
||||
}
|
||||
|
||||
if ($('#sidebar-topics').length > 0) {
|
||||
var $sdTopics = $('#sidebar-topics');
|
||||
helper.ajaxLoadHtml($sdTopics.data('url'), $sdTopics.attr('id'));
|
||||
|
@ -58,8 +58,8 @@ layui.use(['jquery', 'layim'], function () {
|
||||
},
|
||||
maxLength: 1000,
|
||||
find: '/im/find',
|
||||
msgbox: '/im/msg/box',
|
||||
chatLog: '/im/chat/log'
|
||||
msgbox: '/im/msgbox',
|
||||
chatLog: '/im/chatlog'
|
||||
});
|
||||
|
||||
layim.on('ready', function (options) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user