1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-17 15:55:31 +08:00

Compare commits

...

30 Commits

Author SHA1 Message Date
xiaochong0302
247050f4ef Merge branch 'koogua/v1.7.8'
# Conflicts:
#	public/static/admin/js/avatar.upload.js
2025-06-15 16:51:20 +08:00
xiaochong0302
57409cb630 v1.7.8 2025-06-15 15:08:42 +08:00
xiaochong0302
4e1e8340b9 1.添加closeLiveTask
2.优化kg-back返回
3.优化统计分析代码位置
2025-06-11 15:01:23 +08:00
xiaochong0302
2ab6ae71cd 1.优化直播状态显示
2.优化关闭注册提示
2025-06-09 22:46:28 +08:00
xiaochong0302
303442f446 搜索结果中图片alt属性增加striptags过滤 2025-06-09 19:08:33 +08:00
xiaochong0302
7281029dd0 sitemap.xml直接写入public目录 2025-06-05 17:53:06 +08:00
xiaochong0302
f5ed2ce239 优化fixbar电话图标 2025-05-26 19:19:12 +08:00
xiaochong0302
2a1b4b69fd fixbar增加电话图标 2025-05-26 10:41:17 +08:00
xiaochong0302
123e1ec97f 后台重置头像->上传头像 2025-05-23 17:03:58 +08:00
xiaochong0302
b2f795eb3b 还原几个不能为空的腾讯云配置 2025-05-22 23:31:26 +08:00
xiaochong0302
12db90d9c1 还原几个不能为空的腾讯云配置 2025-05-22 23:31:12 +08:00
xiaochong0302
59bfe4a765 gitee webhook测试 2025-05-21 11:05:18 +08:00
xiaochong0302
fb0b760e2e 1.优化后台配置默认值
2.后台增加返回顶部功能
3.精简优化逻辑
2025-05-20 18:09:19 +08:00
xiaochong0302
e31b86580d 优化课时列表直播提示 2025-05-20 18:09:15 +08:00
xiaochong0302
f2a446a876 移除Throttle 2025-05-20 18:09:12 +08:00
xiaochong0302
27440fe679 1.优化后台配置默认值
2.后台增加返回顶部功能
3.精简优化逻辑
2025-05-20 18:06:11 +08:00
xiaochong0302
7a9fee5545 优化课时列表直播提示 2025-05-08 17:18:20 +08:00
xiaochong0302
d927e619e8 移除Throttle 2025-05-02 07:55:38 +08:00
xiaochong0302
77cdc594ff 优化layer窗口中表单的跳转 2025-04-20 17:05:30 +08:00
xiaochong0302
0d8b07033a 优化layer窗口中表单的跳转 2025-04-20 17:03:36 +08:00
xiaochong0302
9ad15b72cf 优化倒计时 2025-04-20 17:03:32 +08:00
xiaochong0302
12f0f6dc87 重命令若干路由 2025-04-20 17:03:28 +08:00
xiaochong0302
3efa081e81 LiveChapter -> LiveChat 2025-04-20 17:03:24 +08:00
xiaochong0302
47a6c5cce1 修正workerman中onMessage无法调用问题 2025-04-20 17:03:20 +08:00
xiaochong0302
328aea1e2d 1.优化章节列表UI
2.优化评价UI
2025-04-20 17:03:17 +08:00
xiaochong0302
e5869e1e8f 1.优化课程目录UI
2.优化收藏UI
3.修正收费课程试听问题
2025-04-20 17:03:14 +08:00
xiaochong0302
9fcea65989 1.优化vip页面
2.优化索引管理工具
2025-04-20 17:03:11 +08:00
xiaochong0302
08d3859e38 1.抽离refund.info.js
2.优化获取临时令牌日志
2025-04-03 19:02:48 +08:00
xiaochong0302
02983a27c9 优化微信公众号相关 2025-04-03 19:02:45 +08:00
xiaochong0302
72deb17daa 增强注册验证 2025-04-03 19:02:42 +08:00
102 changed files with 1095 additions and 1018 deletions

View File

@ -1,3 +1,28 @@
### [v1.7.8](https://gitee.com/koogua/course-tencent-cloud/releases/v1.7.8)(2025-06-20)
- 移除ThrottleLimit
- 增加CloseLiveTask
- 增加搜索页图片alt属性striptags过滤
- 后台增加返回顶部快捷方式
- 前台fixbar增加联系电话
- 优化安装脚本
- 优化课时列表直播提示
- 优化后台返回链接
- 优化统计分析代码位置
- 直播回调后更新课时缓存
- 后台清空头像->上传头像
- sitemap.xml直接写入网站根目录
### [v1.7.7](https://gitee.com/koogua/course-tencent-cloud/releases/v1.7.7)(2025-04-20)
- 优化索引管理工具
- 优化章节等页面UI
- 修正workerman中onMessage问题
- 修正非免费课程试听问题
- 优化layer窗口中的表单跳转
- 文件清理以及命名优化
- 优化倒计时
### [v1.7.6](https://gitee.com/koogua/course-tencent-cloud/releases/v1.7.6)(2025-03-22)
- 升级layui-v2.9.25

View File

@ -18,6 +18,13 @@ abstract class Migration
abstract public function run();
protected function saveSettings(array $settings)
{
foreach ($settings as $setting) {
$this->saveSetting($setting);
}
}
protected function saveSetting(array $setting)
{
$settingRepo = new SettingRepo();
@ -32,4 +39,4 @@ abstract class Migration
}
}
}
}

View File

@ -20,8 +20,6 @@ class ArticleIndexTask extends Task
* 搜索测试
*
* @command: php console.php article_index search {query}
* @param array $params
* @throws \XSException
*/
public function searchAction($params)
{
@ -31,7 +29,9 @@ class ArticleIndexTask extends Task
exit('please special a query word' . PHP_EOL);
}
$result = $this->searchArticles($query);
$handler = new ArticleSearcher();
$result = $handler->search($query);
var_export($result);
}
@ -42,24 +42,6 @@ class ArticleIndexTask extends Task
* @command: php console.php article_index clean
*/
public function cleanAction()
{
$this->cleanArticleIndex();
}
/**
* 重建索引
*
* @command: php console.php article_index rebuild
*/
public function rebuildAction()
{
$this->rebuildArticleIndex();
}
/**
* 清空索引
*/
protected function cleanArticleIndex()
{
$handler = new ArticleSearcher();
@ -74,8 +56,10 @@ class ArticleIndexTask extends Task
/**
* 重建索引
*
* @command: php console.php article_index rebuild
*/
protected function rebuildArticleIndex()
public function rebuildAction()
{
$articles = $this->findArticles();
@ -83,7 +67,7 @@ class ArticleIndexTask extends Task
$handler = new ArticleSearcher();
$documenter = new ArticleDocument();
$doc = new ArticleDocument();
$index = $handler->getXS()->getIndex();
@ -92,7 +76,7 @@ class ArticleIndexTask extends Task
$index->beginRebuild();
foreach ($articles as $article) {
$document = $documenter->setDocument($article);
$document = $doc->setDocument($article);
$index->add($document);
}
@ -102,17 +86,39 @@ class ArticleIndexTask extends Task
}
/**
* 搜索文章
* 刷新索引缓存
*
* @param string $query
* @return array
* @throws \XSException
* @command: php console.php article_index flush_index
*/
protected function searchArticles($query)
public function flushIndexAction()
{
$handler = new ArticleSearcher();
return $handler->search($query);
$index = $handler->getXS()->getIndex();
echo '------ start flush article index ------' . PHP_EOL;
$index->flushIndex();
echo '------ end flush article index ------' . PHP_EOL;
}
/**
* 刷新搜索日志
*
* @command: php console.php article_index flush_logging
*/
public function flushLoggingAction()
{
$handler = new ArticleSearcher();
$index = $handler->getXS()->getIndex();
echo '------ start flush article logging ------' . PHP_EOL;
$index->flushLogging();
echo '------ end flush article logging ------' . PHP_EOL;
}
/**

View File

@ -0,0 +1,72 @@
<?php
/**
* @copyright Copyright (c) 2024 深圳市酷瓜软件有限公司
* @license https://opensource.org/licenses/GPL-2.0
* @link https://www.koogua.com
*/
namespace App\Console\Tasks;
use App\Caches\CourseChapterList as CourseChapterListCache;
use App\Models\Chapter as ChapterModel;
use App\Models\ChapterLive as ChapterLiveModel;
use App\Repos\Chapter as ChapterRepo;
use Phalcon\Mvc\Model\Resultset;
use Phalcon\Mvc\Model\ResultsetInterface;
class CloseLiveTask extends Task
{
public function mainAction()
{
$chapterLives = $this->findChapterLives();
echo sprintf('pending lives: %s', $chapterLives->count()) . PHP_EOL;
if ($chapterLives->count() == 0) return;
echo '------ start close live task ------' . PHP_EOL;
foreach ($chapterLives as $chapterLive) {
$chapterLive->status = ChapterLiveModel::STATUS_INACTIVE;
$chapterLive->update();
$chapterRepo = new ChapterRepo();
$chapter = $chapterRepo->findById($chapterLive->chapter_id);
$attrs = $chapter->attrs;
$attrs['stream']['status'] = ChapterModel::SS_INACTIVE;
$chapter->attrs = $attrs;
$chapter->update();
$cache = new CourseChapterListCache();
$cache->rebuild($chapterLive->course_id);
}
echo '------ end close live task ------' . PHP_EOL;
}
/**
* 查找待关闭直播
*
* @param int $limit
* @return ResultsetInterface|Resultset|ChapterLiveModel[]
*/
protected function findChapterLives(int $limit = 100)
{
$status = ChapterLiveModel::STATUS_ACTIVE;
$endTime = time() - 3600;
return ChapterLiveModel::query()
->where('status = :status:', ['status' => $status])
->andWhere('end_time < :end_time:', ['end_time' => $endTime])
->limit($limit)
->execute();
}
}

View File

@ -20,8 +20,6 @@ class CourseIndexTask extends Task
* 搜索测试
*
* @command: php console.php course_index search {query}
* @param array $params
* @throws \XSException
*/
public function searchAction($params)
{
@ -31,7 +29,9 @@ class CourseIndexTask extends Task
exit('please special a query word' . PHP_EOL);
}
$result = $this->searchCourses($query);
$handler = new CourseSearcher();
$result = $handler->search($query);
var_export($result);
}
@ -42,24 +42,6 @@ class CourseIndexTask extends Task
* @command: php console.php course_index clean
*/
public function cleanAction()
{
$this->cleanCourseIndex();
}
/**
* 重建索引
*
* @command: php console.php course_index rebuild
*/
public function rebuildAction()
{
$this->rebuildCourseIndex();
}
/**
* 清空索引
*/
protected function cleanCourseIndex()
{
$handler = new CourseSearcher();
@ -74,8 +56,10 @@ class CourseIndexTask extends Task
/**
* 重建索引
*
* @command: php console.php course_index rebuild
*/
protected function rebuildCourseIndex()
public function rebuildAction()
{
$courses = $this->findCourses();
@ -83,7 +67,7 @@ class CourseIndexTask extends Task
$handler = new CourseSearcher();
$documenter = new CourseDocument();
$doc = new CourseDocument();
$index = $handler->getXS()->getIndex();
@ -92,7 +76,7 @@ class CourseIndexTask extends Task
$index->beginRebuild();
foreach ($courses as $course) {
$document = $documenter->setDocument($course);
$document = $doc->setDocument($course);
$index->add($document);
}
@ -102,17 +86,39 @@ class CourseIndexTask extends Task
}
/**
* 搜索课程
* 刷新索引缓存
*
* @param string $query
* @return array
* @throws \XSException
* @command: php console.php course_index flush_index
*/
protected function searchCourses($query)
public function flushIndexAction()
{
$handler = new CourseSearcher();
return $handler->search($query);
$index = $handler->getXS()->getIndex();
echo '------ start flush course index ------' . PHP_EOL;
$index->flushIndex();
echo '------ end flush course index ------' . PHP_EOL;
}
/**
* 刷新搜索日志
*
* @command: php console.php course_index flush_logging
*/
public function flushLoggingAction()
{
$handler = new CourseSearcher();
$index = $handler->getXS()->getIndex();
echo '------ start flush course logging ------' . PHP_EOL;
$index->flushLogging();
echo '------ end flush course logging ------' . PHP_EOL;
}
/**
@ -124,7 +130,7 @@ class CourseIndexTask extends Task
{
return CourseModel::query()
->where('published = 1')
->where('deleted = 0')
->andWhere('deleted = 0')
->execute();
}

View File

@ -20,8 +20,6 @@ class QuestionIndexTask extends Task
* 搜索测试
*
* @command: php console.php question_index search {query}
* @param array $params
* @throws \XSException
*/
public function searchAction($params)
{
@ -31,7 +29,9 @@ class QuestionIndexTask extends Task
exit('please special a query word' . PHP_EOL);
}
$result = $this->searchQuestions($query);
$handler = new QuestionSearcher();
$result = $handler->search($query);
var_export($result);
}
@ -42,24 +42,6 @@ class QuestionIndexTask extends Task
* @command: php console.php question_index clean
*/
public function cleanAction()
{
$this->cleanQuestionIndex();
}
/**
* 重建索引
*
* @command: php console.php question_index rebuild
*/
public function rebuildAction()
{
$this->rebuildQuestionIndex();
}
/**
* 清空索引
*/
protected function cleanQuestionIndex()
{
$handler = new QuestionSearcher();
@ -74,8 +56,10 @@ class QuestionIndexTask extends Task
/**
* 重建索引
*
* @command: php console.php question_index rebuild
*/
protected function rebuildQuestionIndex()
public function rebuildAction()
{
$questions = $this->findQuestions();
@ -83,7 +67,7 @@ class QuestionIndexTask extends Task
$handler = new QuestionSearcher();
$documenter = new QuestionDocument();
$doc = new QuestionDocument();
$index = $handler->getXS()->getIndex();
@ -92,7 +76,7 @@ class QuestionIndexTask extends Task
$index->beginRebuild();
foreach ($questions as $question) {
$document = $documenter->setDocument($question);
$document = $doc->setDocument($question);
$index->add($document);
}
@ -102,17 +86,39 @@ class QuestionIndexTask extends Task
}
/**
* 搜索文章
* 刷新索引缓存
*
* @param string $query
* @return array
* @throws \XSException
* @command: php console.php question_index flush_index
*/
protected function searchQuestions($query)
public function flushIndexAction()
{
$handler = new QuestionSearcher();
return $handler->search($query);
$index = $handler->getXS()->getIndex();
echo '------ start flush question index ------' . PHP_EOL;
$index->flushIndex();
echo '------ end flush question index ------' . PHP_EOL;
}
/**
* 刷新搜索日志
*
* @command: php console.php question_index flush_logging
*/
public function flushLoggingAction()
{
$handler = new QuestionSearcher();
$index = $handler->getXS()->getIndex();
echo '------ start flush question logging ------' . PHP_EOL;
$index->flushLogging();
echo '------ end flush question logging ------' . PHP_EOL;
}
/**

View File

@ -37,7 +37,7 @@ class SitemapTask extends Task
$this->sitemap = new Sitemap();
$filename = tmp_path('sitemap.xml');
$filename = public_path('sitemap.xml');
echo '------ start sitemap task ------' . PHP_EOL;

View File

@ -13,12 +13,12 @@ use GuzzleHttp\Client;
class SyncAppInfoTask extends Task
{
const API_BASE_URL = 'https://www.koogua.com/api';
public function mainAction()
{
echo '------ start sync app info ------' . PHP_EOL;
$url = 'https://www.koogua.com/api/instance/collect';
$site = $this->getSettings('site');
$serverHost = parse_url($site['url'], PHP_URL_HOST);
@ -38,6 +38,8 @@ class SyncAppInfoTask extends Task
$client = new Client();
$url = sprintf('%s/instance/collect', self::API_BASE_URL);
$client->request('POST', $url, ['form_params' => $params]);
echo '------ end sync app info ------' . PHP_EOL;

View File

@ -71,28 +71,6 @@ class UploadController extends Controller
return $this->jsonSuccess(['data' => $data]);
}
/**
* @Post("/avatar/img", name="admin.upload.avatar_img")
*/
public function uploadAvatarImageAction()
{
$service = new StorageService();
$file = $service->uploadAvatarImage();
if (!$file) {
return $this->jsonError(['msg' => '上传文件失败']);
}
$data = [
'id' => $file->id,
'name' => $file->name,
'url' => $service->getImageUrl($file->path),
];
return $this->jsonSuccess(['data' => $data]);
}
/**
* @Post("/content/img", name="admin.upload.content_img")
*/

View File

@ -52,8 +52,8 @@ class Setting extends Service
{
$alipay = $this->getSettings('pay.alipay');
$alipay['return_url'] = $alipay['return_url'] ?: kg_full_url(['for' => 'home.alipay_callback']);
$alipay['notify_url'] = $alipay['notify_url'] ?: kg_full_url(['for' => 'home.alipay_notify']);
$alipay['return_url'] = $alipay['return_url'] ?: kg_full_url(['for' => 'home.alipay.callback']);
$alipay['notify_url'] = $alipay['notify_url'] ?: kg_full_url(['for' => 'home.alipay.notify']);
return $alipay;
}
@ -62,8 +62,8 @@ class Setting extends Service
{
$wxpay = $this->getSettings('pay.wxpay');
$wxpay['return_url'] = $wxpay['return_url'] ?: kg_full_url(['for' => 'home.wxpay_callback']);
$wxpay['notify_url'] = $wxpay['notify_url'] ?: kg_full_url(['for' => 'home.wxpay_notify']);
$wxpay['return_url'] = $wxpay['return_url'] ?: kg_full_url(['for' => 'home.wxpay.callback']);
$wxpay['notify_url'] = $wxpay['notify_url'] ?: kg_full_url(['for' => 'home.wxpay.notify']);
return $wxpay;
}
@ -109,11 +109,11 @@ class Setting extends Service
$result = $this->getSettings($section);
if ($section == 'live.notify') {
$result['stream_begin_url'] = $result['stream_begin_url'] ?: kg_full_url(['for' => 'home.live_notify'], ['action' => 'streamBegin']);
$result['stream_end_url'] = $result['stream_end_url'] ?: kg_full_url(['for' => 'home.live_notify'], ['action' => 'streamEnd']);
$result['record_url'] = $result['record_url'] ?: kg_full_url(['for' => 'home.live_notify'], ['action' => 'record']);
$result['snapshot_url'] = $result['snapshot_url'] ?: kg_full_url(['for' => 'home.live_notify'], ['action' => 'snapshot']);
$result['porn_url'] = $result['porn_url'] ?: kg_full_url(['for' => 'home.live_notify'], ['action' => 'porn']);
$result['stream_begin_url'] = $result['stream_begin_url'] ?: kg_full_url(['for' => 'home.live.notify'], ['action' => 'streamBegin']);
$result['stream_end_url'] = $result['stream_end_url'] ?: kg_full_url(['for' => 'home.live.notify'], ['action' => 'streamEnd']);
$result['record_url'] = $result['record_url'] ?: kg_full_url(['for' => 'home.live.notify'], ['action' => 'record']);
$result['snapshot_url'] = $result['snapshot_url'] ?: kg_full_url(['for' => 'home.live.notify'], ['action' => 'snapshot']);
$result['porn_url'] = $result['porn_url'] ?: kg_full_url(['for' => 'home.live.notify'], ['action' => 'porn']);
}
return $result;

View File

@ -9,7 +9,7 @@
<div class="kg-nav-left">
<span class="layui-breadcrumb">
{% if parent.id > 0 %}
<a class="kg-back" href="{{ back_url }}"><i class="layui-icon layui-icon-return"></i>返回</a>
<a href="{{ back_url }}"><i class="layui-icon layui-icon-return"></i>返回</a>
<a><cite>{{ parent.name }}</cite></a>
{% endif %}
<a><cite>分类管理</cite></a>
@ -87,4 +87,4 @@
</tbody>
</table>
{% endblock %}
{% endblock %}

View File

@ -88,7 +88,7 @@
layer.open({
type: 2,
title: '推流测试',
area: ['720px', '500px'],
area: ['720px', '540px'],
content: [url, 'no']
});
});
@ -97,4 +97,4 @@
</script>
{% endblock %}
{% endblock %}

