mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-06-27 04:57:39 +08:00
增加full_url()函数
This commit is contained in:
parent
cd8e84b574
commit
d5559ec49c
@ -43,12 +43,16 @@ class CloseTradeTask extends Task
|
||||
$alipayTrade = $alipay->find($trade->sn);
|
||||
|
||||
if ($alipayTrade) {
|
||||
|
||||
/**
|
||||
* 异步通知接收异常,补救漏网
|
||||
*/
|
||||
if ($alipayTrade->trade_status == 'TRADE_SUCCESS') {
|
||||
|
||||
$this->eventsManager->fire('pay:afterPay', $this, $trade);
|
||||
|
||||
$allowClosed = false;
|
||||
|
||||
} elseif ($alipayTrade->trade_status == 'WAIT_BUYER_PAY') {
|
||||
$alipay->close($trade->sn);
|
||||
}
|
||||
@ -75,12 +79,16 @@ class CloseTradeTask extends Task
|
||||
$wxpayTrade = $wxpay->find($trade->sn);
|
||||
|
||||
if ($wxpayTrade) {
|
||||
|
||||
/**
|
||||
* 异步通知接收异常,补救漏网
|
||||
*/
|
||||
if ($wxpayTrade->trade_state == 'SUCCESS') {
|
||||
|
||||
$this->eventsManager->fire('pay:afterPay', $this, $trade);
|
||||
|
||||
$allowClosed = false;
|
||||
|
||||
} elseif ($wxpayTrade->trade_state == 'NOTPAY') {
|
||||
$wxpay->close($trade->sn);
|
||||
}
|
||||
|
@ -107,6 +107,7 @@ class CourseController extends Controller
|
||||
$packages = $service->handle($id);
|
||||
|
||||
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
|
||||
$this->view->pick('course/show_packages');
|
||||
$this->view->setVar('packages', $packages);
|
||||
}
|
||||
|
||||
@ -122,6 +123,7 @@ class CourseController extends Controller
|
||||
$pager->target = 'tab-consults';
|
||||
|
||||
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
|
||||
$this->view->pick('course/show_consults');
|
||||
$this->view->setVar('pager', $pager);
|
||||
}
|
||||
|
||||
@ -137,6 +139,7 @@ class CourseController extends Controller
|
||||
$pager->target = 'tab-reviews';
|
||||
|
||||
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
|
||||
$this->view->pick('course/show_reviews');
|
||||
$this->view->setVar('pager', $pager);
|
||||
}
|
||||
|
||||
@ -150,6 +153,7 @@ class CourseController extends Controller
|
||||
$courses = $service->handle($id);
|
||||
|
||||
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
|
||||
$this->view->pick('course/show_recommended');
|
||||
$this->view->setVar('courses', $courses);
|
||||
}
|
||||
|
||||
@ -163,6 +167,7 @@ class CourseController extends Controller
|
||||
$courses = $service->handle($id);
|
||||
|
||||
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
|
||||
$this->view->pick('course/show_related');
|
||||
$this->view->setVar('courses', $courses);
|
||||
}
|
||||
|
||||
@ -176,21 +181,10 @@ class CourseController extends Controller
|
||||
$topics = $service->handle($id);
|
||||
|
||||
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
|
||||
$this->view->pick('course/show_topics');
|
||||
$this->view->setVar('topics', $topics);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Get("/{id:[0-9]+}/reward", name="web.course.reward")
|
||||
*/
|
||||
public function rewardAction($id)
|
||||
{
|
||||
$service = new RewardOptionList();
|
||||
|
||||
$options = $service->handle();
|
||||
|
||||
$this->view->setVar('options', $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Get("/{id:[0-9]+}/rating", name="web.course.rating")
|
||||
*/
|
||||
@ -200,6 +194,7 @@ class CourseController extends Controller
|
||||
|
||||
$course = $service->handle($id);
|
||||
|
||||
$this->view->pick('course/rating');
|
||||
$this->view->setVar('course', $course);
|
||||
}
|
||||
|
||||
|
@ -2,9 +2,11 @@
|
||||
|
||||
{% block content %}
|
||||
|
||||
{% set like_url = url({'for':'web.chapter.like','id':chapter.id}) %}
|
||||
{% set learning_url = url({'for':'web.chapter.learning','id':chapter.id}) %}
|
||||
{% set chapter_url = url({'for':'web.chapter.show','id':chapter.id}) %}
|
||||
{% set danmu_url = url({'for':'web.chapter.danmu','id':chapter.id}) %}
|
||||
{% set learning_url = url({'for':'web.chapter.learning','id':chapter.id}) %}
|
||||
{% set like_url = url({'for':'web.chapter.like','id':chapter.id}) %}
|
||||
{% set qrcode_url = url({'for':'web.qrcode_img'},{'text':'http://baidu.com','size':5}) %}
|
||||
|
||||
<div class="breadcrumb">
|
||||
<span class="layui-breadcrumb">
|
||||
@ -19,12 +21,16 @@
|
||||
<div id="player"></div>
|
||||
<div id="danmu"></div>
|
||||
</div>
|
||||
<div class="chapter-action wrap">
|
||||
<span><i class="layui-icon layui-icon-praise" id="icon-like" title="点赞" data-url="{{ like_url }}"></i><em id="like-count">{{ chapter.like_count }}</em></span>
|
||||
<span><i class="layui-icon layui-icon-user" id="icon-user" title="学习人次"></i><em>{{ chapter.user_count }}</em></span>
|
||||
<span><i class="layui-icon layui-icon-share" id="icon-share" title="分享"></i></span>
|
||||
<span><i class="layui-icon layui-icon-set" id="icon-danmu-set" title="弹幕设置"></i></span>
|
||||
<div class="chapter-action wrap clearfix">
|
||||
<div class="share">
|
||||
<a href="javascript:" title="点赞" data-url="{{ like_url }}"><i class="layui-icon layui-icon-praise icon-praise"></i><em class="like-count">{{ chapter.like_count }}</em></a>
|
||||
<a href="javascript:" title="学习人次"><i class="layui-icon layui-icon-user"></i><em>{{ chapter.user_count }}</em></a>
|
||||
<a href="javascript:" title="分享到微信" data-url=""><i class="layui-icon layui-icon-login-wechat icon-wechat"></i></a>
|
||||
<a href="javascript:" title="分享到QQ空间"><i class="layui-icon layui-icon-login-qq icon-qq"></i></a>
|
||||
<a href="javascript:" title="分享到微博"><i class="layui-icon layui-icon-login-weibo icon-weibo"></i></a>
|
||||
</div>
|
||||
<form class="layui-form danmu-form" lay-filter="danmu.form" action="{{ url({'for':'web.danmu.create'}) }}">
|
||||
<a href="javascript:" title="弹幕设置"><i class="layui-icon layui-icon-set icon-danmu-set"></i></a>
|
||||
{% if auth_user.id > 0 %}
|
||||
<input class="layui-input" type="text" name="danmu.text" maxlength="50" placeholder="快来发个弹幕吧" lay-verType="tips" lay-verify="required">
|
||||
{% else %}
|
||||
@ -94,6 +100,13 @@
|
||||
<input type="hidden" name="chapter.play_urls" value='{{ chapter.play_urls|json_encode }}'>
|
||||
</div>
|
||||
|
||||
<div class="layui-hide">
|
||||
<input type="hidden" name="share.title" value="{{ chapter.course.title }}">
|
||||
<input type="hidden" name="share.pic" value="{{ chapter.course.cover }}">
|
||||
<input type="hidden" name="share.url" value="{{ chapter_url }}">
|
||||
<input type="hidden" name="share.qrcode" value="{{ qrcode_url }}">
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block include_js %}
|
||||
@ -102,6 +115,7 @@
|
||||
|
||||
{{ js_include('lib/jquery.min.js') }}
|
||||
{{ js_include('lib/jquery.danmu.min.js') }}
|
||||
{{ js_include('web/js/share.js') }}
|
||||
{{ js_include('web/js/vod.player.js') }}
|
||||
{{ js_include('web/js/chapter.action.js') }}
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
</div>
|
||||
|
||||
<div class="course-meta wrap clearfix">
|
||||
{{ partial('course/meta') }}
|
||||
{{ partial('course/show_meta') }}
|
||||
</div>
|
||||
|
||||
<div class="layout-main clearfix">
|
||||
@ -26,27 +26,18 @@
|
||||
|
||||
<div class="layout-content">
|
||||
<div class="course-tab-wrap wrap">
|
||||
{% if show_tab_packages == 1 %}
|
||||
<span class="tab-count package-count">{{ course.package_count }}</span>
|
||||
{% endif %}
|
||||
{% if show_tab_consults == 1 %}
|
||||
<span class="tab-count consult-count">{{ course.consult_count }}</span>
|
||||
{% endif %}
|
||||
{% if show_tab_reviews == 1 %}
|
||||
<span class="tab-count review-count">{{ course.review_count }}</span>
|
||||
{% endif %}
|
||||
<div class="layui-tab layui-tab-brief course-tab">
|
||||
<ul class="layui-tab-title">
|
||||
<li class="layui-this">详情</li>
|
||||
<li>目录</li>
|
||||
{% if show_tab_packages == 1 %}
|
||||
<li>套餐</li>
|
||||
<li>套餐<span class="tab-count package-count">{{ course.package_count }}</span></li>
|
||||
{% endif %}
|
||||
{% if show_tab_consults == 1 %}
|
||||
<li>咨询</li>
|
||||
<li>咨询<span class="tab-count consult-count">{{ course.consult_count }}</span></li>
|
||||
{% endif %}
|
||||
{% if show_tab_reviews == 1 %}
|
||||
<li>评价</li>
|
||||
<li>评价<span class="tab-count review-count">{{ course.review_count }}</span></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
<div class="layui-tab-content">
|
||||
@ -54,7 +45,7 @@
|
||||
<div class="course-details">{{ course.details }}</div>
|
||||
</div>
|
||||
<div class="layui-tab-item">
|
||||
{{ partial('course/chapters') }}
|
||||
{{ partial('course/show_chapters') }}
|
||||
</div>
|
||||
{% if show_tab_packages == 1 %}
|
||||
{% set packages_url = url({'for':'web.course.packages','id':course.id}) %}
|
||||
@ -79,8 +70,8 @@
|
||||
{% set show_sidebar_related = 1 %}
|
||||
|
||||
<div class="layout-sidebar">
|
||||
{{ partial('course/order') }}
|
||||
{{ partial('course/teachers') }}
|
||||
{{ partial('course/show_order') }}
|
||||
{{ partial('course/show_teachers') }}
|
||||
{% if show_sidebar_topics %}
|
||||
{% set topics_url = url({'for':'web.course.topics','id':course.id}) %}
|
||||
<div class="sidebar" id="sidebar-topics" data-url="{{ topics_url }}"></div>
|
||||
|
@ -34,14 +34,14 @@
|
||||
</p>
|
||||
|
||||
{% set favorite_url = url({'for':'web.course.favorite','id':course.id}) %}
|
||||
{% set course_url = url({'for':'web.course.show','id':course.id}) %}
|
||||
{% set qrcode_url = url({'for':'web.qrcode_img'},{'text':'http://baidu.com','size':5}) %}
|
||||
{% set full_course_url = full_url({'for':'web.course.show','id':course.id}) %}
|
||||
{% set qrcode_url = url({'for':'web.qrcode_img'},{'text':full_course_url}) %}
|
||||
|
||||
<div class="layui-hide">
|
||||
<input type="hidden" name="course.title" value="{{ course.title }}">
|
||||
<input type="hidden" name="course.cover" value="{{ course.cover }}">
|
||||
<input type="hidden" name="course.url" value="{{ course_url }}">
|
||||
<input type="hidden" name="course.qrcode" value="{{ qrcode_url }}">
|
||||
<input type="hidden" name="share.title" value="{{ course.title }}">
|
||||
<input type="hidden" name="share.pic" value="{{ course.cover }}">
|
||||
<input type="hidden" name="share.url" value="{{ full_course_url }}">
|
||||
<input type="hidden" name="share.qrcode" value="{{ qrcode_url }}">
|
||||
</div>
|
||||
|
||||
<div class="share">
|
@ -1,6 +1,7 @@
|
||||
<div class="layui-fluid">
|
||||
<div class="kg-tips">
|
||||
<i class="layui-icon layui-icon-face-surprised"></i>
|
||||
<div class="message">{{ flashSession.output() }}</div>
|
||||
<div class="layui-text">
|
||||
<h1>
|
||||
<span class="layui-anim layui-anim-loop">4</span>
|
||||
|
@ -314,7 +314,7 @@ function kg_can($route = null)
|
||||
/**
|
||||
* 构造icon路径
|
||||
*
|
||||
* @param $path
|
||||
* @param string $path
|
||||
* @param bool $local
|
||||
* @param string $version
|
||||
* @return string
|
||||
@ -329,7 +329,7 @@ function kg_icon_link($path, $local = true, $version = null)
|
||||
/**
|
||||
* 构造css路径
|
||||
*
|
||||
* @param $path
|
||||
* @param string $path
|
||||
* @param bool $local
|
||||
* @param string $version
|
||||
* @return string
|
||||
@ -344,7 +344,7 @@ function kg_css_link($path, $local = true, $version = null)
|
||||
/**
|
||||
* 构造js引入
|
||||
*
|
||||
* @param $path
|
||||
* @param string $path
|
||||
* @param bool $local
|
||||
* @param string $version
|
||||
* @return string
|
||||
@ -359,7 +359,7 @@ function kg_js_include($path, $local = true, $version = null)
|
||||
/**
|
||||
* 构造静态url
|
||||
*
|
||||
* @param $path
|
||||
* @param string $path
|
||||
* @param bool $local
|
||||
* @param string $version
|
||||
* @return string
|
||||
@ -379,3 +379,22 @@ function kg_static_url($path, $local = true, $version = null)
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造全路径url
|
||||
*
|
||||
* @param mixed $uri
|
||||
* @param mixed $args
|
||||
* @return string
|
||||
*/
|
||||
function kg_full_url($uri, $args = null)
|
||||
{
|
||||
/**
|
||||
* @var $url Phalcon\Mvc\Url
|
||||
*/
|
||||
$url = Di::getDefault()->getShared('url');
|
||||
|
||||
$baseUrl = kg_site_base_url();
|
||||
|
||||
return $baseUrl . $url->get($uri, $args);
|
||||
}
|
@ -55,6 +55,8 @@ class CourseCounter extends Listener
|
||||
$this->counter->hIncrBy($course->id, 'review_count');
|
||||
|
||||
$this->syncCourseCounter($course);
|
||||
|
||||
$this->syncCourseIndex($course);
|
||||
}
|
||||
|
||||
public function decrReviewCount(Event $event, $source, CourseModel $course)
|
||||
@ -62,6 +64,8 @@ class CourseCounter extends Listener
|
||||
$this->counter->hDecrBy($course->id, 'review_count');
|
||||
|
||||
$this->syncCourseCounter($course);
|
||||
|
||||
$this->syncCourseIndex($course);
|
||||
}
|
||||
|
||||
public function incrCommentCount(Event $event, $source, CourseModel $course)
|
||||
|
@ -2,8 +2,6 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Phalcon\Mvc\Model\Behavior\SoftDelete;
|
||||
|
||||
class CourseRating extends Model
|
||||
{
|
||||
|
||||
@ -42,13 +40,6 @@ class CourseRating extends Model
|
||||
*/
|
||||
public $rating3;
|
||||
|
||||
/**
|
||||
* 删除标识
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $deleted;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*
|
||||
@ -68,18 +59,6 @@ class CourseRating extends Model
|
||||
return 'kg_course_rating';
|
||||
}
|
||||
|
||||
public function initialize()
|
||||
{
|
||||
parent::initialize();
|
||||
|
||||
$this->addBehavior(
|
||||
new SoftDelete([
|
||||
'field' => 'deleted',
|
||||
'value' => 1,
|
||||
])
|
||||
);
|
||||
}
|
||||
|
||||
public function beforeCreate()
|
||||
{
|
||||
$this->create_time = time();
|
||||
|
@ -17,14 +17,14 @@ class Cache extends Provider
|
||||
$config = $this->getShared('config');
|
||||
|
||||
$frontend = new IgbinaryFrontend([
|
||||
'lifetime' => $config->redis->lifetime,
|
||||
'lifetime' => $config->cache->lifetime,
|
||||
]);
|
||||
|
||||
return new RedisBackend($frontend, [
|
||||
'host' => $config->redis->host,
|
||||
'port' => $config->redis->port,
|
||||
'auth' => $config->redis->auth,
|
||||
'index' => $config->redis->index,
|
||||
'index' => $config->cache->db,
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ class Session extends Provider
|
||||
'host' => $config->redis->host,
|
||||
'port' => $config->redis->port,
|
||||
'auth' => $config->redis->auth,
|
||||
'index' => $config->redis->index,
|
||||
'index' => $config->session->db,
|
||||
'lifetime' => $config->session->lifetime,
|
||||
]);
|
||||
|
||||
|
@ -22,6 +22,10 @@ class Volt extends Provider
|
||||
|
||||
$compiler = $volt->getCompiler();
|
||||
|
||||
$compiler->addFunction('full_url', function ($resolvedArgs) {
|
||||
return 'kg_full_url(' . $resolvedArgs . ')';
|
||||
});
|
||||
|
||||
$compiler->addFunction('static_url', function ($resolvedArgs) {
|
||||
return 'kg_static_url(' . $resolvedArgs . ')';
|
||||
});
|
||||
|
@ -8,16 +8,15 @@ use App\Models\Chapter as ChapterModel;
|
||||
use App\Models\ChapterUser as ChapterUserModel;
|
||||
use App\Models\Comment as CommentModel;
|
||||
use App\Models\Consult as ConsultModel;
|
||||
use App\Models\ConsultLike as ConsultLikeModel;
|
||||
use App\Models\Course as CourseModel;
|
||||
use App\Models\CourseCategory as CourseCategoryModel;
|
||||
use App\Models\CourseFavorite as CourseFavoriteModel;
|
||||
use App\Models\CoursePackage as CoursePackageModel;
|
||||
use App\Models\CourseRating as CourseRatingModel;
|
||||
use App\Models\CourseRelated as CourseRelatedModel;
|
||||
use App\Models\CourseUser as CourseUserModel;
|
||||
use App\Models\Package as PackageModel;
|
||||
use App\Models\Review as ReviewModel;
|
||||
use App\Models\ReviewLike as ReviewLikeModel;
|
||||
use App\Models\User as UserModel;
|
||||
use Phalcon\Mvc\Model;
|
||||
use Phalcon\Mvc\Model\Resultset;
|
||||
@ -132,6 +131,18 @@ class Course extends Repository
|
||||
->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $courseId
|
||||
* @return CourseRatingModel|Model|bool
|
||||
*/
|
||||
public function findCourseRating($courseId)
|
||||
{
|
||||
return CourseRatingModel::findFirst([
|
||||
'conditions' => 'course_id = :course_id:',
|
||||
'bind' => ['course_id' => $courseId],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $courseId
|
||||
* @return ResultsetInterface|Resultset|UserModel[]
|
||||
@ -234,38 +245,6 @@ class Course extends Repository
|
||||
->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $courseId
|
||||
* @param int $userId
|
||||
* @return ResultsetInterface|Resultset|ConsultLikeModel[]
|
||||
*/
|
||||
public function findUserConsultLikes($courseId, $userId)
|
||||
{
|
||||
return $this->modelsManager->createBuilder()
|
||||
->columns('cv.*')
|
||||
->addFrom(ConsultModel::class, 'c')
|
||||
->join(ConsultLikeModel::class, 'c.id = cv.consult_id', 'cv')
|
||||
->where('c.course_id = :course_id:', ['course_id' => $courseId])
|
||||
->andWhere('cv.user_id = :user_id:', ['user_id' => $userId])
|
||||
->getQuery()->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $courseId
|
||||
* @param int $userId
|
||||
* @return ResultsetInterface|Resultset|ReviewLikeModel[]
|
||||
*/
|
||||
public function findUserReviewLikes($courseId, $userId)
|
||||
{
|
||||
return $this->modelsManager->createBuilder()
|
||||
->columns('rv.*')
|
||||
->addFrom(ReviewModel::class, 'r')
|
||||
->join(ReviewLikeModel::class, 'r.id = rv.review_id', 'rv')
|
||||
->where('r.course_id = :course_id:', ['course_id' => $courseId])
|
||||
->andWhere('rv.user_id = :user_id:', ['user_id' => $userId])
|
||||
->getQuery()->execute();
|
||||
}
|
||||
|
||||
public function countLessons($courseId)
|
||||
{
|
||||
return ChapterModel::count([
|
||||
|
60
app/Repos/CourseRating.php
Normal file
60
app/Repos/CourseRating.php
Normal file
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repos;
|
||||
|
||||
use App\Models\CourseRating as CourseRatingModel;
|
||||
use App\Models\Review as ReviewModel;
|
||||
use Phalcon\Mvc\Model;
|
||||
|
||||
class CourseRating extends Repository
|
||||
{
|
||||
|
||||
/**
|
||||
* @param int $courseId
|
||||
* @return CourseRatingModel|Model|bool
|
||||
*/
|
||||
public function findByCourseId($courseId)
|
||||
{
|
||||
return CourseRatingModel::findFirst([
|
||||
'conditions' => 'course_id = :course_id:',
|
||||
'bind' => ['course_id' => $courseId],
|
||||
]);
|
||||
}
|
||||
|
||||
public function averageRating($courseId)
|
||||
{
|
||||
return (float)ReviewModel::average([
|
||||
'column' => 'rating',
|
||||
'conditions' => 'course_id = :course_id: AND published = 1',
|
||||
'bind' => ['course_id' => $courseId],
|
||||
]);
|
||||
}
|
||||
|
||||
public function averageRating1($courseId)
|
||||
{
|
||||
return (float)ReviewModel::average([
|
||||
'column' => 'rating1',
|
||||
'conditions' => 'course_id = :course_id: AND published = 1',
|
||||
'bind' => ['course_id' => $courseId],
|
||||
]);
|
||||
}
|
||||
|
||||
public function averageRating2($courseId)
|
||||
{
|
||||
return (float)ReviewModel::average([
|
||||
'column' => 'rating2',
|
||||
'conditions' => 'course_id = :course_id: AND published = 1',
|
||||
'bind' => ['course_id' => $courseId],
|
||||
]);
|
||||
}
|
||||
|
||||
public function averageRating3($courseId)
|
||||
{
|
||||
return (float)ReviewModel::average([
|
||||
'column' => 'rating3',
|
||||
'conditions' => 'course_id = :course_id: AND published = 1',
|
||||
'bind' => ['course_id' => $courseId],
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
@ -5,6 +5,7 @@ namespace App\Services\Frontend\Review;
|
||||
use App\Models\Course as CourseModel;
|
||||
use App\Models\Review as ReviewModel;
|
||||
use App\Models\User as UserModel;
|
||||
use App\Repos\CourseRating as CourseRatingRepo;
|
||||
use App\Services\Frontend\CourseTrait;
|
||||
use App\Services\Frontend\Service as FrontendService;
|
||||
use App\Validators\CourseUser as CourseUserValidator;
|
||||
@ -48,6 +49,8 @@ class ReviewCreate extends FrontendService
|
||||
|
||||
$review->create($data);
|
||||
|
||||
$this->updateCourseRating($course);
|
||||
|
||||
$this->incrCourseReviewCount($course);
|
||||
|
||||
$this->incrUserDailyReviewCount($user);
|
||||
@ -55,6 +58,22 @@ class ReviewCreate extends FrontendService
|
||||
return $review;
|
||||
}
|
||||
|
||||
protected function updateCourseRating(CourseModel $course)
|
||||
{
|
||||
$repo = new CourseRatingRepo();
|
||||
|
||||
$courseRating = $repo->findByCourseId($course->id);
|
||||
|
||||
$courseRating->rating = $repo->averageRating($course->id);
|
||||
$courseRating->rating1 = $repo->averageRating1($course->id);
|
||||
$courseRating->rating2 = $repo->averageRating2($course->id);
|
||||
$courseRating->rating3 = $repo->averageRating3($course->id);
|
||||
$courseRating->update();
|
||||
|
||||
$course->rating = $courseRating->rating;
|
||||
$course->update();
|
||||
}
|
||||
|
||||
protected function incrCourseReviewCount(CourseModel $course)
|
||||
{
|
||||
$this->eventsManager->fire('courseCounter:incrReviewCount', $this, $course);
|
||||
|
@ -108,7 +108,7 @@ class HttpErrorHandler extends Component
|
||||
{
|
||||
$content = $this->translate($e->getMessage());
|
||||
|
||||
$this->flash->error($content);
|
||||
$this->flashSession->error($content['msg']);
|
||||
|
||||
$code = $this->response->getStatusCode();
|
||||
|
||||
|
@ -83,19 +83,24 @@ $config['redis']['port'] = 6379;
|
||||
$config['redis']['auth'] = '1qaz2wsx3edc';
|
||||
|
||||
/**
|
||||
* redis库编号
|
||||
* 缓存所用redis库编号
|
||||
*/
|
||||
$config['redis']['index'] = 0;
|
||||
$config['cache']['db'] = 0;
|
||||
|
||||
/**
|
||||
* 缓存有效期(秒)
|
||||
*/
|
||||
$config['redis']['lifetime'] = 2 * 86400;
|
||||
$config['cache']['lifetime'] = 2 * 3600;
|
||||
|
||||
/**
|
||||
* 会话所用redis库编号
|
||||
*/
|
||||
$config['session']['db'] = 0;
|
||||
|
||||
/**
|
||||
* 会话有效期(秒)
|
||||
*/
|
||||
$config['session']['lifetime'] = 2 * 3600;
|
||||
$config['session']['lifetime'] = 24 * 3600;
|
||||
|
||||
/**
|
||||
* 访问令牌有效期(秒)
|
||||
|
@ -468,29 +468,18 @@ body {
|
||||
line-height: 30px;
|
||||
}
|
||||
|
||||
.course-tab-wrap {
|
||||
.layui-tab-title li {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.course-tab-wrap .tab-count {
|
||||
.layui-tab-title .tab-count {
|
||||
position: absolute;
|
||||
top: 25px;
|
||||
top: -10px;
|
||||
left: 70px;
|
||||
font-size: 12px;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.course-tab-wrap .package-count {
|
||||
left: 275px;
|
||||
}
|
||||
|
||||
.course-tab-wrap .consult-count {
|
||||
left: 370px;
|
||||
}
|
||||
|
||||
.course-tab-wrap .review-count {
|
||||
left: 465px;
|
||||
}
|
||||
|
||||
.course-tab {
|
||||
margin: 0;
|
||||
}
|
||||
@ -803,8 +792,13 @@ body {
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.sidebar-chapter {
|
||||
padding: 20px 15px;
|
||||
}
|
||||
|
||||
.sidebar-chapter .layui-field-title {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.sidebar-chapter .layui-field-title legend {
|
||||
@ -820,11 +814,10 @@ body {
|
||||
padding-top: 10px;
|
||||
margin-bottom: 10px;
|
||||
color: #333;
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.sidebar-lesson-list {
|
||||
margin-left: 15px;
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
.sidebar-lesson-list .lesson-title {
|
||||
@ -845,50 +838,54 @@ body {
|
||||
}
|
||||
|
||||
.read-info {
|
||||
min-height: 428px;
|
||||
min-height: 454px;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.chapter-action {
|
||||
position: relative;
|
||||
padding: 20px;
|
||||
height: 32px;
|
||||
line-height: 32px;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.chapter-action .layui-icon {
|
||||
.chapter-action .share {
|
||||
float: left;
|
||||
}
|
||||
|
||||
.chapter-action .danmu-form {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.share .layui-icon {
|
||||
margin-right: 5px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.chapter-action .active, .chapter-action .layui-icon:hover {
|
||||
.share .active, .share .layui-icon:hover {
|
||||
color: green;
|
||||
}
|
||||
|
||||
.chapter-action span {
|
||||
.share a {
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
.chapter-action i {
|
||||
.share i {
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
.chapter-action em {
|
||||
.share em {
|
||||
font-style: normal;
|
||||
color: #999;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
#icon-danmu-set {
|
||||
position: absolute;
|
||||
top: 22px;
|
||||
right: 530px;
|
||||
.danmu-form .icon-danmu-set {
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
.chapter-action .layui-input {
|
||||
position: absolute;
|
||||
top: 15px;
|
||||
right: 20px;
|
||||
.danmu-form .layui-input {
|
||||
width: 500px;
|
||||
height: 32px;
|
||||
display: inline;
|
||||
line-height: 32px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
@ -9,6 +9,10 @@
|
||||
color: #393D49;
|
||||
}
|
||||
|
||||
.kg-tips .message {
|
||||
margin-top: 30px;
|
||||
}
|
||||
|
||||
.kg-tips .layui-text {
|
||||
width: 500px;
|
||||
margin: 30px auto;
|
||||
|
@ -1,26 +1,35 @@
|
||||
layui.use(['jquery', 'form', 'layer'], function () {
|
||||
layui.use(['jquery', 'layer', 'helper'], function () {
|
||||
|
||||
var $ = layui.jquery;
|
||||
var layer = layui.layer;
|
||||
var helper = layui.helper;
|
||||
|
||||
var $likeIcon = $('#icon-like');
|
||||
var $likeCount = $('#like-count');
|
||||
var likeCount = parseInt($likeCount.text());
|
||||
var myShare = {
|
||||
title: $('input[name="share.title"]').val(),
|
||||
pic: $('input[name="share.pic"]').val(),
|
||||
url: $('input[name="share.url"]').val(),
|
||||
qrcode: $('input[name="share.qrcode"]').val()
|
||||
};
|
||||
|
||||
$likeIcon.on('click', function () {
|
||||
$('.icon-praise').on('click', function () {
|
||||
var $this = $(this);
|
||||
var $likeCount = $this.next();
|
||||
var likeCount = parseInt($likeCount.text());
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: $(this).data('url'),
|
||||
success: function (res) {
|
||||
if ($likeIcon.hasClass('active')) {
|
||||
$likeIcon.removeClass('active');
|
||||
url: $this.data('url'),
|
||||
beforeSend: function () {
|
||||
return helper.checkLogin();
|
||||
},
|
||||
success: function () {
|
||||
if ($this.hasClass('active')) {
|
||||
$this.removeClass('active');
|
||||
$likeCount.text(likeCount - 1);
|
||||
likeCount -= 1;
|
||||
} else {
|
||||
$likeIcon.addClass('active');
|
||||
$this.addClass('active');
|
||||
$likeCount.text(likeCount + 1);
|
||||
likeCount += 1;
|
||||
|
||||
}
|
||||
},
|
||||
error: function (xhr) {
|
||||
@ -30,8 +39,35 @@ layui.use(['jquery', 'form', 'layer'], function () {
|
||||
});
|
||||
});
|
||||
|
||||
$('#icon-share').on('click', function () {
|
||||
$('.icon-wechat').on('click', function () {
|
||||
var content = '<div class="qrcode"><img src="' + myShare.qrcode + '" alt="分享到微信"></div>';
|
||||
layer.open({
|
||||
type: 1,
|
||||
title: false,
|
||||
closeBtn: 0,
|
||||
shadeClose: true,
|
||||
content: content
|
||||
});
|
||||
});
|
||||
|
||||
$('.icon-qq').on('click', function () {
|
||||
var title = '推荐一门好课:' + myShare.title + ',快来和我一起学习吧!';
|
||||
Share.qq(title, myShare.url, myShare.pic);
|
||||
});
|
||||
|
||||
$('.icon-weibo').on('click', function () {
|
||||
var title = '推荐一门好课:' + myShare.title + ',快来和我一起学习吧!';
|
||||
Share.weibo(title, myShare.url, myShare.pic);
|
||||
});
|
||||
|
||||
$('.icon-danmu-set').on('click', function () {
|
||||
layer.open({
|
||||
type: 1,
|
||||
title: '弹幕设置',
|
||||
area: '600px',
|
||||
shadeClose: true,
|
||||
content: $('#my-danmu-set')
|
||||
});
|
||||
});
|
||||
|
||||
});
|
@ -4,11 +4,11 @@ layui.use(['jquery', 'layer', 'helper'], function () {
|
||||
var layer = layui.layer;
|
||||
var helper = layui.helper;
|
||||
|
||||
var course = {
|
||||
title: $('input[name="course.title"]').val(),
|
||||
cover: $('input[name="course.cover"]').val(),
|
||||
url: $('input[name="course.url"]').val(),
|
||||
qrcode: $('input[name="course.qrcode"]').val()
|
||||
var myShare = {
|
||||
title: $('input[name="share.title"]').val(),
|
||||
pic: $('input[name="share.cover"]').val(),
|
||||
url: $('input[name="share.url"]').val(),
|
||||
qrcode: $('input[name="share.qrcode"]').val()
|
||||
};
|
||||
|
||||
$('.rating-btn').on('click', function () {
|
||||
@ -44,7 +44,7 @@ layui.use(['jquery', 'layer', 'helper'], function () {
|
||||
});
|
||||
|
||||
$('.icon-wechat').on('click', function () {
|
||||
var content = '<div class="qrcode"><img src="' + course.qrcode + '" alt="分享到微信"></div>';
|
||||
var content = '<div class="qrcode"><img src="' + myShare.qrcode + '" alt="分享到微信"></div>';
|
||||
layer.open({
|
||||
type: 1,
|
||||
title: false,
|
||||
@ -55,13 +55,13 @@ layui.use(['jquery', 'layer', 'helper'], function () {
|
||||
});
|
||||
|
||||
$('.icon-qq').on('click', function () {
|
||||
var title = '推荐一门好课:' + course.title + ',快来和我一起学习吧!';
|
||||
Share.qq(title, null, course.cover);
|
||||
var title = '推荐一门好课:' + myShare.title + ',快来和我一起学习吧!';
|
||||
Share.qq(title, myShare.url, myShare.pic);
|
||||
});
|
||||
|
||||
$('.icon-weibo').on('click', function () {
|
||||
var title = '推荐一门好课:' + course.title + ',快来和我一起学习吧!';
|
||||
Share.weibo(title, null, course.cover);
|
||||
var title = '推荐一门好课:' + myShare.title + ',快来和我一起学习吧!';
|
||||
Share.weibo(title, myShare.url, myShare.pic);
|
||||
});
|
||||
|
||||
$('body').on('click', '.icon-praise', function () {
|
||||
|
@ -1,8 +1,7 @@
|
||||
layui.use(['jquery', 'form', 'slider', 'layer', 'helper'], function () {
|
||||
layui.use(['jquery', 'form', 'layer', 'helper'], function () {
|
||||
|
||||
var $ = layui.jquery;
|
||||
var form = layui.form;
|
||||
var slider = layui.slider;
|
||||
var layer = layui.layer;
|
||||
var helper = layui.helper;
|
||||
|
||||
@ -66,10 +65,6 @@ layui.use(['jquery', 'form', 'slider', 'layer', 'helper'], function () {
|
||||
|
||||
initDanmu();
|
||||
|
||||
$('#icon-danmu-set').on('click', function () {
|
||||
showMyDanmuSet();
|
||||
});
|
||||
|
||||
form.on('switch(danmu.status)', function (data) {
|
||||
if (data.elem.checked) {
|
||||
$('#danmu').danmu('setOpacity', 1);
|
||||
@ -164,15 +159,6 @@ layui.use(['jquery', 'form', 'slider', 'layer', 'helper'], function () {
|
||||
}
|
||||
}
|
||||
|
||||
function showMyDanmuSet() {
|
||||
layer.open({
|
||||
type: 1,
|
||||
title: '弹幕设置',
|
||||
area: '600px',
|
||||
content: $('#my-danmu-set')
|
||||
});
|
||||
}
|
||||
|
||||
function startDanmu() {
|
||||
$('#danmu').danmu('danmuResume');
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user