mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-07-04 16:01:35 +08:00
layui还是有很多问题的,绕开先
This commit is contained in:
parent
b374309c1f
commit
c7cc2210fb
@ -4,6 +4,7 @@ namespace App\Http\Web\Controllers;
|
|||||||
|
|
||||||
use App\Http\Web\Services\Live as LiveService;
|
use App\Http\Web\Services\Live as LiveService;
|
||||||
use App\Traits\Response as ResponseTrait;
|
use App\Traits\Response as ResponseTrait;
|
||||||
|
use Phalcon\Mvc\View;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @RoutePrefix("/live")
|
* @RoutePrefix("/live")
|
||||||
@ -18,33 +19,21 @@ class LiveController extends \Phalcon\Mvc\Controller
|
|||||||
*/
|
*/
|
||||||
public function membersAction($id)
|
public function membersAction($id)
|
||||||
{
|
{
|
||||||
$list = [
|
return $this->jsonSuccess();
|
||||||
[
|
}
|
||||||
'username' => '直飞机',
|
|
||||||
'avatar' => 'http://tp1.sinaimg.cn/5619439268/180/40030060651/1',
|
|
||||||
'status' => 'online',
|
|
||||||
'sign' => '高舍炮打的准',
|
|
||||||
'id' => 1,
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'username' => '直飞机2',
|
|
||||||
'avatar' => 'http://tp1.sinaimg.cn/5619439268/180/40030060651/1',
|
|
||||||
'status' => 'online',
|
|
||||||
'sign' => '高舍炮打的准',
|
|
||||||
'id' => 2,
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'username' => '直飞机3',
|
|
||||||
'avatar' => 'http://tp1.sinaimg.cn/5619439268/180/40030060651/1',
|
|
||||||
'status' => 'online',
|
|
||||||
'sign' => '高舍炮打的准',
|
|
||||||
'id' => 3,
|
|
||||||
],
|
|
||||||
];
|
|
||||||
|
|
||||||
$content = ['data' => ['list' => $list]];
|
/**
|
||||||
|
* @Get("/{id:[0-9]+}/stats", name="web.live.stats")
|
||||||
|
*/
|
||||||
|
public function statsAction($id)
|
||||||
|
{
|
||||||
|
$service = new LiveService();
|
||||||
|
|
||||||
return $this->jsonSuccess($content);
|
$stats = $service->getStats($id);
|
||||||
|
|
||||||
|
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
|
||||||
|
$this->view->pick('chapter/live_stats');
|
||||||
|
$this->view->setVar('stats', $stats);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2,26 +2,18 @@
|
|||||||
|
|
||||||
namespace App\Http\Web\Controllers;
|
namespace App\Http\Web\Controllers;
|
||||||
|
|
||||||
use App\Http\Web\Services\Index as IndexService;
|
/**
|
||||||
|
* @RoutePrefix("/im")
|
||||||
|
*/
|
||||||
class MessengerController extends Controller
|
class MessengerController extends Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Get("/", name="web.index")
|
* @Get("/init", name="web.index")
|
||||||
*/
|
*/
|
||||||
public function indexAction()
|
public function initAction()
|
||||||
{
|
{
|
||||||
$this->siteSeo->setKeywords($this->siteSettings['keywords']);
|
|
||||||
$this->siteSeo->setDescription($this->siteSettings['description']);
|
|
||||||
|
|
||||||
$indexService = new IndexService();
|
|
||||||
|
|
||||||
$this->view->setVar('slides', $indexService->getSlides());
|
|
||||||
$this->view->setVar('lives', $indexService->getLives());
|
|
||||||
$this->view->setVar('new_courses', $indexService->getNewCourses());
|
|
||||||
$this->view->setVar('free_courses', $indexService->getFreeCourses());
|
|
||||||
$this->view->setVar('vip_courses', $indexService->getVipCourses());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,8 @@ class TeacherController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function listAction()
|
public function listAction()
|
||||||
{
|
{
|
||||||
|
$_REQUEST['limit'] = 12;
|
||||||
|
|
||||||
$service = new TeacherListService();
|
$service = new TeacherListService();
|
||||||
|
|
||||||
$pager = $service->handle();
|
$pager = $service->handle();
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Http\Web\Services;
|
namespace App\Http\Web\Services;
|
||||||
|
|
||||||
|
use App\Repos\User as UserRepo;
|
||||||
use App\Services\Frontend\ChapterTrait;
|
use App\Services\Frontend\ChapterTrait;
|
||||||
use GatewayClient\Gateway;
|
use GatewayClient\Gateway;
|
||||||
|
|
||||||
@ -10,21 +11,44 @@ class Live extends Service
|
|||||||
|
|
||||||
use ChapterTrait;
|
use ChapterTrait;
|
||||||
|
|
||||||
public function bindUser($id)
|
public function getStats($id)
|
||||||
{
|
{
|
||||||
$chapter = $this->checkChapterCache($id);
|
$chapter = $this->checkChapterCache($id);
|
||||||
|
|
||||||
$user = $this->getCurrentUser();
|
Gateway::$registerAddress = '127.0.0.1:1238';
|
||||||
|
|
||||||
$userId = $user->id > 0 ?: $this->session->getId();
|
$groupName = $this->getGroupName($chapter->id);
|
||||||
|
|
||||||
|
$clientCount = Gateway::getClientIdCountByGroup($groupName);
|
||||||
|
$userCount = Gateway::getUidCountByGroup($groupName);
|
||||||
|
$guestCount = $clientCount - $userCount;
|
||||||
|
|
||||||
|
$userIds = Gateway::getUidListByGroup($groupName);
|
||||||
|
|
||||||
|
$users = $this->handleUsers($userIds);
|
||||||
|
|
||||||
|
return [
|
||||||
|
'user_count' => $userCount,
|
||||||
|
'guest_count' => $guestCount,
|
||||||
|
'users' => $users,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function bindUser($id)
|
||||||
|
{
|
||||||
$clientId = $this->request->getPost('client_id');
|
$clientId = $this->request->getPost('client_id');
|
||||||
|
|
||||||
|
$chapter = $this->checkChapterCache($id);
|
||||||
|
|
||||||
|
$user = $this->getCurrentUser();
|
||||||
|
|
||||||
$groupName = $this->getGroupName($chapter->id);
|
$groupName = $this->getGroupName($chapter->id);
|
||||||
|
|
||||||
Gateway::$registerAddress = '127.0.0.1:1238';
|
Gateway::$registerAddress = '127.0.0.1:1238';
|
||||||
|
|
||||||
Gateway::bindUid($clientId, $userId);
|
if ($user->id > 0) {
|
||||||
|
Gateway::bindUid($clientId, $user->id);
|
||||||
|
}
|
||||||
|
|
||||||
Gateway::joinGroup($clientId, $groupName);
|
Gateway::joinGroup($clientId, $groupName);
|
||||||
}
|
}
|
||||||
@ -33,9 +57,21 @@ class Live extends Service
|
|||||||
{
|
{
|
||||||
$chapter = $this->checkChapterCache($id);
|
$chapter = $this->checkChapterCache($id);
|
||||||
|
|
||||||
|
$user = $this->getLoginUser();
|
||||||
|
|
||||||
$from = $this->request->getPost('from');
|
$from = $this->request->getPost('from');
|
||||||
$to = $this->request->getPost('to');
|
$to = $this->request->getPost('to');
|
||||||
|
|
||||||
|
Gateway::$registerAddress = '127.0.0.1:1238';
|
||||||
|
|
||||||
|
$groupName = $this->getGroupName($chapter->id);
|
||||||
|
|
||||||
|
$excludeClientId = null;
|
||||||
|
|
||||||
|
if ($user->id == $from['id']) {
|
||||||
|
$excludeClientId = Gateway::getClientIdByUid($user->id);
|
||||||
|
}
|
||||||
|
|
||||||
$content = [
|
$content = [
|
||||||
'username' => $from['username'],
|
'username' => $from['username'],
|
||||||
'avatar' => $from['avatar'],
|
'avatar' => $from['avatar'],
|
||||||
@ -52,11 +88,36 @@ class Live extends Service
|
|||||||
'content' => $content,
|
'content' => $content,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$groupName = $this->getGroupName($chapter->id);
|
|
||||||
|
|
||||||
Gateway::$registerAddress = '127.0.0.1:1238';
|
Gateway::sendToGroup($groupName, $message, $excludeClientId);
|
||||||
|
}
|
||||||
|
|
||||||
Gateway::sendToGroup($groupName, $message);
|
protected function handleUsers($userIds)
|
||||||
|
{
|
||||||
|
if (!$userIds) return [];
|
||||||
|
|
||||||
|
$userRepo = new UserRepo();
|
||||||
|
|
||||||
|
$users = $userRepo->findByIds($userIds);
|
||||||
|
|
||||||
|
$baseUrl = kg_ci_base_url();
|
||||||
|
|
||||||
|
$result = [];
|
||||||
|
|
||||||
|
foreach ($users->toArray() as $key => $user) {
|
||||||
|
|
||||||
|
$user['avatar'] = $baseUrl . $user['avatar'];
|
||||||
|
|
||||||
|
$result[] = [
|
||||||
|
'id' => $user['id'],
|
||||||
|
'name' => $user['name'],
|
||||||
|
'title' => $user['title'],
|
||||||
|
'vip' => $user['vip'],
|
||||||
|
'avatar' => $user['avatar'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getGroupName($groupId)
|
protected function getGroupName($groupId)
|
||||||
|
65
app/Http/Web/Services/Messenger.php
Normal file
65
app/Http/Web/Services/Messenger.php
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Web\Services;
|
||||||
|
|
||||||
|
use App\Services\Frontend\ChapterTrait;
|
||||||
|
use GatewayClient\Gateway;
|
||||||
|
|
||||||
|
class Messenger extends Service
|
||||||
|
{
|
||||||
|
|
||||||
|
use ChapterTrait;
|
||||||
|
|
||||||
|
public function bindUser($id)
|
||||||
|
{
|
||||||
|
$user = $this->getCurrentUser();
|
||||||
|
|
||||||
|
$userId = $user->id > 0 ?: $this->session->getId();
|
||||||
|
|
||||||
|
$clientId = $this->request->getPost('client_id');
|
||||||
|
|
||||||
|
$groupName = $this->getGroupName($id);
|
||||||
|
|
||||||
|
Gateway::$registerAddress = '127.0.0.1:1238';
|
||||||
|
|
||||||
|
Gateway::bindUid($clientId, $userId);
|
||||||
|
|
||||||
|
Gateway::joinGroup($clientId, $groupName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function sendMessage($id)
|
||||||
|
{
|
||||||
|
$chapter = $this->checkChapterCache($id);
|
||||||
|
|
||||||
|
$from = $this->request->getPost('from');
|
||||||
|
$to = $this->request->getPost('to');
|
||||||
|
|
||||||
|
$content = [
|
||||||
|
'username' => $from['username'],
|
||||||
|
'avatar' => $from['avatar'],
|
||||||
|
'content' => $from['content'],
|
||||||
|
'fromid' => $from['id'],
|
||||||
|
'id' => $to['id'],
|
||||||
|
'type' => $to['type'],
|
||||||
|
'timestamp' => 1000 * time(),
|
||||||
|
'mine' => false,
|
||||||
|
];
|
||||||
|
|
||||||
|
$message = json_encode([
|
||||||
|
'type' => 'show_message',
|
||||||
|
'content' => $content,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$groupName = $this->getGroupName($chapter->id);
|
||||||
|
|
||||||
|
Gateway::$registerAddress = '127.0.0.1:1238';
|
||||||
|
|
||||||
|
Gateway::sendToGroup($groupName, $message);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getGroupName($groupId)
|
||||||
|
{
|
||||||
|
return "group_{$groupId}";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
17
app/Http/Web/Views/chapter/live_stats.volt
Normal file
17
app/Http/Web/Views/chapter/live_stats.volt
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<div class="layui-card">
|
||||||
|
<div class="layui-card-header">在线成员</div>
|
||||||
|
<div class="layui-card-body live-stats">
|
||||||
|
<div class="stats">
|
||||||
|
用户:<span class="count">{{ stats.user_count }}</span>
|
||||||
|
游客:<span class="count">{{ stats.guest_count }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="live-user-list">
|
||||||
|
{% for user in stats.users %}
|
||||||
|
{% set vip_flag = user.vip ? '<span class="layui-badge">vip</span>' : '' %}
|
||||||
|
<div class="live-user-card">
|
||||||
|
<div class="name">{{ user.name }} {{ vip_flag }}</div>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
@ -9,9 +9,16 @@
|
|||||||
<a><cite>{{ chapter.title }}</cite></a>
|
<a><cite>{{ chapter.title }}</cite></a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="layout-main">
|
||||||
|
<div class="layout-content">
|
||||||
<div class="live-player container">
|
<div class="live-player container">
|
||||||
<div id="player"></div>
|
<div id="player"></div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layout-sidebar">
|
||||||
|
<div id="sidebar-live-stats" data-url="{{ url({'for':'web.live.stats','id':chapter.id}) }}"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="layui-hide">
|
<div class="layui-hide">
|
||||||
<input type="hidden" name="user.id" value="{{ auth_user.id }}">
|
<input type="hidden" name="user.id" value="{{ auth_user.id }}">
|
||||||
@ -40,4 +47,17 @@
|
|||||||
|
|
||||||
{% block inline_js %}
|
{% block inline_js %}
|
||||||
|
|
||||||
|
<script>
|
||||||
|
|
||||||
|
refreshLiveStats();
|
||||||
|
|
||||||
|
setInterval('refreshLiveStats()', 60000);
|
||||||
|
|
||||||
|
function refreshLiveStats() {
|
||||||
|
var $liveStats = $('#sidebar-live-stats');
|
||||||
|
helper.ajaxLoadHtml($liveStats.attr('data-url'), $liveStats.attr('id'));
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
@ -91,33 +91,8 @@
|
|||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block inline_js %}
|
{% block include_js %}
|
||||||
|
|
||||||
<script>
|
{{ js_include('web/js/course.show.js') }}
|
||||||
if ($('#tab-packages').length > 0) {
|
|
||||||
var $tabPackages = $('#tab-packages');
|
|
||||||
helper.ajaxLoadHtml($tabPackages.attr('data-url'), $tabPackages.attr('id'));
|
|
||||||
}
|
|
||||||
if ($('#tab-consults').length > 0) {
|
|
||||||
var $tabConsults = $('#tab-consults');
|
|
||||||
helper.ajaxLoadHtml($tabConsults.attr('data-url'), $tabConsults.attr('id'));
|
|
||||||
}
|
|
||||||
if ($('#tab-reviews').length > 0) {
|
|
||||||
var $tabReviews = $('#tab-reviews');
|
|
||||||
helper.ajaxLoadHtml($tabReviews.attr('data-url'), $tabReviews.attr('id'));
|
|
||||||
}
|
|
||||||
if ($('#sidebar-topics').length > 0) {
|
|
||||||
var $sdTopics = $('#sidebar-topics');
|
|
||||||
helper.ajaxLoadHtml($sdTopics.attr('data-url'), $sdTopics.attr('id'));
|
|
||||||
}
|
|
||||||
if ($('#sidebar-recommended').length > 0) {
|
|
||||||
var $sdRecommended = $('#sidebar-recommended');
|
|
||||||
helper.ajaxLoadHtml($sdRecommended.attr('data-url'), $sdRecommended.attr('id'));
|
|
||||||
}
|
|
||||||
if ($('#sidebar-related').length > 0) {
|
|
||||||
var $sdRelated = $('#sidebar-related');
|
|
||||||
helper.ajaxLoadHtml($sdRelated.attr('data-url'), $sdRelated.attr('id'));
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
@ -28,6 +28,7 @@
|
|||||||
<img src="{{ course.cover }}!cover_270" alt="{{ course.title|e }}" title="{{ course.title|e }}">
|
<img src="{{ course.cover }}!cover_270" alt="{{ course.title|e }}" title="{{ course.title|e }}">
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="info">
|
||||||
<div class="title layui-elip">
|
<div class="title layui-elip">
|
||||||
<a href="{{ course_url }}" title="{{ course.title|e }}">{{ course.title }}</a>
|
<a href="{{ course_url }}" title="{{ course.title|e }}">{{ course.title }}</a>
|
||||||
</div>
|
</div>
|
||||||
@ -54,6 +55,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
{%- endmacro %}
|
{%- endmacro %}
|
||||||
|
|
||||||
{%- macro sidebar_course_card(course) %}
|
{%- macro sidebar_course_card(course) %}
|
||||||
@ -90,6 +92,7 @@
|
|||||||
<img src="{{ item.course.cover }}!cover_270" alt="{{ course_title }}">
|
<img src="{{ item.course.cover }}!cover_270" alt="{{ course_title }}">
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="info">
|
||||||
<div class="title layui-elip">
|
<div class="title layui-elip">
|
||||||
<a href="{{ course_url }}" title="{{ course_title }}">{{ course_title }}</a>
|
<a href="{{ course_url }}" title="{{ course_title }}">{{ course_title }}</a>
|
||||||
</div>
|
</div>
|
||||||
@ -100,4 +103,5 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="duration">已学习 {{ item.duration|total_duration }}</div>
|
<div class="duration">已学习 {{ item.duration|total_duration }}</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
{%- endmacro %}
|
{%- endmacro %}
|
@ -14,28 +14,23 @@
|
|||||||
{% block inline_css %}{% endblock %}
|
{% block inline_css %}{% endblock %}
|
||||||
</head>
|
</head>
|
||||||
<body class="body">
|
<body class="body">
|
||||||
|
|
||||||
<div id="header">
|
<div id="header">
|
||||||
{{ partial('partials/header') }}
|
{{ partial('partials/header') }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="main" class="layui-main">
|
<div id="main" class="layui-main">
|
||||||
{% block content %}{% endblock %}
|
{% block content %}{% endblock %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="footer">
|
<div id="footer">
|
||||||
{{ partial('partials/footer') }}
|
{{ partial('partials/footer') }}
|
||||||
</div>
|
</div>
|
||||||
{{ js_include('lib/layui/layui.all.js') }}
|
|
||||||
|
{{ js_include('lib/layui/layui.js') }}
|
||||||
{{ js_include('web/js/common.js') }}
|
{{ js_include('web/js/common.js') }}
|
||||||
<script>
|
{{ js_include('web/js/fixbar.js') }}
|
||||||
layui.util.fixbar({
|
|
||||||
bar1: true,
|
|
||||||
click: function (type) {
|
|
||||||
console.log(type);
|
|
||||||
if (type === 'bar1') {
|
|
||||||
alert('点击了bar1');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
{% block include_js %}{% endblock %}
|
{% block include_js %}{% endblock %}
|
||||||
{% block inline_js %}{% endblock %}
|
{% block inline_js %}{% endblock %}
|
||||||
</body>
|
</body>
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
namespace App\Services\Frontend\Teacher;
|
namespace App\Services\Frontend\Teacher;
|
||||||
|
|
||||||
use App\Library\Paginator\Query as PagerQuery;
|
use App\Library\Paginator\Query as PagerQuery;
|
||||||
|
use App\Models\User;
|
||||||
use App\Repos\User as UserRepo;
|
use App\Repos\User as UserRepo;
|
||||||
use App\Services\Frontend\Service as FrontendService;
|
use App\Services\Frontend\Service as FrontendService;
|
||||||
|
|
||||||
@ -15,6 +16,7 @@ class TeacherList extends FrontendService
|
|||||||
|
|
||||||
$params = $pagerQuery->getParams();
|
$params = $pagerQuery->getParams();
|
||||||
|
|
||||||
|
$params['edu_role'] = User::EDU_ROLE_TEACHER;
|
||||||
$params['deleted'] = 0;
|
$params['deleted'] = 0;
|
||||||
|
|
||||||
$sort = $pagerQuery->getSort();
|
$sort = $pagerQuery->getSort();
|
||||||
|
@ -174,7 +174,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.index-course-list .course-card {
|
.index-course-list .course-card {
|
||||||
box-shadow: 0 1px 2px 1px rgba(0, 0, 0, 0.05);
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.index-course-list .course-card .info {
|
||||||
|
border: 1px solid #eee;
|
||||||
}
|
}
|
||||||
|
|
||||||
.index-carousel {
|
.index-carousel {
|
||||||
@ -285,7 +289,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.course-card .cover {
|
.course-card .cover {
|
||||||
margin-bottom: 10px;
|
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -299,15 +302,17 @@
|
|||||||
transform: scale(1.2);
|
transform: scale(1.2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.course-card .info {
|
||||||
|
padding: 10px 5px;
|
||||||
|
}
|
||||||
|
|
||||||
.course-card .title {
|
.course-card .title {
|
||||||
padding: 0 5px;
|
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.course-card .meta {
|
.course-card .meta {
|
||||||
color: #666;
|
color: #666;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
padding: 0 5px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.course-card .meta span {
|
.course-card .meta span {
|
||||||
@ -728,8 +733,31 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.live-player {
|
.live-player {
|
||||||
width: 800px;
|
width: 760px;
|
||||||
height: 450px;
|
height: 428px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.live-stats {
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
|
|
||||||
|
.live-stats .stats {
|
||||||
|
margin-bottom: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.live-stats .count {
|
||||||
|
margin-right: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.live-user-card {
|
||||||
|
line-height: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-login-tips {
|
||||||
|
padding-top: 20px;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 12px;
|
||||||
|
color: #999;
|
||||||
}
|
}
|
||||||
|
|
||||||
.chapter-bg {
|
.chapter-bg {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
var $ = layui.jquery;
|
layui.use(['jquery'], function () {
|
||||||
var layer = layui.layer;
|
var $ = layui.jquery;
|
||||||
var captcha = new TencentCaptcha(
|
var captcha = new TencentCaptcha(
|
||||||
$('#captcha-btn')[0],
|
$('#captcha-btn')[0],
|
||||||
$('#captcha-btn').attr('data-app-id'),
|
$('#captcha-btn').attr('data-app-id'),
|
||||||
function (res) {
|
function (res) {
|
||||||
@ -11,4 +11,5 @@ var captcha = new TencentCaptcha(
|
|||||||
$('#submit-btn').removeClass('layui-btn-disabled').removeAttr('disabled');
|
$('#submit-btn').removeClass('layui-btn-disabled').removeAttr('disabled');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
});
|
@ -1,11 +1,13 @@
|
|||||||
var $ = layui.jquery;
|
layui.use(['jquery', 'util'], function () {
|
||||||
var layer = layui.layer;
|
|
||||||
|
|
||||||
var timeCounting = false;
|
var $ = layui.jquery;
|
||||||
var $account = $('#cv-account');
|
var util = layui.util;
|
||||||
var $emit = $('#cv-verify-emit');
|
|
||||||
|
|
||||||
var captcha = new TencentCaptcha(
|
var timeCounting = false;
|
||||||
|
var $account = $('#cv-account');
|
||||||
|
var $emit = $('#cv-verify-emit');
|
||||||
|
|
||||||
|
var captcha = new TencentCaptcha(
|
||||||
$emit[0],
|
$emit[0],
|
||||||
$('#cv-app-id').val(),
|
$('#cv-app-id').val(),
|
||||||
function (res) {
|
function (res) {
|
||||||
@ -13,7 +15,7 @@ var captcha = new TencentCaptcha(
|
|||||||
$('#cv-ticket').val(res.ticket);
|
$('#cv-ticket').val(res.ticket);
|
||||||
$('#cv-rand').val(res.randstr);
|
$('#cv-rand').val(res.randstr);
|
||||||
if (isEmail($account.val()) || isPhone($account.val())) {
|
if (isEmail($account.val()) || isPhone($account.val())) {
|
||||||
var postUrl = null;
|
var postUrl;
|
||||||
var postData = {
|
var postData = {
|
||||||
ticket: $('#cv-ticket').val(),
|
ticket: $('#cv-ticket').val(),
|
||||||
rand: $('#cv-rand').val(),
|
rand: $('#cv-rand').val(),
|
||||||
@ -28,14 +30,7 @@ var captcha = new TencentCaptcha(
|
|||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
url: postUrl,
|
url: postUrl,
|
||||||
data: postData,
|
data: postData
|
||||||
success: function (res) {
|
|
||||||
|
|
||||||
},
|
|
||||||
error: function (xhr) {
|
|
||||||
var json = JSON.parse(xhr.responseText);
|
|
||||||
layer.msg(json.msg, {icon: 2});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
$('#cv-submit-btn').removeClass('layui-btn-disabled').removeAttr('disabled');
|
$('#cv-submit-btn').removeClass('layui-btn-disabled').removeAttr('disabled');
|
||||||
$emit.addClass('layui-btn-disabled').attr('disabled', 'disabled');
|
$emit.addClass('layui-btn-disabled').attr('disabled', 'disabled');
|
||||||
@ -43,9 +38,9 @@ var captcha = new TencentCaptcha(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
$account.on('keyup', function () {
|
$account.on('keyup', function () {
|
||||||
var accountOk;
|
var accountOk;
|
||||||
var type = $(this).attr('data-type');
|
var type = $(this).attr('data-type');
|
||||||
var account = $(this).val();
|
var account = $(this).val();
|
||||||
@ -61,12 +56,12 @@ $account.on('keyup', function () {
|
|||||||
} else {
|
} else {
|
||||||
$emit.addClass('layui-btn-disabled').attr('disabled', 'disabled');
|
$emit.addClass('layui-btn-disabled').attr('disabled', 'disabled');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function showCountDown(obj) {
|
function showCountDown(obj) {
|
||||||
var serverTime = new Date().getTime();
|
var serverTime = new Date().getTime();
|
||||||
var endTime = serverTime + 60 * 1000;
|
var endTime = serverTime + 60 * 1000;
|
||||||
layui.util.countdown(endTime, serverTime, function (date, serverTime, timer) {
|
util.countdown(endTime, serverTime, function (date, serverTime, timer) {
|
||||||
var left = date[0] * 86400 + date[1] * 3600 + date[2] * 60 + date[3];
|
var left = date[0] * 86400 + date[1] * 3600 + date[2] * 60 + date[3];
|
||||||
obj.text(left + '秒');
|
obj.text(left + '秒');
|
||||||
if (left === 0) {
|
if (left === 0) {
|
||||||
@ -76,12 +71,14 @@ function showCountDown(obj) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
timeCounting = true;
|
timeCounting = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isEmail(email) {
|
function isEmail(email) {
|
||||||
return /^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/.test(email);
|
return /^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/.test(email);
|
||||||
}
|
}
|
||||||
|
|
||||||
function isPhone(phone) {
|
function isPhone(phone) {
|
||||||
return /^1(3|4|5|6|7|8|9)\d{9}$/.test(phone);
|
return /^1(3|4|5|6|7|8|9)\d{9}$/.test(phone);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
});
|
@ -1,17 +1,7 @@
|
|||||||
var $ = layui.jquery;
|
layui.define(['jquery', 'element'], function (exports) {
|
||||||
var element = layui.element;
|
exports('ajaxLoadHtml', function (url, target) {
|
||||||
var form = layui.form;
|
var $ = layui.jquery;
|
||||||
var layer = layui.layer;
|
var element = layui.element;
|
||||||
|
|
||||||
$.ajaxSetup({
|
|
||||||
beforeSend: function (xhr) {
|
|
||||||
xhr.setRequestHeader('X-Csrf-Token', $('meta[name="csrf-token"]').attr('content'));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
var helper = {};
|
|
||||||
|
|
||||||
helper.ajaxLoadHtml = function (url, target) {
|
|
||||||
var $target = $('#' + target);
|
var $target = $('#' + target);
|
||||||
var html = '<div class="loading"><i class="layui-icon layui-icon-loading layui-anim layui-anim-rotate layui-anim-loop"></i></div>';
|
var html = '<div class="loading"><i class="layui-icon layui-icon-loading layui-anim layui-anim-rotate layui-anim-loop"></i></div>';
|
||||||
$target.html(html);
|
$target.html(html);
|
||||||
@ -19,9 +9,23 @@ helper.ajaxLoadHtml = function (url, target) {
|
|||||||
$target.html(html);
|
$target.html(html);
|
||||||
element.init();
|
element.init();
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
|
});
|
||||||
|
|
||||||
form.on('submit(go)', function (data) {
|
layui.use(['jquery', 'form', 'element', 'layer'], function () {
|
||||||
|
|
||||||
|
var $ = layui.jquery;
|
||||||
|
var element = layui.element;
|
||||||
|
var form = layui.form;
|
||||||
|
var layer = layui.layer;
|
||||||
|
|
||||||
|
$.ajaxSetup({
|
||||||
|
beforeSend: function (xhr) {
|
||||||
|
xhr.setRequestHeader('X-Csrf-Token', $('meta[name="csrf-token"]').attr('content'));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
form.on('submit(go)', function (data) {
|
||||||
var submit = $(this);
|
var submit = $(this);
|
||||||
submit.attr('disabled', 'disabled').addClass('layui-btn-disabled');
|
submit.attr('disabled', 'disabled').addClass('layui-btn-disabled');
|
||||||
$.ajax({
|
$.ajax({
|
||||||
@ -48,9 +52,9 @@ form.on('submit(go)', function (data) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.kg-delete').on('click', function () {
|
$('.kg-delete').on('click', function () {
|
||||||
var url = $(this).attr('data-url');
|
var url = $(this).attr('data-url');
|
||||||
var tips = '确定要删除吗?';
|
var tips = '确定要删除吗?';
|
||||||
layer.confirm(tips, function () {
|
layer.confirm(tips, function () {
|
||||||
@ -73,14 +77,16 @@ $('.kg-delete').on('click', function () {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.kg-back').on('click', function () {
|
$('.kg-back').on('click', function () {
|
||||||
window.history.back();
|
window.history.back();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('body').on('click', '.layui-laypage > a', function () {
|
$('body').on('click', '.layui-laypage > a', function () {
|
||||||
var url = $(this).attr('data-url');
|
var url = $(this).attr('data-url');
|
||||||
var target = $(this).attr('data-target');
|
var target = $(this).attr('data-target');
|
||||||
helper.ajaxLoadHtml(url, target);
|
layui.ajaxLoadHtml(url, target);
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
30
public/static/web/js/course.show.js
Normal file
30
public/static/web/js/course.show.js
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
layui.use(['jquery', 'element'], function () {
|
||||||
|
|
||||||
|
var $ = layui.jquery;
|
||||||
|
|
||||||
|
if ($('#tab-packages').length > 0) {
|
||||||
|
var $tabPackages = $('#tab-packages');
|
||||||
|
layui.ajaxLoadHtml($tabPackages.attr('data-url'), $tabPackages.attr('id'));
|
||||||
|
}
|
||||||
|
if ($('#tab-consults').length > 0) {
|
||||||
|
var $tabConsults = $('#tab-consults');
|
||||||
|
layui.ajaxLoadHtml($tabConsults.attr('data-url'), $tabConsults.attr('id'));
|
||||||
|
}
|
||||||
|
if ($('#tab-reviews').length > 0) {
|
||||||
|
var $tabReviews = $('#tab-reviews');
|
||||||
|
layui.ajaxLoadHtml($tabReviews.attr('data-url'), $tabReviews.attr('id'));
|
||||||
|
}
|
||||||
|
if ($('#sidebar-topics').length > 0) {
|
||||||
|
var $sdTopics = $('#sidebar-topics');
|
||||||
|
layui.ajaxLoadHtml($sdTopics.attr('data-url'), $sdTopics.attr('id'));
|
||||||
|
}
|
||||||
|
if ($('#sidebar-recommended').length > 0) {
|
||||||
|
var $sdRecommended = $('#sidebar-recommended');
|
||||||
|
layui.ajaxLoadHtml($sdRecommended.attr('data-url'), $sdRecommended.attr('id'));
|
||||||
|
}
|
||||||
|
if ($('#sidebar-related').length > 0) {
|
||||||
|
var $sdRelated = $('#sidebar-related');
|
||||||
|
layui.ajaxLoadHtml($sdRelated.attr('data-url'), $sdRelated.attr('id'));
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
12
public/static/web/js/fixbar.js
Normal file
12
public/static/web/js/fixbar.js
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
layui.use(['util'], function () {
|
||||||
|
var util = layui.util;
|
||||||
|
util.fixbar({
|
||||||
|
bar1: true,
|
||||||
|
click: function (type) {
|
||||||
|
console.log(type);
|
||||||
|
if (type === 'bar1') {
|
||||||
|
alert('点击了bar1');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
@ -2,7 +2,6 @@ layui.use(['jquery', 'layim'], function () {
|
|||||||
|
|
||||||
var $ = layui.jquery;
|
var $ = layui.jquery;
|
||||||
var layim = layui.layim;
|
var layim = layui.layim;
|
||||||
|
|
||||||
var socket = new WebSocket('ws://127.0.0.1:8282');
|
var socket = new WebSocket('ws://127.0.0.1:8282');
|
||||||
|
|
||||||
var membersUrl = $('input[name="im.members_url"]').val();
|
var membersUrl = $('input[name="im.members_url"]').val();
|
||||||
@ -34,9 +33,7 @@ layui.use(['jquery', 'layim'], function () {
|
|||||||
'sign': user.sign
|
'sign': user.sign
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
members: {
|
members: {url: membersUrl}
|
||||||
url: membersUrl
|
|
||||||
}
|
|
||||||
}).chat({
|
}).chat({
|
||||||
type: 'group',
|
type: 'group',
|
||||||
name: group.name,
|
name: group.name,
|
||||||
@ -44,6 +41,8 @@ layui.use(['jquery', 'layim'], function () {
|
|||||||
id: group.id
|
id: group.id
|
||||||
});
|
});
|
||||||
|
|
||||||
|
layim.setChatMin();
|
||||||
|
|
||||||
layim.on('sendMessage', function (res) {
|
layim.on('sendMessage', function (res) {
|
||||||
sendMessage(res.mine, res.to);
|
sendMessage(res.mine, res.to);
|
||||||
});
|
});
|
||||||
@ -72,6 +71,8 @@ layui.use(['jquery', 'layim'], function () {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
showOrHidePoster();
|
||||||
|
|
||||||
function bindUser(clientId) {
|
function bindUser(clientId) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
@ -90,7 +91,16 @@ layui.use(['jquery', 'layim'], function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function showMessage(message) {
|
function showMessage(message) {
|
||||||
|
if (message.fromid !== user.id) {
|
||||||
layim.getMessage(message);
|
layim.getMessage(message);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function showOrHidePoster() {
|
||||||
|
if (user.id === '0') {
|
||||||
|
var html = '<div class="chat-login-tips">登录用户才可以参与讨论哦</div>';
|
||||||
|
$('.layim-chat-footer').hide().after(html);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
@ -1,58 +1,60 @@
|
|||||||
var interval = null;
|
layui.use(['jquery'], function () {
|
||||||
var intervalTime = 5000;
|
|
||||||
var position = 0;
|
|
||||||
var chapterId = $('input[name="chapter.id"]').val();
|
|
||||||
var planId = $('input[name="chapter.plan_id"]').val();
|
|
||||||
var userId = $('input[name="user.id"]').val();
|
|
||||||
var learningUrl = $('input[name="chapter.learning_url"]').val();
|
|
||||||
var playUrls = JSON.parse($('input[name="chapter.play_urls"]').val());
|
|
||||||
var requestId = getRequestId();
|
|
||||||
|
|
||||||
var options = {
|
var interval = null;
|
||||||
|
var intervalTime = 5000;
|
||||||
|
var position = 0;
|
||||||
|
var chapterId = $('input[name="chapter.id"]').val();
|
||||||
|
var planId = $('input[name="chapter.plan_id"]').val();
|
||||||
|
var userId = $('input[name="user.id"]').val();
|
||||||
|
var learningUrl = $('input[name="chapter.learning_url"]').val();
|
||||||
|
var playUrls = JSON.parse($('input[name="chapter.play_urls"]').val());
|
||||||
|
var requestId = getRequestId();
|
||||||
|
|
||||||
|
var options = {
|
||||||
live: true,
|
live: true,
|
||||||
autoplay: true,
|
autoplay: true,
|
||||||
h5_flv: true,
|
h5_flv: true,
|
||||||
width: 800,
|
width: 760,
|
||||||
height: 450
|
height: 428
|
||||||
};
|
};
|
||||||
|
|
||||||
if (playUrls.rtmp && playUrls.rtmp.od) {
|
if (playUrls.rtmp && playUrls.rtmp.od) {
|
||||||
options.rtmp = playUrls.rtmp.od;
|
options.rtmp = playUrls.rtmp.od;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (playUrls.rtmp && playUrls.rtmp.hd) {
|
if (playUrls.rtmp && playUrls.rtmp.hd) {
|
||||||
options.rtmp_hd = playUrls.rtmp.hd;
|
options.rtmp_hd = playUrls.rtmp.hd;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (playUrls.rtmp && playUrls.rtmp.sd) {
|
if (playUrls.rtmp && playUrls.rtmp.sd) {
|
||||||
options.rtmp_sd = playUrls.rtmp.sd;
|
options.rtmp_sd = playUrls.rtmp.sd;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (playUrls.flv && playUrls.flv.od) {
|
if (playUrls.flv && playUrls.flv.od) {
|
||||||
options.flv = playUrls.flv.od;
|
options.flv = playUrls.flv.od;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (playUrls.flv && playUrls.flv.hd) {
|
if (playUrls.flv && playUrls.flv.hd) {
|
||||||
options.flv_hd = playUrls.flv.hd;
|
options.flv_hd = playUrls.flv.hd;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (playUrls.flv && playUrls.flv.sd) {
|
if (playUrls.flv && playUrls.flv.sd) {
|
||||||
options.flv_sd = playUrls.flv.sd;
|
options.flv_sd = playUrls.flv.sd;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (playUrls.m3u8 && playUrls.m3u8.od) {
|
if (playUrls.m3u8 && playUrls.m3u8.od) {
|
||||||
options.m3u8 = playUrls.m3u8.od;
|
options.m3u8 = playUrls.m3u8.od;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (playUrls.m3u8 && playUrls.m3u8.hd) {
|
if (playUrls.m3u8 && playUrls.m3u8.hd) {
|
||||||
options.m3u8_hd = playUrls.m3u8.hd;
|
options.m3u8_hd = playUrls.m3u8.hd;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (playUrls.m3u8 && playUrls.m3u8.sd) {
|
if (playUrls.m3u8 && playUrls.m3u8.sd) {
|
||||||
options.m3u8_sd = playUrls.m3u8.sd;
|
options.m3u8_sd = playUrls.m3u8.sd;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (userId !== '0' && planId !== '0') {
|
if (userId !== '0' && planId !== '0') {
|
||||||
options.listener = function (msg) {
|
options.listener = function (msg) {
|
||||||
if (msg.type === 'play') {
|
if (msg.type === 'play') {
|
||||||
start();
|
start();
|
||||||
@ -62,28 +64,28 @@ if (userId !== '0' && planId !== '0') {
|
|||||||
stop();
|
stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var player = new TcPlayer('player', options);
|
var player = new TcPlayer('player', options);
|
||||||
|
|
||||||
if (position > 0) {
|
if (position > 0) {
|
||||||
player.currentTime(position);
|
player.currentTime(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
function start() {
|
function start() {
|
||||||
if (interval != null) {
|
if (interval != null) {
|
||||||
clearInterval(interval);
|
clearInterval(interval);
|
||||||
interval = null;
|
interval = null;
|
||||||
}
|
}
|
||||||
interval = setInterval(learning, intervalTime);
|
interval = setInterval(learning, intervalTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
function stop() {
|
function stop() {
|
||||||
clearInterval(interval);
|
clearInterval(interval);
|
||||||
interval = null;
|
interval = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function learning() {
|
function learning() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
url: learningUrl,
|
url: learningUrl,
|
||||||
@ -95,10 +97,12 @@ function learning() {
|
|||||||
position: player.currentTime(),
|
position: player.currentTime(),
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRequestId() {
|
function getRequestId() {
|
||||||
var id = Date.now().toString(36);
|
var id = Date.now().toString(36);
|
||||||
id += Math.random().toString(36).substr(3);
|
id += Math.random().toString(36).substr(3);
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user