View File

@ -43,7 +43,7 @@
<div class="kg-nav">
<div class="kg-nav-left">
<span class="layui-breadcrumb">
<a class="kg-back" href="{{ back_url }}"><i class="layui-icon layui-icon-return"></i>返回</a>
<a href="{{ back_url }}"><i class="layui-icon layui-icon-return"></i>返回</a>
<a><cite>{{ course.title }}</cite></a>
<a><cite>{{ chapter.title }}</cite></a>
<a><cite>课时管理</cite></a>
@ -126,4 +126,4 @@
</tbody>
</table>
{% endblock %}
{% endblock %}

View File

@ -9,7 +9,7 @@
<div class="kg-nav">
<div class="kg-nav-left">
<span class="layui-breadcrumb">
<a class="kg-back" href="{{ back_url }}"><i class="layui-icon layui-icon-return"></i>返回</a>
<a href="{{ back_url }}"><i class="layui-icon layui-icon-return"></i>返回</a>
<a><cite>{{ course.title }}</cite></a>
<a><cite>章节管理</cite></a>
</span>
@ -79,4 +79,4 @@
</tbody>
</table>
{% endblock %}
{% endblock %}

View File

@ -3,7 +3,6 @@
<table class="kg-table layui-table">
<tr>
<th>名称</th>
<th>类型</th>
<th>大小</th>
<th>日期</th>
<th width="15%">操作</th>
@ -13,7 +12,6 @@
{% set delete_url = url({'for':'admin.resource.delete','id':item.id}) %}
<tr>
<td><input class="layui-input res-name" type="text" value="{{ item.upload.name }}" data-url="{{ update_url }}"></td>
<td>{{ item.upload.mime }}</td>
<td>{{ item.upload.size|human_size }}</td>
<td>{{ date('Y-m-d H:i:s',item.create_time) }}</td>
<td>
@ -27,4 +25,4 @@
{% else %}
<div class="kg-center">没有相关资料</div>
<br>
{% endif %}
{% endif %}

View File

@ -25,9 +25,7 @@
<div class="kg-nav-left">
<span class="layui-breadcrumb">
{% if parent.id > 0 %}
<a class="kg-back" href="{{ back_url }}">
<i class="layui-icon layui-icon-return"></i> 返回
</a>
<a href="{{ back_url }}"><i class="layui-icon layui-icon-return"></i>返回</a>
<a><cite>{{ parent.name }}</cite></a>
{% endif %}
<a><cite>导航管理</cite></a>

View File

@ -65,7 +65,7 @@
layer.open({
type: 2,
title: '推流测试',
area: ['720px', '500px'],
area: ['720px', '540px'],
content: [url, 'no']
});
});
@ -85,4 +85,4 @@
</script>
{% endblock %}
{% endblock %}

View File

@ -20,9 +20,10 @@
{{ js_include('lib/layui/layui.js') }}
{{ js_include('admin/js/common.js') }}
{{ js_include('admin/js/fixbar.js') }}
{% block include_js %}{% endblock %}
{% block inline_js %}{% endblock %}
</body>
</html>
</html>

View File

@ -21,12 +21,11 @@
<div class="layui-form-item">
<label class="layui-form-label" style="padding-top:30px;">头像</label>
<div class="layui-input-inline" style="width:80px;">
<img id="avatar" class="kg-avatar" src="{{ user.avatar }}">
<img id="img-avatar" class="kg-avatar" src="{{ user.avatar }}">
<input type="hidden" name="avatar" value="{{ user.avatar }}">
<input type="hidden" name="default_avatar" value="{{ default_avatar }}">
</div>
<div class="layui-input-inline" style="padding-top:25px;">
<button id="clear-avatar" class="layui-btn layui-btn-sm" type="button">清空</button>
<button id="change-avatar" class="layui-btn layui-btn-sm" type="button">更换</button>
</div>
</div>
<div class="layui-form-item">
@ -153,6 +152,12 @@
{% endblock %}
{% block include_js %}
{{ js_include('admin/js/avatar.upload.js') }}
{% endblock %}
{% block inline_js %}
<script>
@ -163,12 +168,6 @@
var form = layui.form;
var laydate = layui.laydate;
$('#clear-avatar').on('click', function () {
var defaultAvatar = $('input[name=default_avatar]').val();
$('input[name=avatar]').val(defaultAvatar);
$('#avatar').attr('src', defaultAvatar);
});
laydate.render({
elem: 'input[name=vip_expiry_time]',
type: 'datetime'
@ -201,4 +200,4 @@
</script>
{% endblock %}
{% endblock %}

View File

@ -30,8 +30,6 @@ class Controller extends \Phalcon\Mvc\Controller
$this->setCors();
}
$this->checkRateLimit();
return true;
}

View File

