1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-26 20:52:44 +08:00

vip.js -> vip.index.js

This commit is contained in:
xiaochong0302 2023-12-11 12:38:47 +08:00
parent 435bc12035
commit c859deec44
7 changed files with 59 additions and 14 deletions

View File

@ -9,6 +9,7 @@ namespace App\Http\Home\Controllers;
use App\Caches\FeaturedArticleList as FeaturedArticleListCache;
use App\Caches\FeaturedCourseList as FeaturedCourseListCache;
use App\Caches\FeaturedQuestionList as FeaturedQuestionListCache;
use App\Services\Logic\Article\TopAuthorList as TopAuthorListService;
use App\Services\Logic\Question\HotQuestionList as HotQuestionListService;
use App\Services\Logic\Question\TopAnswererList as TopAnswererListService;
@ -63,6 +64,20 @@ class WidgetController extends Controller
$this->view->setVar('articles', $articles);
}
/**
* @Get("/featured/questions", name="home.widget.featured_questions")
*/
public function featuredQuestionsAction()
{
$cache = new FeaturedQuestionListCache();
$questions = $cache->get();
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
$this->view->pick('widget/featured_questions');
$this->view->setVar('questions', $questions);
}
/**
* @Get("/hot/questions", name="home.widget.hot_questions")
*/

View File

@ -57,17 +57,8 @@
{% endblock %}
{% block inline_js %}
{% block include_js %}
<script>
layui.use(['form'], function () {
var form = layui.form;
form.on('submit(search)', function (data) {
if (data.field.query === '') {
return false;
}
});
});
</script>
{{ js_include('home/js/search.index.js') }}
{% endblock %}

View File

@ -10,6 +10,17 @@
</div>
{% endif %}
{% if type == 'course' %}
{% set load_url = url({'for':'home.widget.featured_courses'}) %}
<div class="sidebar" id="sidebar-course-list" data-url="{{ load_url }}"></div>
{% elseif type == 'article' %}
{% set load_url = url({'for':'home.widget.featured_articles'}) %}
<div class="sidebar" id="sidebar-article-list" data-url="{{ load_url }}"></div>
{% elseif type == 'question' %}
{% set load_url = url({'for':'home.widget.featured_questions'}) %}
<div class="sidebar" id="sidebar-question-list" data-url="{{ load_url }}"></div>
{% endif %}
{% if related_queries %}
<div class="layui-card">
<div class="layui-card-header">相关搜索</div>

View File

@ -55,6 +55,6 @@
{% block include_js %}
{{ js_include('home/js/vip.js') }}
{{ js_include('home/js/vip.index.js') }}
{% endblock %}

View File

@ -2,7 +2,7 @@
<div class="layui-card">
<div class="layui-card-header">推荐问题</div>
<div class="layui-card-body">
<div class="sidebar-question-list">
<div class="sidebar-article-list">
{% for question in questions %}
{% set question_url = url({'for':'home.question.show','id':question.id}) %}
<div class="title layui-elip">
@ -11,7 +11,7 @@
<div class="meta">
<span class="view">{{ question.view_count }} 浏览</span>
<span class="like">{{ question.like_count }} 点赞</span>
<span class="comment">{{ question.comment_count }} 评论</span>
<span class="answer">{{ question.answer_count }} 回答</span>
</div>
{% endfor %}
</div>

View File

@ -0,0 +1,28 @@
layui.use(['jquery', 'form', 'layer', 'helper'], function () {
var $ = layui.jquery;
var form = layui.form;
var helper = layui.helper;
var $courseList = $('#sidebar-course-list');
if ($courseList.length > 0) {
helper.ajaxLoadHtml($courseList.data('url'), $courseList.attr('id'));
}
var $articleList = $('#sidebar-article-list');
if ($articleList.length > 0) {
helper.ajaxLoadHtml($articleList.data('url'), $articleList.attr('id'));
}
var $questionList = $('#sidebar-question-list');
if ($questionList.length > 0) {
helper.ajaxLoadHtml($questionList.data('url'), $questionList.attr('id'));
}
form.on('submit(search)', function (data) {
if (data.field.query === '') {
return false;
}
});
});