@ -7,7 +7,7 @@
namespace App\Http\Api\Controllers;
use App\Services\Logic\Live\LiveChapter as LiveChapterService;
use App\Services\Logic\Live\LiveChat as LiveChatService;
use App\Services\Logic\Live\LiveList as LiveListService;
/**
@ -33,7 +33,7 @@ class LiveController extends Controller
*/
public function chatsAction($id)
{
$service = new LiveChapterService();
$service = new LiveChatService();
$chats = $service->getRecentChats($id);
@ -45,7 +45,7 @@ class LiveController extends Controller
*/
public function statsAction($id)
{
$service = new LiveChapterService();
$service = new LiveChatService();
$stats = $service->getStats($id);
@ -57,7 +57,7 @@ class LiveController extends Controller
*/
public function statusAction($id)
{
$service = new LiveChapterService();
$service = new LiveChatService();
$status = $service->getStatus($id);
@ -69,7 +69,7 @@ class LiveController extends Controller
*/
public function bindUserAction($id)
{
$service = new LiveChapterService();
$service = new LiveChatService();
$service->bindUser($id);
@ -81,7 +81,7 @@ class LiveController extends Controller
*/
public function sendMessageAction($id)
{
$service = new LiveChapterService();
$service = new LiveChatService();
$message = $service->sendMessage($id);

View File

@ -34,7 +34,7 @@ class AccountController extends Controller
}
if ($this->authUser->id > 0) {
return $this->response->redirect('/');
return $this->response->redirect(['for' => 'home.index']);
}
$returnUrl = $this->request->getHTTPReferer();
@ -62,7 +62,7 @@ class AccountController extends Controller
}
if ($this->authUser->id > 0) {
return $this->response->redirect('/');
return $this->response->redirect(['for' => 'home.index']);
}
$service = new OAuthProviderService();
@ -105,7 +105,7 @@ class AccountController extends Controller
return $this->response->redirect(['for' => 'home.index']);
}
$this->seo->prependTitle('重置密码');
$this->seo->prependTitle('忘记密码');
}
/**
@ -119,9 +119,11 @@ class AccountController extends Controller
$returnUrl = $this->request->getPost('return_url', 'string');
$location = $returnUrl ?: $this->url->get(['for' => 'home.index']);
$content = [
'location' => $returnUrl ?: '/',
'msg' => '注册成功',
'location' => $location,
'msg' => '注册账号成功',
];
return $this->jsonSuccess($content);
@ -140,7 +142,12 @@ class AccountController extends Controller
$location = $returnUrl ?: $this->url->get(['for' => 'home.index']);
return $this->jsonSuccess(['location' => $location]);
$content = [
'location' => $location,
'msg' => '登录账号成功',
];
return $this->jsonSuccess($content);
}
/**
@ -156,7 +163,12 @@ class AccountController extends Controller
$location = $returnUrl ?: $this->url->get(['for' => 'home.index']);
return $this->jsonSuccess(['location' => $location]);
$content = [
'location' => $location,
'msg' => '登录账号成功',
];
return $this->jsonSuccess($content);
}
/**

View File

@ -120,27 +120,21 @@ class ConnectController extends Controller
$service = new ConnectService();
$openUser = $service->getOpenUserInfo($code, $state, $provider);
$connect = $service->getConnectRelation($openUser['id'], $openUser['provider']);
if ($this->authUser->id > 0) {
if ($openUser) {
$service->bindUser($openUser);
return $this->response->redirect(['for' => 'home.uc.account']);
}
} else {
if ($connect) {
$service->authConnectLogin($connect);
return $this->response->redirect(['for' => 'home.index']);
}
if ($this->authUser->id > 0 && $openUser) {
$service->bindUser($openUser);
return $this->response->redirect(['for' => 'home.uc.account']);
}
$captcha = $service->getSettings('captcha');
if ($this->authUser->id == 0 && $connect) {
$service->authConnectLogin($connect);
return $this->response->redirect(['for' => 'home.index']);
}
$this->seo->prependTitle('绑定帐号');
$this->view->pick('connect/bind');
$this->view->setVar('captcha', $captcha);
$this->view->setVar('provider', $provider);
$this->view->setVar('open_user', $openUser);
}

View File

@ -77,8 +77,14 @@ class ConsultController extends Controller
$consult = $service->handle($consult->id);
$location = $this->url->get([
'for' => 'home.course.show',
'id' => $consult['course']['id'],
]);
$content = [
'consult' => $consult,
'location' => $location,
'target' => 'parent',
'msg' => '提交咨询成功',
];
@ -92,14 +98,13 @@ class ConsultController extends Controller
{
$service = new ConsultUpdateService();
$consult = $service->handle($id);
$service->handle($id);
$service = new ConsultInfoService();
$consult = $service->handle($consult->id);
$location = $this->url->get(['for' => 'home.uc.consults']);
$content = [
'consult' => $consult,
'location' => $location,
'target' => 'parent',
'msg' => '更新咨询成功',
];
@ -127,14 +132,13 @@ class ConsultController extends Controller
$service = new ConsultReplyService();
$consult = $service->handle($id);
$service->handle($id);
$service = new ConsultInfoService();
$consult = $service->handle($consult->id);
$location = $this->url->get(['for' => 'home.tc.consults']);
$content = [
'consult' => $consult,
'location' => $location,
'target' => 'parent',
'msg' => '回复咨询成功',
];

View File

@ -77,8 +77,6 @@ class Controller extends \Phalcon\Mvc\Controller
$this->checkCsrfToken();
}
$this->checkRateLimit();
return true;
}

View File

@ -37,8 +37,6 @@ class LayerController extends \Phalcon\Mvc\Controller
$this->checkCsrfToken();
}
$this->checkRateLimit();
return true;
}

View File

@ -7,7 +7,7 @@
namespace App\Http\Home\Controllers;
use App\Services\Logic\Live\LiveChapter as LiveChapterService;
use App\Services\Logic\Live\LiveChat as LiveChatService;
use Phalcon\Mvc\View;
/**
@ -21,7 +21,7 @@ class LiveController extends Controller
*/
public function chatsAction($id)
{
$service = new LiveChapterService();
$service = new LiveChatService();
$chats = $service->getRecentChats($id);
@ -35,7 +35,7 @@ class LiveController extends Controller
*/
public function statsAction($id)
{
$service = new LiveChapterService();
$service = new LiveChatService();
$stats = $service->getStats($id);
@ -47,7 +47,7 @@ class LiveController extends Controller
*/
public function statusAction($id)
{
$service = new LiveChapterService();
$service = new LiveChatService();
$status = $service->getStatus($id);
@ -59,7 +59,7 @@ class LiveController extends Controller
*/
public function bindUserAction($id)
{
$service = new LiveChapterService();
$service = new LiveChatService();
$service->bindUser($id);
@ -71,7 +71,7 @@ class LiveController extends Controller
*/
public function sendMessageAction($id)
{
$service = new LiveChapterService();
$service = new LiveChatService();
$response = $service->sendMessage($id);

View File

@ -104,7 +104,7 @@ class PublicController extends \Phalcon\Mvc\Controller
}
/**
* @Get("/alipay/callback", name="home.alipay_callback")
* @Get("/alipay/callback", name="home.alipay.callback")
*/
public function alipayCallbackAction()
{
@ -112,7 +112,7 @@ class PublicController extends \Phalcon\Mvc\Controller
}
/**
* @Get("/wxpay/callback", name="home.wxpay_callback")
* @Get("/wxpay/callback", name="home.wxpay.callback")
*/
public function wxpayCallbackAction()
{
@ -120,7 +120,7 @@ class PublicController extends \Phalcon\Mvc\Controller
}
/**
* @Post("/alipay/notify", name="home.alipay_notify")
* @Post("/alipay/notify", name="home.alipay.notify")
*/
public function alipayNotifyAction()
{
@ -136,7 +136,7 @@ class PublicController extends \Phalcon\Mvc\Controller
}
/**
* @Post("/wxpay/notify", name="home.wxpay_notify")
* @Post("/wxpay/notify", name="home.wxpay.notify")
*/
public function wxpayNotifyAction()
{
@ -188,7 +188,7 @@ class PublicController extends \Phalcon\Mvc\Controller
}
/**
* @Post("/live/notify", name="home.live_notify")
* @Post("/live/notify", name="home.live.notify")
*/
public function liveNotifyAction()
{
@ -198,6 +198,7 @@ class PublicController extends \Phalcon\Mvc\Controller
return $this->jsonSuccess();
} else {
$this->response->setStatusCode(403);
return $this->jsonError();
}
}

View File

@ -49,7 +49,15 @@ class RefundController extends Controller
$service->handle();
return $this->jsonSuccess(['msg' => '申请退款成功']);
$location = $this->url->get(['for' => 'home.uc.refunds']);
$content = [
'location' => $location,
'target' => 'parent',
'msg' => '提交申请成功',
];
return $this->jsonSuccess($content);
}
/**

View File

@ -55,13 +55,6 @@ class ReviewController extends Controller
$this->notFound();
}
$approved = $review['published'] == ReviewModel::PUBLISH_APPROVED;
$owned = $review['me']['owned'] == 1;
if (!$approved && !$owned) {
$this->notFound();
}
return $this->jsonSuccess(['review' => $review]);
}
@ -72,14 +65,13 @@ class ReviewController extends Controller
{
$service = new ReviewCreateService();
$review = $service->handle();
$service->handle();
$service = new ReviewInfoService();
$review = $service->handle($review->id);
$location = $this->url->get(['for' => 'home.uc.reviews']);
$content = [
'review' => $review,
'location' => $location,
'target' => 'parent',
'msg' => '发布评价成功',
];
@ -95,12 +87,11 @@ class ReviewController extends Controller
$service->handle($id);
$service = new ReviewInfoService();
$review = $service->handle($id);
$location = $this->url->get(['for' => 'home.uc.reviews']);
$content = [
'review' => $review,
'location' => $location,
'target' => 'parent',
'msg' => '更新评价成功',
];

View File

@ -24,12 +24,9 @@ class WeChatOfficialAccountController extends Controller
*/
public function bindAction()
{
$captcha = $this->getSettings('captcha');
$this->seo->prependTitle('绑定帐号');
$this->view->pick('wechat/oa/bind');
$this->view->setVar('captcha', $captcha);
}
/**

View File

@ -14,6 +14,7 @@ use App\Repos\User as UserRepo;
use App\Services\Auth\Home as AuthService;
use App\Services\Logic\Account\Register as RegisterService;
use App\Services\Logic\Notice\External\AccountLogin as AccountLoginNotice;
use App\Services\Logic\WeChat\OfficialAccount as WeChatOAService;
use App\Validators\Account as AccountValidator;
use App\Validators\WeChatOfficialAccount as WeChatOAValidator;
@ -63,10 +64,13 @@ class WeChatOfficialAccount extends Service
$openId = $validator->checkLoginOpenId($post['ticket']);
$unionId = $this->getUnionId($openId);
$connect = new ConnectModel();
$connect->user_id = $user->id;
$connect->open_id = $openId;
$connect->union_id = $unionId;
$connect->provider = ConnectModel::PROVIDER_WECHAT_OA;
$connect->create();
@ -86,6 +90,8 @@ class WeChatOfficialAccount extends Service
$openId = $validator->checkLoginOpenId($post['ticket']);
$unionId = $this->getUnionId($openId);
$registerService = new RegisterService();
$account = $registerService->handle();
@ -98,6 +104,7 @@ class WeChatOfficialAccount extends Service
$connect->user_id = $user->id;
$connect->open_id = $openId;
$connect->union_id = $unionId;
$connect->provider = ConnectModel::PROVIDER_WECHAT_OA;
$connect->create();
@ -111,6 +118,17 @@ class WeChatOfficialAccount extends Service
$this->eventsManager->fire('Account:afterRegister', $this, $user);
}
protected function getUnionId($openId)
{
$service = new WeChatOAService();
$app = $service->getOfficialAccount();
$user = $app->user->get($openId);
return $user['unionid'] ?: '';
}
protected function getAppAuth()
{
/**

View File

@ -36,6 +36,6 @@
</form>
{% else %}
<div class="register-close-tips">
<i class="layui-icon layui-icon-tips"></i> 邮箱注册已关闭
<i class="layui-icon layui-icon-lock"></i> 邮箱注册已关闭
</div>
{% endif %}
{% endif %}

View File

@ -36,6 +36,6 @@
</form>
{% else %}
<div class="register-close-tips">
<i class="layui-icon layui-icon-tips"></i> 手机注册已关闭
<i class="layui-icon layui-icon-lock"></i> 手机注册已关闭
</div>
{% endif %}
{% endif %}

View File

@ -1,35 +1,44 @@
{%- macro model_icon(model) %}
{% if model == 1 %}
<i class="iconfont icon-video"></i>
{% elseif model == 2 %}
<i class="iconfont icon-live"></i>
{% elseif model == 3 %}
<i class="iconfont icon-article"></i>
{% elseif model == 4 %}
<i class="layui-icon layui-icon-user"></i>
{% endif %}
{%- endmacro %}
{%- macro show_lesson_list(parent,chapter) %}
<ul class="sidebar-lesson-list">
{% for lesson in parent.children %}
{% set url = url({'for':'home.chapter.show','id':lesson.id}) %}
{% set active = (chapter.id == lesson.id) ? 'active' : 'normal' %}
<li class="lesson-title layui-elip">
{% if lesson.me.owned == 1 %}
<a class="{{ active }}" href="{{ url }}" title="{{ lesson.title }}">{{ lesson.title }}</a>
{% else %}
<span class="deny" title="{{ lesson.title }}">{{ lesson.title }}</span>
{% set active = chapter.id == lesson.id ? 'active' : 'normal' %}
{% set priv = lesson.me.owned == 1 ? 'allow' : 'deny' %}
<li class="sidebar-lesson layui-elip {{ priv }} {{ active }}" data-url="{{ url }}">
<span class="model">{{ model_icon(lesson.model) }}</span>
<span class="title" title="{{ lesson.title }}">{{ lesson.title }}</span>
{% if lesson.me.owned == 0 %}
<span class="lock"><i class="iconfont icon-lock"></i></span>
{% endif %}
</li>
{% endfor %}
</ul>
{%- endmacro %}
<div class="layui-card sidebar-card sidebar-chapter">
<div class="layui-card sidebar-card sidebar-catalog">
<div class="layui-card-header">课程目录</div>
<div class="layui-card-body">
{% if catalog|length > 1 %}
<div class="sidebar-chapter-list">
{% for item in catalog %}
<div class="chapter-title layui-elip">{{ item.title }}</div>
<div class="sidebar-lesson-list">
{{ show_lesson_list(item,chapter) }}
</div>
<div class="sidebar-chapter layui-elip">{{ item.title }}</div>
{{ show_lesson_list(item,chapter) }}
{% endfor %}
</div>
{% else %}
<div class="sidebar-lesson-list">
{{ show_lesson_list(catalog[0],chapter) }}
</div>
{{ show_lesson_list(catalog[0],chapter) }}
{% endif %}
</div>
</div>
</div>

View File

@ -35,11 +35,7 @@
<div class="layui-card-body">
<div class="chat-msg-list" id="chat-msg-list" data-url="{{ live_chats_url }}"></div>
<form class="layui-form chat-msg-form" method="post" action="{{ send_msg_url }}">
{% if auth_user.id > 0 %}
<input class="layui-input" type="text" name="content" maxlength="50" placeholder="快来一起互动吧" lay-verType="tips" lay-verify="required">
{% else %}
<input class="layui-input" type="text" placeholder="登录后才可以发言哦" readonly="readonly">
{% endif %}
<input class="layui-input" type="text" name="content" maxlength="50" placeholder="快来一起互动吧" lay-vertype="tips" lay-verify="required">
<button class="layui-hide" type="submit" lay-submit="true" lay-filter="chat">发送</button>
</form>
</div>
@ -80,4 +76,4 @@
{{ js_include('home/js/course.share.js') }}
{{ js_include('home/js/copy.js') }}
{% endblock %}
{% endblock %}

View File

@ -1,9 +1,15 @@
{% for chat in chats %}
<div class="chat">
{% if chat.user.vip == 1 %}
<span class="layui-icon layui-icon-diamond icon-vip"></span>
{% endif %}
<span class="user">{{ chat.user.name }}</span>
<span class="content">{{ chat.content }}</span>
</div>
{% endfor %}
{% if chat.user.vip == 1 %}
<div class="chat chat-vip">
<span class="icon"><i class="layui-icon layui-icon-diamond"></i></span>
<span class="user layui-badge layui-bg-orange">{{ chat.user.name }}</span>
<span class="content">{{ chat.content }}</span>
</div>
{% else %}
<div class="chat chat-normal">
<span class="icon"><i class="layui-icon layui-icon-username"></i></span>
<span class="user layui-badge layui-bg-blue">{{ chat.user.name }}</span>
<span class="content">{{ chat.content }}</span>
</div>
{% endif %}
{% endfor %}

View File

@ -11,9 +11,9 @@
</span>
</div>
<div class="preview">
<div class="live-preview">
<div class="icon"><i class="layui-icon layui-icon-face-cry"></i></div>
<div class="tips">直播已禁止,谢谢关注!</div>
</div>
{% endblock %}
{% endblock %}

View File

@ -13,19 +13,19 @@
</div>
{% if time() < chapter.start_time %}
<div class="preview countdown">
<div class="live-preview countdown wrap">
<div class="icon"><i class="layui-icon layui-icon-time"></i></div>
<div class="timer"></div>
<div class="tips">直播倒计时开始啦,敬请关注!</div>
</div>
{% elseif chapter.start_time < time() and chapter.end_time > time() %}
<div class="preview countdown">
<div class="live-preview countdown wrap">
<div class="icon"><i class="layui-icon layui-icon-face-surprised"></i></div>
<div class="timer"></div>
<div class="tips">直播时间到了,老师去哪了?</div>
</div>
{% else %}
<div class="preview">
<div class="live-preview wrap">
<div class="icon"><i class="layui-icon layui-icon-tree"></i></div>
<div class="tips">直播已结束,谢谢关注!</div>
</div>
@ -43,4 +43,4 @@
{{ js_include('home/js/chapter.live.countdown.js') }}
{% endblock %}
{% endblock %}

View File

@ -7,7 +7,7 @@
<div class="icon" title="{{ like_title }}" data-url="{{ like_url }}">
<i class="layui-icon layui-icon-praise icon-praise {{ like_class }}"></i>
</div>
<div class="text">{{ chapter.like_count }}</div>
<div class="text" data-count="{{ chapter.like_count }}">{{ chapter.like_count }}</div>
</div>
<div class="item" id="toolbar-online">
<div class="icon" title="在线人数">
@ -15,4 +15,4 @@
</div>
<div class="text">0</div>
</div>
</div>
</div>

View File

@ -1,103 +1,118 @@
{%- macro show_lesson_list(chapter) %}
<ul class="lesson-list">
{% for lesson in chapter.children %}
{% set url = url({'for':'home.chapter.show','id':lesson.id}) %}
{% set priv = lesson.me.owned ? 'allow' : 'deny' %}
{% if lesson.model == 1 %}
<li class="lesson-item">{{ vod_lesson_info(lesson) }}</li>
<li class="lesson-item {{ priv }}" data-url="{{ url }}">{{ vod_lesson_info(lesson) }}</li>
{% elseif lesson.model == 2 %}
<li class="lesson-item">{{ live_lesson_info(lesson) }}</li>
<li class="lesson-item {{ priv }}" data-url="{{ url }}">{{ live_lesson_info(lesson) }}</li>
{% elseif lesson.model == 3 %}
<li class="lesson-item">{{ read_lesson_info(lesson) }}</li>
<li class="lesson-item {{ priv }}" data-url="{{ url }}">{{ read_lesson_info(lesson) }}</li>
{% elseif lesson.model == 4 %}
<li class="lesson-item">{{ offline_lesson_info(lesson) }}</li>
<li class="lesson-item deny" data-url="{{ url }}">{{ offline_lesson_info(lesson) }}</li>
{% endif %}
{% endfor %}
</ul>
{%- endmacro %}
{%- macro vod_lesson_info(lesson) %}
{% set url = lesson.me.owned ? url({'for':'home.chapter.show','id':lesson.id}) : '' %}
{% set priv = lesson.me.owned ? 'allow' : 'deny' %}
<a class="{{ priv }} view-lesson" href="javascript:" data-url="{{ url }}">
<i class="layui-icon layui-icon-play"></i>
<div class="left">
<span class="model"><i class="iconfont icon-video"></i></span>
<span class="title">{{ lesson.title }}</span>
{% if lesson.free == 1 %}
<span class="iconfont icon-trial"></span>
{% endif %}
{% if lesson.me.duration > 0 %}
<span class="study-time" title="学习时长:{{ lesson.me.duration|duration }}"><i class="layui-icon layui-icon-time"></i></span>
{% endif %}
{% if priv == 'deny' %}
<span class="iconfont icon-lock"></span>
{% if lesson.me.owned == 0 %}
<span class="lock"><i class="iconfont icon-lock"></i></span>
{% endif %}
{% if lesson.free == 1 %}
<span class="flag flag-free">试听</span>
{% endif %}
</div>
<div class="right">
<span class="duration">{{ lesson.attrs.duration|duration }}</span>
</a>
</div>
{%- endmacro %}
{%- macro live_lesson_info(lesson) %}
{% set url = lesson.me.owned ? url({'for':'home.chapter.show','id':lesson.id}) : '' %}
{% set priv = lesson.me.owned ? 'allow' : 'deny' %}
<a class="{{ priv }} view-lesson" href="javascript:" data-url="{{ url }}">
<i class="layui-icon layui-icon-video"></i>
<div class="left">
<span class="model"><i class="iconfont icon-live"></i></span>
<span class="title">{{ lesson.title }}</span>
{% if lesson.free == 1 %}
<span class="iconfont icon-trial"></span>
{% endif %}
{% if lesson.me.duration > 0 %}
<span class="study-time" title="学习时长:{{ lesson.me.duration|duration }}"><i class="layui-icon layui-icon-time"></i></span>
{% endif %}
{% if priv == 'deny' %}
<span class="iconfont icon-lock"></span>
{% if lesson.me.owned == 0 %}
<span class="lock"><i class="iconfont icon-lock"></i></span>
{% endif %}
<span class="live" title="{{ date('Y-m-d H:i',lesson.attrs.start_time) }}">{{ live_status_info(lesson) }}</span>
</a>
{% if lesson.attrs.playback.ready == 1 %}
<span class="flag flag-playback">回放</span>
{% endif %}
{% if lesson.free == 1 %}
<span class="flag flag-free">试听</span>
{% endif %}
</div>
<div class="right">
<span class="live-status">{{ live_status_info(lesson) }}</span>
<span class="live-time">{{ date('Y-m-d H:i',lesson.attrs.start_time) }}</span>
</div>
{%- endmacro %}
{%- macro read_lesson_info(lesson) %}
{% set url = lesson.me.owned ? url({'for':'home.chapter.show','id':lesson.id}) : '' %}
{% set priv = lesson.me.owned ? 'allow' : 'deny' %}
<a class="{{ priv }} view-lesson" href="javascript:" data-url="{{ url }}">
<i class="layui-icon layui-icon-read"></i>
<div class="left">
<span class="model"><i class="iconfont icon-article"></i></span>
<span class="title">{{ lesson.title }}</span>
{% if lesson.free == 1 %}
<span class="iconfont icon-trial"></span>
{% endif %}
{% if lesson.me.duration > 0 %}
<span class="study-time" title="学习时长:{{ lesson.me.duration|duration }}"><i class="layui-icon layui-icon-time"></i></span>
{% endif %}
{% if priv == 'deny' %}
<span class="iconfont icon-lock"></span>
{% if lesson.me.owned == 0 %}
<span class="lock"><i class="iconfont icon-lock"></i></span>
{% endif %}
</a>
{% if lesson.free == 1 %}
<span class="flag flag-free">试读</span>
{% endif %}
</div>
<div class="right">
<span class="size"></span>
</div>
{%- endmacro %}
{%- macro offline_lesson_info(lesson) %}
<a class="deny view-lesson" href="javascript:">
<i class="layui-icon layui-icon-user"></i>
<div class="left">
<span class="model"><i class="layui-icon layui-icon-user"></i></span>
<span class="title">{{ lesson.title }}</span>
{% if lesson.free == 1 %}
<span class="layui-badge free-badge">试听</span>
{% if lesson.me.owned == 0 %}
<span class="lock"><i class="iconfont icon-lock"></i></span>
{% endif %}
<span class="live" title="{{ date('Y-m-d H:i',lesson.attrs.start_time) }}">{{ offline_status_info(lesson) }}</span>
</a>
{% if lesson.free == 1 %}
<span class="flag flag-free">试听</span>
{% endif %}
</div>
<div class="right">
<span class="live-status">{{ offline_status_info(lesson) }}</span>
<span class="live-time">{{ date('Y-m-d H:i',lesson.attrs.start_time) }}</span>
</div>
{%- endmacro %}
{%- macro live_status_info(lesson) %}
{% if lesson.attrs.stream.status == 'active' %}
<span class="active">{{ date('m月d日 H:i',lesson.attrs.start_time) }} 直播中</span>
<span class="flag flag-active">直播中</span>
{% elseif lesson.attrs.start_time > time() %}
<span class="pending">{{ date('m月d日 H:i',lesson.attrs.start_time) }} 倒计时</span>
<span class="flag flag-scheduled">倒计时</span>
{% elseif lesson.attrs.end_time < time() %}
<span class="finished">{{ date('m月d日 H:i',lesson.attrs.start_time) }} 已结束</span>
<span class="flag flag-ended">已结束</span>
{% elseif lesson.attrs.stream.status == 'inactive' %}
<span class="flag flag-inactive">未推流</span>
{% endif %}
{%- endmacro %}
{%- macro offline_status_info(lesson) %}
{% if lesson.attrs.start_time < time() and lesson.attrs.end_time > time() %}
<span class="active">{{ date('m月d日 H:i',lesson.attrs.start_time) }} 授课中</span>
<span class="flag flag-active">授课中</span>
{% elseif lesson.attrs.start_time > time() %}
<span class="pending">{{ date('m月d日 H:i',lesson.attrs.start_time) }} 未开始</span>
<span class="flag flag-scheduled">未开始</span>
{% elseif lesson.attrs.end_time < time() %}
<span class="finished">{{ date('m月d日 H:i',lesson.attrs.start_time) }} 已结束</span>
<span class="flag flag-ended">已结束</span>
{% endif %}
{%- endmacro %}
@ -119,4 +134,4 @@
{% else %}
{{ show_lesson_list(chapters[0]) }}
{% endif %}
{% endif %}
{% endif %}

View File

@ -105,21 +105,21 @@
{{ offline_meta_info(course) }}
{% endif %}
</div>
<div class="rating">
<div class="ratings">
<p class="item">
<span class="name">内容实用</span>
<span class="star">{{ star_info(course.ratings.rating1) }}</span>
<span class="star" id="rating1" data-value="{{ course.ratings.rating1 }}"></span>
<span class="score">{{ "%0.1f"|format(course.ratings.rating1) }} 分</span>
</p>
<p class="item">
<span class="name">简洁易懂</span>
<span class="star">{{ star_info(course.ratings.rating2) }}</span>
<span class="star" id="rating2" data-value="{{ course.ratings.rating2 }}"></span>
<span class="score">{{ "%0.1f"|format(course.ratings.rating2) }} 分</span>
</p>
<p class="item">
<span class="name">逻辑清晰</span>
<span class="star">{{ star_info(course.ratings.rating3) }}</span>
<span class="star" id="rating3" data-value="{{ course.ratings.rating3 }}"></span>
<span class="score">{{ "%0.1f"|format(course.ratings.rating3) }} 分</span>
</p>
</div>
</div>
</div>

View File

@ -26,8 +26,8 @@
{% endif %}
<div class="item" id="toolbar-favorite">
<div class="icon" title="{{ favorite_title }}" data-url="{{ favorite_url }}">
<i class="layui-icon layui-icon-star icon-star {{ favorite_class }}"></i>
<i class="layui-icon icon-star {{ favorite_class }}"></i>
</div>
<div class="text" data-count="{{ course.favorite_count }}">{{ course.favorite_count }}</div>
</div>
</div>
</div>

View File

@ -31,17 +31,10 @@
{% endblock %}
{% block inline_js %}
{% block include_js %}
<script>
layui.use(['jquery', 'helper'], function () {
var $ = layui.jquery;
var helper = layui.helper;
var $courseList = $('#course-list');
if ($courseList.length > 0) {
helper.ajaxLoadHtml($courseList.data('url'), $courseList.attr('id'));
}
});
</script>
{{ js_include('lib/clipboard.min.js') }}
{{ js_include('home/js/help.show.js') }}
{{ js_include('home/js/copy.js') }}
{% endblock %}
{% endblock %}

View File

@ -10,7 +10,7 @@
{% if course.model in [1,2,3] %}
<p>
<span>学习期限:{{ date('Y-m-d',course.study_expiry_time) }}</span>
<span>退款期限:{{ date('Y-m-d',course.refund_expiry_time) }}</span>
<span>退款期限:{{ course.refund_expiry > 0 ? date('Y-m-d',course.refund_expiry_time) : '不支持' }}</span>
</p>
{% elseif course.model == 4 %}
<p>上课时间:{{ course.attrs.start_date }} ~ {{ course.attrs.end_date }}</p>
@ -23,13 +23,13 @@
<div class="order-item">
<p>课程名称:{{ course.title }}</p>
<p>
<span>市场价格:{{ '¥%0.2f'|format(course.market_price) }}</span>
<span>市场价格:<em class="price">{{ '¥%0.2f'|format(course.market_price) }}</em></span>
<span>会员价格:<em class="price">{{ '¥%0.2f'|format(course.vip_price) }}</em></span>
</p>
{% if course.model in [1,2,3] %}
<p>
<span>学习期限:{{ date('Y-m-d',course.study_expiry_time) }}</span>
<span>退款期限:{{ date('Y-m-d',course.refund_expiry_time) }}</span>
<span>退款期限:{{ course.refund_expiry > 0 ? date('Y-m-d',course.refund_expiry_time) : '不支持' }}</span>
</p>
{% endif %}
</div>

View File

@ -26,7 +26,7 @@
<a class="layui-btn layui-bg-blue" href="{{ order_pay_url }}" target="_top">立即支付</a>
{% endif %}
{% if order.me.allow_cancel == 1 %}
<a class="layui-btn layui-bg-red order-cancel" href="javascript:" data-sn="{{ order.sn }}" data-url="{{ order_cancel_url }}">立即取消</a>
<button class="layui-btn layui-bg-red btn-order-cancel" data-sn="{{ order.sn }}" data-url="{{ order_cancel_url }}">立即取消</button>
{% endif %}
{% if order.me.allow_refund == 1 %}
<a class="layui-btn layui-bg-blue" href="{{ refund_confirm_url }}">申请退款</a>
@ -39,4 +39,4 @@
{{ js_include('home/js/order.info.js') }}
{% endblock %}
{% endblock %}

View File

@ -30,17 +30,10 @@
{% endblock %}
{% block inline_js %}
{% block include_js %}
<script>
layui.use(['jquery', 'helper'], function () {
var $ = layui.jquery;
var helper = layui.helper;
var $courseList = $('#course-list');
if ($courseList.length > 0) {
helper.ajaxLoadHtml($courseList.data('url'), $courseList.attr('id'));
}
});
</script>
{{ js_include('lib/clipboard.min.js') }}
{{ js_include('home/js/page.show.js') }}
{{ js_include('home/js/copy.js') }}
{% endblock %}
{% endblock %}

View File

@ -9,7 +9,7 @@
<div class="order-item">
<p>课程名称:<span>{{ course.title }}</span></p>
<p>退款期限:<span>{{ date('Y-m-d H:i:s',course.refund_expiry_time) }} {{ expiry_flag }}</span></p>
<p>退款金额:<span class="price">{{ '¥%0.2f'|format(course.refund_amount) }}</span>退款比例:<span class="price">{{ 100 * course.refund_percent }}%</span></p>
<p>退款金额:<span class="price">{{ '¥%0.2f'|format(course.refund_amount) }}</span>退款比例:<span class="rate">{{ 100 * course.refund_rate }}%</span></p>
</div>
{% elseif confirm.item_type == 2 %}
{% set courses = confirm.item_info.courses %}
@ -18,7 +18,7 @@
<div class="order-item">
<p>课程名称:<span>{{ course.title }}</span></p>
<p>退款期限:<span>{{ date('Y-m-d H:i:s',course.refund_expiry_time) }} {{ expiry_flag }}</span></p>
<p>退款金额:<span class="price">{{ '¥%0.2f'|format(course.refund_amount) }}</span>退款比例:<span class="price">{{ 100 * course.refund_percent }}%</span></p>
<p>退款金额:<span class="price">{{ '¥%0.2f'|format(course.refund_amount) }}</span>退款比例:<span class="rate">{{ 100 * course.refund_rate }}%</span></p>
</div>
{% endfor %}
{% endif %}
@ -40,12 +40,9 @@
</table>
<br>
{% if confirm.refund_amount > 0 %}
<form class="layui-form layui-form-pane" method="post" action="{{ url({'for':'home.refund.create'}) }}">
<form class="layui-form" method="post" action="{{ url({'for':'home.refund.create'}) }}">
<div class="layui-form-item">
<label class="layui-form-label">退款原因</label>
<div class="layui-input-block">
<input class="layui-input" name="apply_note" lay-verify="required">
</div>
<input class="layui-input" name="apply_note" placeholder="请告知我们退款原因,让我们做的更好..." lay-verify="required">
</div>
<div class="layui-form-item center">
<button class="layui-btn" lay-submit="true" lay-filter="go">提交申请</button>
@ -68,4 +65,4 @@
});
</script>
{% endblock %}
{% endblock %}

View File

@ -9,9 +9,9 @@
<table class="layui-table order-table" lay-size="lg">
<tr>
<td colspan="2">
订单金额:<span class="price">{{ '¥%0.2f'|format(refund.order.amount) }}</span>
退款金额:<span class="price">{{ '¥%0.2f'|format(refund.amount) }}</span>
退款状态:<span class="status">{{ refund_status(refund.status) }}</span>
<span>订单金额:<em class="price">{{ '¥%0.2f'|format(refund.order.amount) }}</em></span>
<span>退款金额:<em class="price">{{ '¥%0.2f'|format(refund.amount) }}</em></span>
<span>退款状态:{{ refund_status(refund.status) }}</span>
</td>
</tr>
<tr>
@ -22,41 +22,8 @@
<br>
<div class="center">
{% if refund.me.allow_cancel == 1 %}
<button class="kg-refund layui-btn" data-sn="{{ refund.sn }}" data-url="{{ cancel_url }}">取消退款</button>
<button class="layui-btn btn-refund-cancel" data-sn="{{ refund.sn }}" data-url="{{ cancel_url }}">取消退款</button>
{% endif %}
</div>
{% endblock %}
{% block inline_js %}
<script>
layui.use(['jquery', 'layer'], function () {
var $ = layui.jquery;
var layer = layui.layer;
var index = parent.layer.getFrameIndex(window.name);
parent.layer.iframeAuto(index);
$('.kg-refund').on('click', function () {
var url = $(this).data('url');
var data = {sn: $(this).data('sn')};
layer.confirm('确定要取消退款吗?', function () {
$.ajax({
type: 'POST',
url: url,
data: data,
success: function (res) {
layer.msg(res.msg, {icon: 1});
setTimeout(function () {
parent.window.location.href = '/uc/refunds';
}, 1500);
}
});
});
});
});
</script>
{% endblock %}

View File

@ -24,9 +24,9 @@
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label" for="content">评价内容</label>
<label class="layui-form-label">评价内容</label>
<div class="layui-input-block">
<textarea name="content" id="content" class="layui-textarea" placeholder="请描述你的学习经历,例如学习成果、课程内容、讲师风格、教学服务等。"></textarea>
<textarea name="content" class="layui-textarea" placeholder="请描述你的学习经历,例如学习成果、课程内容、讲师风格、教学服务等。" lay-verify="required"></textarea>
</div>
</div>
<div class="layui-form-item">
@ -54,4 +54,4 @@
{{ js_include('home/js/user.console.review.js') }}
{% endblock %}
{% endblock %}

View File

@ -26,7 +26,7 @@
<div class="layui-form-item">
<label class="layui-form-label">评价内容</label>
<div class="layui-input-block">
<textarea name="content" class="layui-textarea">{{ review.content }}</textarea>
<textarea name="content" class="layui-textarea" lay-verify="required">{{ review.content }}</textarea>
</div>
</div>
<div class="layui-form-item">
@ -53,4 +53,4 @@
{{ js_include('home/js/user.console.review.js') }}
{% endblock %}
{% endblock %}

View File

@ -19,7 +19,7 @@
{% if item.cover %}
<div class="cover">
<a href="{{ article_url }}" target="_blank">
<img src="{{ item.cover }}!cover_270" alt="{{ item.title }}">
<img src="{{ item.cover }}!cover_270" alt="{{ item.title|striptags }}">
</a>
</div>
{% endif %}

View File

@ -6,7 +6,7 @@
<div class="search-course-card">
<div class="cover">
<a href="{{ course_url }}" target="_blank">
<img src="{{ item.cover }}!cover_270" alt="{{ item.title }}">
<img src="{{ item.cover }}!cover_270" alt="{{ item.title|striptags }}">
</a>
</div>
<div class="info">

View File

@ -19,7 +19,7 @@
{% if item.cover %}
<div class="cover">
<a href="{{ question_url }}" target="_blank">
<img src="{{ item.cover }}!cover_270" alt="{{ item.title }}">
<img src="{{ item.cover }}!cover_270" alt="{{ item.title|striptags }}">
</a>
</div>
{% endif %}

View File

@ -1,6 +1,9 @@
<!DOCTYPE html>
<html lang="zh-CN-Hans">
<head>
{% if site_info.analytics_enabled == 1 %}
{{ site_info.analytics_script }}
{% endif %}
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
@ -38,12 +41,5 @@
{% block include_js %}{% endblock %}
{% block inline_js %}{% endblock %}
{% if site_info.analytics_enabled == 1 %}
<div class="layui-hide">
{{ site_info.analytics_script }}
</div>
{% endif %}
</body>
</html>
</html>

View File

@ -10,10 +10,11 @@
{% set point_enabled = setting('point','enabled') %}
<div class="my-profile-card wrap">
<div class="vip">{{ vip_info(auth_user) }}</div>
<div class="avatar">
<img class="my-avatar" src="{{ auth_user.avatar }}" alt="{{ auth_user.name }}">
</div>
<div class="name">{{ auth_user.name }} {{ vip_info(auth_user) }}</div>
<div class="name">{{ auth_user.name }}</div>
</div>
<div class="layui-card">
@ -71,4 +72,4 @@
<li><a href="{{ url({'for':'home.uc.account'}) }}">帐号安全</a></li>
</ul>
</div>
</div>
</div>

View File

@ -79,7 +79,6 @@
{% block include_js %}
{{ js_include('home/js/user.avatar.upload.js') }}
{{ js_include('home/js/user.console.profile.js') }}
{% endblock %}
{% endblock %}

View File

@ -4,13 +4,13 @@
<div class="vip-header">会员权益</div>
<div class="vip-reason-list wrap">
<span class="layui-badge reason-badge">好课畅学</span>
<span class="layui-badge reason-badge">会员折扣</span>
<span class="layui-badge reason-badge">高清视频</span>
<span class="layui-badge reason-badge">广告免疫</span>
<span class="layui-badge reason-badge">会员标识</span>
<span class="layui-badge reason-badge">贴心服务</span>
<div class="vip-priv-list wrap">
<button class="layui-btn layui-bg-blue">好课畅学</button>
<button class="layui-btn layui-bg-blue">会员折扣</button>
<button class="layui-btn layui-bg-blue">高清视频</button>
<button class="layui-btn layui-bg-blue">广告免疫</button>
<button class="layui-btn layui-bg-blue">会员标识</button>
<button class="layui-btn layui-bg-blue">优先服务</button>
</div>
<div class="vip-header">开通会员</div>
@ -57,4 +57,4 @@
{{ js_include('home/js/vip.index.js') }}
{% endblock %}
{% endblock %}

View File

@ -3,7 +3,7 @@
<div class="layui-row layui-col-space20">
{% for item in pager.items %}
{% set user_url = url({'for':'home.user.show','id':item.id}) %}
<div class="layui-col-md2">
<div class="layui-col-md3">
<div class="user-card">
<div class="avatar">
<a href="{{ user_url }}" title="{{ item.about }}" target="_blank">

View File

@ -16,7 +16,7 @@ class AppInfo
protected $link = 'https://www.koogua.com';
protected $version = '1.7.6';
protected $version = '1.7.8';
public function __get($name)
{

View File

@ -0,0 +1,51 @@
<?php
/**
* @copyright Copyright (c) 2024 深圳市酷瓜软件有限公司
* @license https://opensource.org/licenses/GPL-2.0
* @link https://www.koogua.com
*/
namespace App\Library\Paginator\Adapter;
use App\Library\Paginator\Query as PaginatorQuery;
use Phalcon\Paginator\Adapter\NativeArray as PhNativeArray;
use stdClass;
class NativeArray extends PhNativeArray
{
/**
* @var string
*/
protected $baseUrl;
/**
* @var array
*/
protected $params = [];
public function paginate(): stdClass
{
$pager = parent::paginate();
$query = new PaginatorQuery();
$this->baseUrl = $query->getBaseUrl();
$this->params = $query->getParams();
$pager->first = $this->buildPageUrl($pager->first);
$pager->previous = $this->buildPageUrl($pager->previous);
$pager->next = $this->buildPageUrl($pager->next);
$pager->last = $this->buildPageUrl($pager->last);
return $pager;
}
protected function buildPageUrl($page)
{
$this->params['page'] = $page;
return $this->baseUrl . '?' . http_build_query($this->params);
}
}

View File

@ -29,8 +29,16 @@ class Connect extends Repository
$query->andWhere('user_id = :user_id:', ['user_id' => $where['user_id']]);
}
if (!empty($where['open_id'])) {
$query->andWhere('open_id = :open_id:', ['open_id' => $where['open_id']]);
}
if (!empty($where['provider'])) {
$query->andWhere('provider = :provider:', ['provider' => $where['provider']]);
if (is_array($where['provider'])) {
$query->inWhere('provider', $where['provider']);
} else {
$query->andWhere('provider = :provider:', ['provider' => $where['provider']]);
}
}
if (isset($where['deleted'])) {
@ -67,19 +75,6 @@ class Connect extends Repository
]);
}
/**
* @param string $openId
* @param int $provider
* @return ConnectModel|Model|bool
*/
public function findByOpenIdShallow($openId, $provider)
{
return ConnectModel::findFirst([
'conditions' => 'open_id = ?1 AND provider = ?2',
'bind' => [1 => $openId, 2 => $provider],
]);
}
/**
* @param int $userId
* @param int $provider

View File

@ -7,7 +7,7 @@
namespace App\Services;
use App\Caches\CourseChapterList as CatalogCache;
use App\Caches\CourseChapterList as CourseChapterListCache;
use App\Models\Chapter as ChapterModel;
use App\Models\ChapterLive as ChapterLiveModel;
use App\Repos\Chapter as ChapterRepo;
@ -175,7 +175,7 @@ class LiveNotify extends Service
protected function rebuildCatalogCache(ChapterModel $chapter)
{
$cache = new CatalogCache();
$cache = new CourseChapterListCache();
$cache->rebuild($chapter->course_id);
}
@ -216,4 +216,4 @@ class LiveNotify extends Service
return $sign == $mySign;
}
}
}

View File

@ -36,6 +36,8 @@ class Register extends LogicService
$accountValidator = new AccountValidator();
$accountValidator->checkRegisterStatus($post['account']);
$accountValidator->checkLoginName($post['account']);
$data = [];

View File

@ -39,10 +39,10 @@ class ChapterList extends LogicService
if (count($chapters) == 0) return [];
if ($user->id > 0 && $this->courseUser) {
if ($user->id > 0) {
$chapters = $this->handleLoginUserChapters($chapters, $course, $user);
} else {
$chapters = $this->handleGuestUserChapters($chapters);
$chapters = $this->handleGuestUserChapters($chapters, $course);
}
return $chapters;
@ -50,7 +50,11 @@ class ChapterList extends LogicService
protected function handleLoginUserChapters(array $chapters, CourseModel $course, UserModel $user)
{
$mappings = $this->getLearningMappings($course->id, $user->id, $this->courseUser->plan_id);
$mappings = [];
if ($this->courseUser) {
$mappings = $this->getLearningMappings($course->id, $user->id, $this->courseUser->plan_id);
}
foreach ($chapters as &$chapter) {
foreach ($chapter['children'] as &$lesson) {
@ -61,23 +65,30 @@ class ChapterList extends LogicService
'owned' => $owned ? 1 : 0,
'logged' => 1,
];
// 如果课程是免费的,但又设置了课时试听,清除试听标识
if ($course->market_price == 0 && $lesson['free'] == 1) {
$lesson['free'] = 0;
}
}
}
return $chapters;
}
protected function handleGuestUserChapters(array $chapters)
protected function handleGuestUserChapters(array $chapters, CourseModel $course)
{
foreach ($chapters as &$chapter) {
foreach ($chapter['children'] as &$lesson) {
$owned = ($this->ownedCourse || $lesson['free'] == 1) && $lesson['published'] == 1;
$lesson['me'] = [
'progress' => 0,
'duration' => 0,
'logged' => 0,
'owned' => $owned ? 1 : 0,
'owned' => 0,
];
// 如果课程是免费的,但又设置了课时试听,清除试听标识
if ($course->market_price == 0 && $lesson['free'] == 1) {
$lesson['free'] = 0;
}
}
}

View File

@ -100,7 +100,7 @@ class CourseInfo extends LogicService
if ($this->courseUser) {
$me['reviewed'] = $this->courseUser->reviewed ? 1 : 0;
$me['progress'] = $this->courseUser->progress ? 1 : 0;
$me['progress'] = $this->courseUser->progress;
$me['plan_id'] = $this->courseUser->plan_id;
}
}

View File

@ -12,7 +12,7 @@ use App\Services\Logic\Service as LogicService;
use App\Validators\Live as LiveValidator;
use GatewayClient\Gateway;
class LiveChapter extends LogicService
class LiveChat extends LogicService
{
use ChapterTrait;

View File

@ -121,7 +121,6 @@ class OrderConfirm extends LogicService
'lesson_count' => $course->lesson_count,
'study_expiry' => $course->study_expiry,
'refund_expiry' => $course->refund_expiry,
'origin_price' => $course->origin_price,
'market_price' => $course->market_price,
'vip_price' => $course->vip_price,
];

View File

@ -33,7 +33,7 @@ class Article extends Handler
'limit' => $limit,
]);
$pager = $paginator->getPaginate();
$pager = $paginator->paginate();
return $this->handleArticles($pager);
}

View File

@ -33,7 +33,7 @@ class Course extends Handler
'limit' => $limit,
]);
$pager = $paginator->getPaginate();
$pager = $paginator->paginate();
return $this->handleCourses($pager);
}

View File

@ -33,7 +33,7 @@ class Question extends Handler
'limit' => $limit,
]);
$pager = $paginator->getPaginate();
$pager = $paginator->paginate();
return $this->handleQuestions($pager);
}

View File

@ -111,6 +111,9 @@ class OfficialAccount extends AppService
$logger->debug('Received Message: ' . json_encode($message));
/**
* 事件类型文档https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Receiving_event_pushes.html
*/
switch ($message['MsgType']) {
case 'event':
switch ($message['Event']) {
@ -161,44 +164,24 @@ class OfficialAccount extends AppService
if ($connect) return null;
/**
* 尼玛不知道为什么又多了个"qrscene_"前缀SCAN事件里面又不带这个前缀
*/
$loginScene = sprintf('qrscene_%s', self::QR_SCENE_LOGIN);
$subscribeScene = sprintf('qrscene_%s', self::QR_SCENE_SUBSCRIBE);
$userId = 0;
if (Text::startsWith($eventKey, $subscribeScene)) {
$userId = str_replace($subscribeScene, '', $eventKey);
} else {
$connect = $connectRepo->findByOpenIdShallow($openId, ConnectModel::PROVIDER_WECHAT_OA);
if ($connect) $userId = $connect->user_id;
/**
* 未关注过服务号,在登录页扫登录场景码,关注服务号
*/
if (Text::startsWith($eventKey, $loginScene)) {
$ticket = str_replace($loginScene, '', $eventKey);
$this->handleLoginPageSubscribe($ticket, $openId);
}
if ($userId > 0) {
$userRepo = new UserRepo();
$user = $userRepo->findById($userId);
if (!$user) return null;
$userInfo = $this->getUserInfo($openId);
$unionId = $userInfo['unionid'] ?: '';
$connect = new ConnectModel();
$connect->user_id = $userId;
$connect->open_id = $openId;
$connect->union_id = $unionId;
$connect->provider = ConnectModel::PROVIDER_WECHAT_OA;
$connect->create();
/**
* 未关注过服务号,在用户中心扫关注场景码,关注服务号
*/
if (Text::startsWith($eventKey, $subscribeScene)) {
$userId = str_replace($subscribeScene, '', $eventKey);
$this->handleAccountPageSubscribe($userId, $openId);
}
return new TextMessage('开心呀,我们又多了一个小伙伴!');
@ -228,19 +211,19 @@ class OfficialAccount extends AppService
$eventKey = $message['EventKey'] ?? '';
if (Text::startsWith($eventKey, self::QR_SCENE_LOGIN)) {
return $this->handleLoginScanEvent($eventKey, $openId);
$ticket = str_replace(self::QR_SCENE_LOGIN, '', $eventKey);
$this->handleLoginPageSubscribe($ticket, $openId);
} elseif (Text::startsWith($eventKey, self::QR_SCENE_SUBSCRIBE)) {
return $this->handleSubscribeScanEvent($eventKey, $openId);
$userId = str_replace(self::QR_SCENE_SUBSCRIBE, '', $eventKey);
$this->handleAccountPageSubscribe($userId, $openId);
}
return $this->emptyReply();
}
protected function handleLoginScanEvent($eventKey, $openId)
protected function handleLoginPageSubscribe($ticket, $openId)
{
$ticket = str_replace(self::QR_SCENE_LOGIN, '', $eventKey);
if (empty($ticket) || empty($openId)) return null;
if (empty($ticket) || empty($openId)) return;
$connectRepo = new ConnectRepo();
@ -256,31 +239,27 @@ class OfficialAccount extends AppService
];
$cache->save($keyName, $content, 30 * 60);
return $this->emptyReply();
}
protected function handleSubscribeScanEvent($eventKey, $openId)
protected function handleAccountPageSubscribe($userId, $openId)
{
$userId = str_replace(self::QR_SCENE_SUBSCRIBE, '', $eventKey);
if (empty($userId) || empty($openId)) return null;
if (empty($userId) || empty($openId)) return;
$userRepo = new UserRepo();
$user = $userRepo->findById($userId);
if (!$user) return null;
$userInfo = $this->getUserInfo($openId);
$unionId = $userInfo['unionid'] ?: '';
if (!$user) return;
$connectRepo = new ConnectRepo();
$connect = $connectRepo->findByOpenId($openId, ConnectModel::PROVIDER_WECHAT_OA);
if ($connect) return null;
if ($connect) return;
$userInfo = $this->getUserInfo($openId);
$unionId = $userInfo['unionid'] ?: '';
$connect = new ConnectModel();
@ -290,8 +269,6 @@ class OfficialAccount extends AppService
$connect->provider = ConnectModel::PROVIDER_WECHAT_OA;
$connect->create();
return $this->emptyReply();
}
protected function handleClickEvent($message)

View File

@ -53,15 +53,15 @@ class Refund extends Service
$serviceFee = $this->getServiceFee($order);
$serviceRate = $this->getServiceRate($order);
$refundPercent = 0.00;
$refundRate = 0.00;
$refundAmount = 0.00;
if ($itemInfo['course']['refund_expiry_time'] > time()) {
$refundPercent = $this->getCourseRefundPercent($order->item_id, $order->owner_id);
$refundAmount = round(($order->amount - $serviceFee) * $refundPercent, 2);
$refundRate = $this->getCourseRefundRate($order->item_id, $order->owner_id);
$refundAmount = round(($order->amount - $serviceFee) * $refundRate, 2);
}
$itemInfo['course']['refund_percent'] = $refundPercent;
$itemInfo['course']['refund_rate'] = $refundRate;
$itemInfo['course']['refund_amount'] = $refundAmount;
return [
@ -95,17 +95,17 @@ class Refund extends Service
$course['cover'] = kg_cos_course_cover_url($course['cover']);
$refundPercent = 0.00;
$refundRate = 0.00;
$refundAmount = 0.00;
if ($course['refund_expiry_time'] > time()) {
$pricePercent = round($course['market_price'] / $totalMarketPrice, 4);
$refundPercent = $this->getCourseRefundPercent($course['id'], $order->owner_id);
$refundAmount = round(($order->amount - $serviceFee) * $pricePercent * $refundPercent, 2);
$priceRate = round($course['market_price'] / $totalMarketPrice, 4);
$refundRate = $this->getCourseRefundRate($course['id'], $order->owner_id);
$refundAmount = round(($order->amount - $serviceFee) * $priceRate * $refundRate, 2);
$totalRefundAmount += $refundAmount;
}
$course['refund_percent'] = $refundPercent;
$course['refund_rate'] = $refundRate;
$course['refund_amount'] = $refundAmount;
}
@ -176,7 +176,7 @@ class Refund extends Service
return $serviceRate;
}
protected function getCourseRefundPercent($courseId, $userId)
protected function getCourseRefundRate($courseId, $userId)
{
$courseRepo = new CourseRepo();

View File

@ -10,6 +10,7 @@ namespace App\Services;
use Phalcon\Logger\Adapter\File as FileLogger;
use Qcloud\Cos\Client as CosClient;
use TencentCloud\Common\Credential;
use TencentCloud\Common\Exception\TencentCloudSDKException;
use TencentCloud\Common\Profile\ClientProfile;
use TencentCloud\Common\Profile\HttpProfile;
use TencentCloud\Sts\V20180813\Models\GetFederationTokenRequest;
@ -100,11 +101,12 @@ class Storage extends Service
$result = $client->GetFederationToken($request);
} catch (\Exception $e) {
} catch (TencentCloudSDKException $e) {
$this->logger->error('Get Tmp Token Exception' . kg_json_encode([
$this->logger->error('Get Tmp Token Exception ' . kg_json_encode([
'code' => $e->getCode(),
'message' => $e->getMessage(),
'requestId' => $e->getRequestId(),
]));
$result = false;
@ -130,11 +132,12 @@ class Storage extends Service
$result = $response['Location'] ? $key : false;
} catch (\Exception $e) {
} catch (TencentCloudSDKException $e) {
$this->logger->error('Put String Exception ' . kg_json_encode([
'code' => $e->getCode(),
'message' => $e->getMessage(),
'requestId' => $e->getRequestId(),
]));
$result = false;
@ -162,11 +165,12 @@ class Storage extends Service
$result = $response['Location'] ? $key : false;
} catch (\Exception $e) {
} catch (TencentCloudSDKException $e) {
$this->logger->error('Put File Exception ' . kg_json_encode([
'code' => $e->getCode(),
'message' => $e->getMessage(),
'requestId' => $e->getRequestId(),
]));
$result = false;
@ -194,11 +198,12 @@ class Storage extends Service
$result = $response['Location'] ? $key : false;
} catch (\Exception $e) {
} catch (TencentCloudSDKException $e) {
$this->logger->error('Delete Object Exception ' . kg_json_encode([
'code' => $e->getCode(),
'message' => $e->getMessage(),
'requestId' => $e->getRequestId(),
]));
$result = false;

View File

@ -1,65 +0,0 @@
<?php
/**
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
* @license https://opensource.org/licenses/GPL-2.0
* @link https://www.koogua.com
*/
namespace App\Services;
class Throttle extends Service
{
public function checkRateLimit()
{
$config = $this->getConfig();
if (!$config->path('throttle.enabled')) {
return true;
}
$cache = $this->getCache();
$sign = $this->getRequestSignature();
$cacheKey = $this->getCacheKey($sign);
if ($cache->ttl($cacheKey) < 1) {
$cache->save($cacheKey, 0, $config->path('throttle.lifetime'));
}
$rateLimit = $cache->get($cacheKey);
if ($rateLimit >= $config->path('throttle.rate_limit')) {
return false;
}
$cache->increment($cacheKey, 1);
return true;
}
protected function getRequestSignature()
{
$authUser = $this->getAuthUser();
if (!empty($authUser['id'])) {
return md5($authUser['id']);
}
$httpHost = $this->request->getHttpHost();
$clientAddress = $this->request->getClientAddress();
if ($httpHost && $clientAddress) {
return md5($httpHost . '|' . $clientAddress);
}
throw new \RuntimeException('Unable to generate request signature');
}
protected function getCacheKey($sign)
{
return "throttle:{$sign}";
}
}

View File

@ -28,13 +28,6 @@ trait Security
$validator->checkHttpReferer();
}
public function checkRateLimit()
{
$validator = new SecurityValidator();
$validator->checkRateLimit();
}
public function isNotSafeRequest()
{
/**

View File

@ -129,6 +129,29 @@ class Account extends Validator
}
}
public function checkRegisterStatus($account)
{
$local = $this->getSettings('oauth.local');
$allowPhone = $local['register_with_phone'] ?? false;
$allowEmail = $local['register_with_email'] ?? false;
$isEmail = CommonValidator::email($account);
$isPhone = CommonValidator::Phone($account);
if (!$allowPhone && !$allowEmail) {
throw new BadRequestException('account.register_disabled');
}
if ($isPhone && !$allowPhone) {
throw new BadRequestException('account.register_with_phone_disabled');
}
if ($isEmail && !$allowEmail) {
throw new BadRequestException('account.register_with_email_disabled');
}
}
public function checkVerifyLogin($name, $code)
{
$this->checkLoginName($name);

View File

@ -11,10 +11,7 @@ use App\Exceptions\BadRequest as BadRequestException;
use App\Models\Order as OrderModel;
use App\Models\Refund as RefundModel;
use App\Models\Trade as TradeModel;
use App\Repos\Course as CourseRepo;
use App\Repos\Order as OrderRepo;
use App\Repos\Package as PackageRepo;
use App\Repos\Vip as VipRepo;
class Order extends Validator
{
@ -50,54 +47,36 @@ class Order extends Validator
return $order;
}
public function checkItemType($itemType)
public function checkItemType($type)
{
$list = OrderModel::itemTypes();
$types = OrderModel::itemTypes();
if (!array_key_exists($itemType, $list)) {
if (!array_key_exists($type, $types)) {
throw new BadRequestException('order.invalid_item_type');
}
return $itemType;
return $type;
}
public function checkCourse($itemId)
public function checkCourse($id)
{
$courseRepo = new CourseRepo();
$validator = new Course();
$course = $courseRepo->findById($itemId);
if (!$course || $course->published == 0) {
throw new BadRequestException('order.item_not_found');
}
return $course;
return $validator->checkCourse($id);
}
public function checkPackage($itemId)
public function checkPackage($id)
{
$packageRepo = new PackageRepo();
$validator = new Package();
$package = $packageRepo->findById($itemId);
if (!$package || $package->published == 0) {
throw new BadRequestException('order.item_not_found');
}
return $package;
return $validator->checkPackage($id);
}
public function checkVip($itemId)
public function checkVip($id)
{
$vipRepo = new VipRepo();
$validator = new Vip();
$vip = $vipRepo->findById($itemId);
if (!$vip || $vip->deleted == 1) {
throw new BadRequestException('order.item_not_found');
}
return $vip;
return $validator->checkVip($id);
}
public function checkAmount($amount)
@ -105,7 +84,7 @@ class Order extends Validator
$value = $this->filter->sanitize($amount, ['trim', 'float']);
if ($value < 0.01 || $value > 100000) {
throw new BadRequestException('order.invalid_pay_amount');
throw new BadRequestException('order.invalid_amount');
}
return $value;
@ -148,7 +127,7 @@ class Order extends Validator
];
if (!in_array($order->item_type, $types)) {
throw new BadRequestException('order.refund_item_unsupported');
throw new BadRequestException('order.refund_not_supported');
}
$orderRepo = new OrderRepo();
@ -167,7 +146,7 @@ class Order extends Validator
];
if ($refund && in_array($refund->status, $scopes)) {
throw new BadRequestException('order.refund_apply_existed');
throw new BadRequestException('order.refund_request_existed');
}
}

View File

@ -8,9 +8,7 @@
namespace App\Validators;
use App\Exceptions\BadRequest as BadRequestException;
use App\Exceptions\ServiceUnavailable as ServiceUnavailableException;
use App\Library\CsrfToken as CsrfTokenService;
use App\Services\Throttle as ThrottleService;
class Security extends Validator
{
@ -53,17 +51,6 @@ class Security extends Validator
}
}
public function checkRateLimit()
{
$service = new ThrottleService();
$result = $service->checkRateLimit();
if (!$result) {
throw new ServiceUnavailableException('security.too_many_requests');
}
}
protected function getCsrfWhitelist()
{
return [];

View File

@ -91,7 +91,7 @@ class Trade extends Validator
];
if ($refund && in_array($refund->status, $scopes)) {
throw new BadRequestException('trade.refund_apply_existed');
throw new BadRequestException('trade.refund_request_existed');
}
}

View File

@ -147,21 +147,6 @@ $config['cors']['allow_headers'] = '*';
*/
$config['cors']['allow_methods'] = ['GET', 'POST', 'OPTIONS'];
/**
* 限流开启
*/
$config['throttle']['enabled'] = true;
/**
* 有效期(秒)
*/
$config['throttle']['lifetime'] = 60;
/**
* 限流频率
*/
$config['throttle']['rate_limit'] = 60;
/**
* 客户端ping服务端间隔
*/

View File

@ -22,7 +22,6 @@ $error['sys.unknown_error'] = '未知错误';
/**
* 安全相关
*/
$error['security.too_many_requests'] = '请求过于频繁';
$error['security.invalid_csrf_token'] = '无效的CSRF令牌';
$error['security.invalid_http_referer'] = '无效请求来源';
@ -57,6 +56,9 @@ $error['account.phone_taken'] = '手机号被占用';
$error['account.pwd_not_match'] = '密码不匹配';
$error['account.origin_pwd_incorrect'] = '原有密码不正确';
$error['account.login_pwd_incorrect'] = '登录密码不正确';
$error['account.register_disabled'] = '注册已关闭';
$error['account.register_with_phone_disabled'] = '手机注册已关闭';
$error['account.register_with_email_disabled'] = '邮箱注册已关闭';
/**
* 用户相关
@ -361,17 +363,15 @@ $error['slide.invalid_publish_status'] = '无效的发布状态';
* 订单相关
*/
$error['order.not_found'] = '订单不存在';
$error['order.invalid_amount'] = '无效的支付金额';
$error['order.invalid_status'] = '无效的状态类型';
$error['order.item_not_found'] = '商品不存在';
$error['order.trade_expired'] = '交易已过期';
$error['order.is_delivering'] = '已经下过单了,正在准备发货中';
$error['order.has_bought_course'] = '已经购买过该课程';
$error['order.has_bought_package'] = '已经购买过该套餐';
$error['order.cancel_not_allowed'] = '当前不允许取消订单';
$error['order.close_not_allowed'] = '当前不允许关闭订单';
$error['order.refund_not_allowed'] = '当前不允许申请退款';
$error['order.refund_item_unsupported'] = '该品类不支持退款';
$error['order.refund_apply_existed'] = '退款申请已经存在';
$error['order.refund_not_supported'] = '该品类不支持退款';
$error['order.refund_request_existed'] = '退款申请已经存在';
/**
* 交易相关
@ -382,7 +382,7 @@ $error['trade.invalid_channel'] = '无效的平台类型';
$error['trade.invalid_status'] = '无效的状态类型';
$error['trade.close_not_allowed'] = '当前不允许关闭交易';
$error['trade.refund_not_allowed'] = '当前不允许交易退款';
$error['trade.refund_apply_existed'] = '退款申请已经存在,请等待处理结果';
$error['trade.refund_request_existed'] = '退款申请已经存在,请等待处理结果';
/**
* 退款相关

View File

@ -294,21 +294,6 @@ final class V20210403184518 extends AbstractMigration
protected function initSettingData()
{
$rows = [
[
'section' => 'captcha',
'item_key' => 'enabled',
'item_value' => '0',
],
[
'section' => 'captcha',
'item_key' => 'app_id',
'item_value' => '',
],
[
'section' => 'captcha',
'item_key' => 'secret_key',
'item_value' => '',
],
[
'section' => 'live.push',
'item_key' => 'domain',
@ -392,7 +377,7 @@ final class V20210403184518 extends AbstractMigration
[
'section' => 'mail',
'item_key' => 'smtp_host',
'item_value' => 'smtp.163.com',
'item_value' => '',
],
[
'section' => 'mail',
@ -412,22 +397,22 @@ final class V20210403184518 extends AbstractMigration
[
'section' => 'mail',
'item_key' => 'smtp_username',
'item_value' => 'xxx@163.com',
'item_value' => '',
],
[
'section' => 'mail',
'item_key' => 'smtp_password',
'item_value' => 'xxx',
'item_value' => '',
],
[
'section' => 'mail',
'item_key' => 'smtp_from_email',
'item_value' => 'xxx@163.com',
'item_value' => '',
],
[
'section' => 'mail',
'item_key' => 'smtp_from_name',
'item_value' => 'XXX有限公司',
'item_value' => '',
],
[
'section' => 'pay.alipay',
@ -617,18 +602,18 @@ final class V20210403184518 extends AbstractMigration
[
'section' => 'sms',
'item_key' => 'signature',
'item_value' => '酷瓜云课堂',
'item_value' => '',
],
[
'section' => 'sms',
'item_key' => 'template',
'item_value' => json_encode([
'verify' => ['enabled' => 1, 'id' => ''],
'order_finish' => ['enabled' => 1, 'id' => ''],
'refund_finish' => ['enabled' => 1, 'id' => ''],
'live_begin' => ['enabled' => 1, 'id' => ''],
'consult_reply' => ['enabled' => 1, 'id' => ''],
'goods_deliver' => ['enabled' => 1, 'id' => ''],
'verify' => ['enabled' => 1, 'id' => 0],
'order_finish' => ['enabled' => 0, 'id' => 0],
'refund_finish' => ['enabled' => 0, 'id' => 0],
'live_begin' => ['enabled' => 0, 'id' => 0],
'consult_reply' => ['enabled' => 0, 'id' => 0],
'goods_deliver' => ['enabled' => 0, 'id' => 0],
]),
],
[
@ -835,12 +820,12 @@ final class V20210403184518 extends AbstractMigration
'section' => 'wechat.oa',
'item_key' => 'notice_template',
'item_value' => json_encode([
'account_login' => ['enabled' => 1, 'id' => ''],
'order_finish' => ['enabled' => 1, 'id' => ''],
'refund_finish' => ['enabled' => 1, 'id' => ''],
'goods_deliver' => ['enabled' => 1, 'id' => ''],
'consult_reply' => ['enabled' => 1, 'id' => ''],
'live_begin' => ['enabled' => 1, 'id' => ''],
'account_login' => ['enabled' => 0, 'id' => 0],
'order_finish' => ['enabled' => 0, 'id' => 0],
'refund_finish' => ['enabled' => 0, 'id' => 0],
'goods_deliver' => ['enabled' => 0, 'id' => 0],
'consult_reply' => ['enabled' => 0, 'id' => 0],
'live_begin' => ['enabled' => 0, 'id' => 0],
]),
],
[

View File

@ -14,21 +14,6 @@
padding-bottom: 0;
}
.layui-copyright {
position: fixed;
z-index: 999;
left: 0;
bottom: 0;
width: 180px;
padding: 10px;
font-size: 12px;
color: rgba(255, 255, 255, .7);
}
.layui-copyright a {
color: rgba(255, 255, 255, .7);
}
.red {
color: red;
}
@ -300,10 +285,6 @@ img.kg-qrcode {
border: 3px solid #999;
}
.kg-order-date {
margin-left: 30px;
}
.kg-order-item {
margin-top: 10px;
padding-top: 10px;

View File

@ -9,28 +9,9 @@ layui.use(['jquery', 'layer', 'upload'], function () {
url: '/admin/upload/avatar/img',
accept: 'images',
acceptMime: 'image/*',
size: 512,
auto: false,
before: function () {
layer.load();
},
choose: function (obj) {
var flag = true;
obj.preview(function (index, file, result) {
var img = new Image();
img.src = result;
img.onload = function () {
if (img.width < 1000 && img.height < 1000) {
obj.upload(index, file);
} else {
flag = false;
layer.msg("图片尺寸必须小于 1000 * 1000");
return false;
}
};
return flag;
});
},
done: function (res, index, upload) {
$('#img-avatar').attr('src', res.data.url);
$('input[name=avatar]').val(res.data.url);
@ -41,4 +22,4 @@ layui.use(['jquery', 'layer', 'upload'], function () {
}
});
});
});

View File

@ -0,0 +1,7 @@
layui.use(['util'], function () {
var util = layui.util;
util.fixbar();
});

View File

@ -112,6 +112,16 @@
margin-bottom: 20px;
}
.breadcrumb .share {
position: absolute;
top: 2px;
right: -5px;
}
.breadcrumb .share a {
margin-right: 5px;
}
.wrap {
padding: 20px;
margin-bottom: 20px;
@ -144,10 +154,6 @@
text-align: center;
}
.layer .pager {
margin-top: 0;
}
.loading {
padding: 30px;
text-align: center;
@ -198,12 +204,6 @@
min-height: 80px;
}
.breadcrumb .share {
position: absolute;
top: 2px;
right: -5px;
}
#header {
left: 0;
top: 0;
@ -313,10 +313,6 @@
line-height: 30px;
}
.cs-sidebar p {
line-height: 40px;
}
.index-wrap {
padding-bottom: 15px;
}
@ -958,11 +954,7 @@
padding-top: 5px;
}
.course-meta .rating {
padding-top: 20px;
}
.course-meta p {
.course-meta .info .meta {
line-height: 35px;
}
@ -977,6 +969,10 @@
right: 15px;
}
.course-meta .info .item {
line-height: 35px;
}
.course-meta .info .key {
margin-right: 5px;
}
@ -990,23 +986,32 @@
color: red;
}
.course-meta .info .origin-price {
text-decoration: line-through;
}
.course-meta .info .free {
color: green;
}
.course-meta .rating span {
.course-meta .ratings {
padding-top: 5px;
}
.course-meta .ratings .item {
line-height: 40px;
}
.course-meta .ratings .name {
margin-right: 5px;
}
.course-meta .rating .layui-icon {
color: orange;
.course-meta .ratings .layui-rate {
padding: 0;
margin-top: -8px;
}
.course-meta .rating .score {
.course-meta .ratings .layui-icon {
font-size: 16px;
}
.course-meta .ratings .score {
color: #666;
}
@ -1039,50 +1044,78 @@
font-size: 30px;
}
.lesson-item {
position: relative;
padding: 0 10px;
line-height: 35px;
.lesson-list .allow {
cursor: pointer;
}
.lesson-item a {
display: block;
}
.lesson-item .deny {
.lesson-list .deny {
cursor: default;
color: gray;
}
.lesson-item .title {
margin: 0 5px;
}
.lesson-item .icon-trial {
color: red;
font-size: 24px;
margin-right: 5px;
}
.lesson-item .duration, .lesson-item .live {
top: 0;
right: 10px;
position: absolute;
color: #666;
}
.lesson-item .live .active {
color: red;
}
.lesson-item .study-time {
color: green;
.lesson-item {
display: flex;
justify-content: space-between;
line-height: 35px;
padding: 0 10px;
}
.lesson-item:hover {
background-color: #f2f2f2;
}
.lesson-item .title {
margin-right: 5px;
}
.lesson-item .model {
margin-right: 5px;
}
.lesson-item .lock {
margin-right: 5px;
}
.lesson-item .study-time {
margin-right: 5px;
color: green;
}
.lesson-item .flag {
padding: 2px 3px;
margin-right: 5px;
font-size: 12px;
}
.lesson-item .flag-free {
border: 1px solid red;
color: red;
}
.lesson-item .flag-playback {
border: 1px solid orange;
color: orange;
}
.lesson-item .flag-scheduled {
border: 1px solid green;
color: green;
}
.lesson-item .flag-active {
border: 1px solid red;
color: red;
}
.lesson-item .flag-inactive {
border: 1px solid gray;
color: gray;
}
.lesson-item .flag-ended {
border: 1px solid gray;
color: gray;
}
.package-item {
display: flex;
margin-bottom: 20px;
@ -1173,15 +1206,13 @@
white-space: normal;
}
.review-card,
.consult-card,
.answer-card {
.review-card .info,
.consult-card .info {
position: relative;
}
.review-card .rating,
.consult-card .more,
.answer-card .accepted {
.consult-card .more {
position: absolute;
top: 0;
right: 0;
@ -1205,11 +1236,6 @@
font-size: 12px;
}
.review-card .more {
color: #666;
cursor: pointer;
}
.sidebar-card .layui-card-header {
text-align: center;
}
@ -1292,80 +1318,72 @@
margin-right: 10px;
}
.sidebar-course-card .meta .price {
color: red;
}
.sidebar-course-card .meta .free {
color: green;
}
.sidebar-chapter-list {
height: 405px;
overflow-y: auto;
}
.sidebar-chapter-list .chapter-title {
padding-top: 10px;
margin-bottom: 10px;
color: #333;
}
.sidebar-lesson-list {
margin-left: 10px;
}
.sidebar-lesson-list .lesson-title {
line-height: 30px;
}
.lesson-title .active {
.sidebar-lesson-list .active {
color: red;
}
.lesson-title .deny {
color: gray;
}
.share .layui-icon {
margin-right: 5px;
.sidebar-lesson-list .allow {
cursor: pointer;
}
.share .active,
.share .layui-icon-star-fill {
color: orange;
.sidebar-lesson-list .deny {
cursor: default;
color: gray;
}
.share a {
margin-right: 5px;
.sidebar-chapter {
padding-top: 10px;
margin-bottom: 10px;
font-weight: 600;
color: #333;
}
.share i {
margin-right: 5px;
.sidebar-lesson {
padding: 0 10px;
line-height: 30px;
}
.share em {
font-style: normal;
color: #666;
.sidebar-lesson:hover {
background-color: #f2f2f2;
}
.preview {
.live-preview {
color: #666;
margin-top: 30px;
text-align: center;
}
.preview .icon {
.live-preview .icon {
margin-bottom: 10px;
}
.preview .icon .layui-icon {
.live-preview .icon .layui-icon {
font-size: 150px;
}
.preview .tips {
font-size: 16px;
.live-preview .tips {
color: #999;
margin: 20px 0;
}
.countdown .timer {
.countdown .timer .label {
font-size: 32px;
}
.countdown .timer span {
.countdown .timer .value {
color: green;
font-size: 36px;
padding: 10px;
@ -1384,7 +1402,6 @@
height: 428px;
}
.play-mask {
top: 50%;
left: 50%;
@ -1418,37 +1435,33 @@
overflow-y: auto;
}
.chat-msg-list .chat, .chat-msg-list .chat-sys {
.chat {
margin-bottom: 10px;
line-height: 25px;
line-height: 1.5em;
word-break: break-all;
}
.chat-sys {
font-size: 12px;
color: #999;
}
.chat-sys span, .chat span {
.chat-sys {
padding: 5px;
background-color: black;
color: white;
}
.chat span {
margin-right: 5px;
}
.chat .user {
color: orange;
}
.chat .icon-vip {
color: orange;
}
.chat .content {
color: #666;
.chat .icon .layui-icon {
font-size: 14px;
}
.chat-msg-form .layui-input {
height: 32px;
line-height: 32px;
font-size: 12px;
color: #666;
color: #999;
}
.vip-header {
@ -1457,20 +1470,12 @@
margin-bottom: 30px;
}
.vip-reason-list {
.vip-priv-list {
padding: 30px;
margin-bottom: 30px;
text-align: center;
}
.vip-reason-list .reason-badge {
height: 30px;
line-height: 30px;
padding: 0 10px;
margin-right: 15px;
background-color: #1E9FFF;
}
.vip-option-list {
margin-bottom: 30px;
}
@ -1799,10 +1804,6 @@
background-color: #f2f2f2;
}
.user-tab {
margin: 0;
}
.user-tab .layui-tab-title {
margin-bottom: 10px;
text-align: center;
@ -1843,7 +1844,7 @@
.user-card {
float: left;
width: 100%;
height: 240px;
height: 200px;
position: relative;
text-align: center;
background-color: #fff;
@ -1876,32 +1877,6 @@
color: #666;
}
.user-card .meta {
color: #666;
}
.user-card .meta span {
margin-right: 5px;
}
.user-card .type {
position: absolute;
top: 18px;
right: 28px;
}
.user-list {
margin-bottom: 20px;
}
.teacher-list .user-card {
height: 200px;
}
.vip-user-list .user-card {
height: 200px;
}
.tag-card {
float: left;
width: 100%;
@ -1947,10 +1922,17 @@
}
.my-profile-card {
position: relative;
margin-bottom: 15px;
text-align: center;
}
.my-profile-card .vip {
position: absolute;
right: 15px;
top: 15px;
}
.my-profile-card .avatar {
margin-bottom: 10px;
}

View File

@ -67,19 +67,19 @@ layui.use(['jquery', 'form', 'helper'], function () {
}
function showNewMessage(res) {
var html = '<div class="chat">';
var html = '';
if (res.user.vip === 1) {
html += '<span class="layui-icon layui-icon-diamond icon-vip"></span>';
html = getVipUserMessage(res);
} else {
html = getNormalUserMessage(res);
}
html += '<span class="user">' + res.user.name + ':</span>';
html += '<span class="content">' + res.content + '</span>';
html += '</div>';
$chatMsgList.append(html);
scrollToBottom();
}
function showLoginMessage(res) {
var html = '<div class="chat chat-sys">';
html += '<span class="icon"><i class="layui-icon layui-icon-speaker"></i></span>';
html += '<span>' + res.user.name + '</span>';
html += '<span>进入了直播间</span>';
html += '</div>';
@ -87,11 +87,27 @@ layui.use(['jquery', 'form', 'helper'], function () {
scrollToBottom();
}
function getVipUserMessage(res) {
var html = '<div class="chat chat-vip">';
html += '<span class="icon"><i class="layui-icon layui-icon-diamond"></i></span>';
html += '<span class="user layui-badge layui-bg-orange">' + res.user.name + '</span>';
html += '<span class="content">' + res.content + '</span>';
html += '</div>';
return html;
}
function getNormalUserMessage(res) {
var html = '<div class="chat chat-normal">';
html += '<span class="icon"><i class="layui-icon layui-icon-username"></i></span>';
html += '<span class="user layui-badge layui-bg-blue">' + res.user.name + '</span>';
html += '<span class="content">' + res.content + '</span>';
html += '</div>';
return html;
}
function scrollToBottom() {
var $scrollTo = $chatMsgList.find('.chat:last');
$chatMsgList.scrollTop(
$scrollTo.offset().top - $chatMsgList.offset().top + $chatMsgList.scrollTop()
);
$chatMsgList.scrollTop($scrollTo.offset().top - $chatMsgList.offset().top + $chatMsgList.scrollTop());
}
function refreshLiveStats() {
@ -105,4 +121,4 @@ layui.use(['jquery', 'form', 'helper'], function () {
helper.ajaxLoadHtml($chatMsgList.data('url'), $chatMsgList.attr('id'));
}
});
});

View File

@ -7,7 +7,7 @@ layui.use(['jquery', 'util'], function () {
var serverTime = $('input[name="countdown.server_time"]').val();
var liveStatusUrl = $('input[name="live.status_url"]').val();
util.countdown(1000 * parseInt(endTime), 1000 * parseInt(serverTime), function (date, serverTime, timer) {
util.countdown(1000 * parseInt(endTime), 1000 * parseInt(serverTime), function (date) {
var items = [
{date: date[0], label: '天'},
{date: date[1], label: '时'},
@ -16,7 +16,10 @@ layui.use(['jquery', 'util'], function () {
];
var html = '';
layui.each(items, function (index, item) {
html += '<span>' + item.date + '</span>' + item.label;
if (item.date > 0) {
html += '<span class="value">' + item.date + '</span>';
html += '<span class="label">' + item.label + '</span>';
}
});
$('.countdown > .timer').html(html);
});
@ -29,4 +32,4 @@ layui.use(['jquery', 'util'], function () {
});
}, 30000);
});
});

View File

@ -3,12 +3,6 @@ layui.use(['jquery', 'helper'], function () {
var $ = layui.jquery;
var helper = layui.helper;
var $commentList = $('#comment-list');
if ($commentList.length > 0) {
helper.ajaxLoadHtml($commentList.data('url'), $commentList.attr('id'));
}
$('.icon-praise').on('click', function () {
var $this = $(this);
var $parent = $this.parent();
@ -34,8 +28,24 @@ layui.use(['jquery', 'helper'], function () {
});
});
$('.sidebar-lesson').on('click', function () {
if ($(this).hasClass('deny')) {
return false;
}
var url = $(this).data('url');
helper.checkLogin(function () {
window.location.href = url;
});
});
$('.icon-reply').on('click', function () {
$('html').scrollTop($('#comment-anchor').offset().top);
});
});
var $commentList = $('#comment-list');
if ($commentList.length > 0) {
helper.ajaxLoadHtml($commentList.data('url'), $commentList.attr('id'));
}
});

View File

@ -1,9 +1,31 @@
layui.use(['jquery', 'layer', 'helper'], function () {
layui.use(['jquery', 'layer', 'rate', 'helper'], function () {
var $ = layui.jquery;
var layer = layui.layer;
var rate = layui.rate;
var helper = layui.helper;
rate.render({
elem: '#rating1',
value: $('#rating1').data('value'),
readonly: true,
half: true,
});
rate.render({
elem: '#rating2',
value: $('#rating2').data('value'),
readonly: true,
half: true,
});
rate.render({
elem: '#rating3',
value: $('#rating3').data('value'),
readonly: true,
half: true,
});
/**
* 收藏
*/
@ -50,9 +72,12 @@ layui.use(['jquery', 'layer', 'helper'], function () {
});
/**
* 购买课程|套餐)
* 浏览章节
*/
$('body').on('click', '.btn-buy', function () {
$('.lesson-item').on('click', function () {
if ($(this).hasClass('deny')) {
return false;
}
var url = $(this).data('url');
helper.checkLogin(function () {
window.location.href = url;
@ -60,12 +85,9 @@ layui.use(['jquery', 'layer', 'helper'], function () {
});
/**
* 浏览章节
* 购买课程|套餐)
*/
$('body').on('click', '.view-lesson', function () {
if ($(this).hasClass('deny')) {
return false;
}
$('body').on('click', '.btn-buy', function () {
var url = $(this).data('url');
helper.checkLogin(function () {
window.location.href = url;
@ -140,4 +162,4 @@ layui.use(['jquery', 'layer', 'helper'], function () {
helper.ajaxLoadHtml($sdRelated.data('url'), $sdRelated.attr('id'));
}
});
});

View File

@ -1,4 +1,4 @@
layui.use(['jquery', 'helper', 'util'], function () {
layui.use(['jquery', 'util'], function () {
var $ = layui.jquery;
var util = layui.util;
@ -47,6 +47,19 @@ layui.use(['jquery', 'helper', 'util'], function () {
});
}
var showPhoneCode = function () {
var content = '<div class="layui-font-32 layui-font-red layui-padding-5">';
content += '<i class="iconfont icon-phone layui-padding-1 layui-font-28"></i>' + window.contact.phone;
content += '</div>';
layer.open({
type: 1,
title: false,
closeBtn: 0,
shadeClose: true,
content: content,
});
}
var bars = [];
if (window.contact.wechat) {
@ -63,6 +76,13 @@ layui.use(['jquery', 'helper', 'util'], function () {
});
}
if (window.contact.phone) {
bars.push({
type: 'phone',
content: '<i class="iconfont icon-phone layui-font-30"></i>',
});
}
util.fixbar({
bars: bars,
click: function (type) {
@ -70,24 +90,30 @@ layui.use(['jquery', 'helper', 'util'], function () {
showWechatCode();
} else if (type === 'qq') {
showQQCode();
} else if (type === 'phone') {
showPhoneCode();
}
}
});
$('.icon-wechat').on('click', function () {
$('.contact > .wechat').on('click', function () {
showWechatCode();
});
$('.icon-qq').on('click', function () {
$('.contact > .qq').on('click', function () {
showQQCode();
});
$('.icon-toutiao').on('click', function () {
$('.contact > .toutiao').on('click', function () {
showTouTiaoCode();
});
$('.icon-douyin').on('click', function () {
$('.contact > .douyin').on('click', function () {
showDouYinCode();
});
});
$('.contact > .phone').on('click', function () {
showPhoneCode();
});
});

View File

@ -0,0 +1,12 @@
layui.use(['jquery', 'helper'], function () {
var $ = layui.jquery;
var helper = layui.helper;
var $courseList = $('#course-list');
if ($courseList.length > 0) {
helper.ajaxLoadHtml($courseList.data('url'), $courseList.attr('id'));
}
});

View File

@ -0,0 +1,12 @@
layui.use(['jquery', 'helper'], function () {
var $ = layui.jquery;
var helper = layui.helper;
var $courseList = $('#course-list');
if ($courseList.length > 0) {
helper.ajaxLoadHtml($courseList.data('url'), $courseList.attr('id'));
}
});

View File

@ -0,0 +1,27 @@
layui.use(['jquery', 'layer'], function () {
var $ = layui.jquery;
var layer = layui.layer;
var index = parent.layer.getFrameIndex(window.name);
parent.layer.iframeAuto(index);
$('.btn-refund-cancel').on('click', function () {
var url = $(this).data('url');
var data = {sn: $(this).data('sn')};
layer.confirm('确定要取消退款吗?', function () {
$.ajax({
type: 'POST',
url: url,
data: data,
success: function () {
layer.msg('取消退款成功', {icon: 1});
setTimeout(function () {
parent.window.location.href = '/uc/refunds';
}, 1500);
}
});
});
});
});

View File

@ -12,7 +12,7 @@ layui.use(['jquery', 'layer'], function () {
type: 2,
title: '咨询详情',
content: [url, 'no'],
area: ['720px', '320px']
area: ['720px', '320px'],
});
});
@ -26,9 +26,6 @@ layui.use(['jquery', 'layer'], function () {
title: '回复咨询',
content: [url, 'no'],
area: ['720px', '300px'],
cancel: function () {
parent.location.reload();
}
});
});
@ -41,8 +38,8 @@ layui.use(['jquery', 'layer'], function () {
type: 2,
title: '直播推流',
content: [url, 'no'],
area: ['640px', '420px']
area: ['640px', '420px'],
});
});
});
});

View File

@ -1,44 +0,0 @@
layui.use(['jquery', 'layer', 'upload'], function () {
var $ = layui.jquery;
var layer = layui.layer;
var upload = layui.upload;
upload.render({
elem: '#change-avatar',
url: '/upload/avatar/img',
accept: 'images',
acceptMime: 'image/*',
size: 512,
auto: false,
before: function () {
layer.load();
},
choose: function (obj) {
var flag = true;
obj.preview(function (index, file, result) {
var img = new Image();
img.src = result;
img.onload = function () {
if (img.width < 1000 && img.height < 1000) {
obj.upload(index, file);
} else {
flag = false;
layer.msg("图片尺寸必须小于 1000 * 1000");
return false;
}
};
return flag;
});
},
done: function (res, index, upload) {
$('#img-avatar').attr('src', res.data.url);
$('input[name=avatar]').val(res.data.url);
layer.closeAll('loading');
},
error: function (index, upload) {
layer.msg('上传文件失败', {icon: 2});
}
});
});

View File

@ -12,7 +12,7 @@ layui.use(['jquery', 'layer'], function () {
type: 2,
title: '咨询详情',
content: [url, 'no'],
area: ['720px', '320px']
area: ['720px', '320px'],
});
});
@ -26,9 +26,6 @@ layui.use(['jquery', 'layer'], function () {
title: '编辑咨询',
content: [url, 'no'],
area: ['720px', '420px'],
cancel: function () {
parent.location.reload();
}
});
});
@ -42,9 +39,6 @@ layui.use(['jquery', 'layer'], function () {
title: '发布评价',
content: [url, 'no'],
area: ['640px', '480px'],
cancel: function () {
parent.location.reload();
}
});
});
@ -58,9 +52,6 @@ layui.use(['jquery', 'layer'], function () {
title: '修改评价',
content: [url, 'no'],
area: ['640px', '480px'],
cancel: function () {
parent.location.reload();
}
});
});
@ -74,7 +65,7 @@ layui.use(['jquery', 'layer'], function () {
title: '订单详情',
content: [url, 'no'],
area: '800px',
offset: '200px'
offset: '200px',
});
});
@ -88,7 +79,7 @@ layui.use(['jquery', 'layer'], function () {
title: '退款详情',
content: [url, 'no'],
area: '800px',
offset: '200px'
offset: '200px',
});
});

View File

@ -1,7 +1,47 @@
layui.use(['layarea'], function () {
layui.use(['jquery', 'upload', 'layer', 'layarea'], function () {
var $ = layui.jquery;
var layer = layui.layer;
var upload = layui.upload;
var layarea = layui.layarea;
upload.render({
elem: '#change-avatar',
url: '/upload/avatar/img',
accept: 'images',
acceptMime: 'image/*',
size: 512,
auto: false,
before: function () {
layer.load();
},
choose: function (obj) {
var flag = true;
obj.preview(function (index, file, result) {
var img = new Image();
img.src = result;
img.onload = function () {
if (img.width < 1000 && img.height < 1000) {
obj.upload(index, file);
} else {
flag = false;
layer.msg("图片尺寸必须小于 1000 * 1000");
return false;
}
};
return flag;
});
},
done: function (res) {
$('#img-avatar').attr('src', res.data.url);
$('input[name=avatar]').val(res.data.url);
layer.closeAll('loading');
},
error: function () {
layer.msg('上传文件失败', {icon: 2});
}
});
layarea.render({
elem: '#area-picker',
change: function (res) {
@ -9,4 +49,4 @@ layui.use(['layarea'], function () {
}
});
});
});

View File

@ -7,10 +7,6 @@ layui.use(['jquery', 'rate'], function () {
var $rating2 = $('input[name=rating2]');
var $rating3 = $('input[name=rating3]');
$('.btn-cancel').on('click', function () {
parent.layer.closeAll();
});
rate.render({
elem: '#rating1',
value: $rating1.val(),
@ -35,4 +31,4 @@ layui.use(['jquery', 'rate'], function () {
}
});
});
});

Some files were not shown because too many files have changed in this diff Show More