feat: Nas专题帮助中心
This commit is contained in:
@@ -3,6 +3,8 @@ declare (strict_types = 1);
|
||||
|
||||
namespace app\index\controller;
|
||||
|
||||
use app\index\model\ArticleCategoryModel;
|
||||
use app\index\model\ArticleModel;
|
||||
use app\index\model\SysBannerModel;
|
||||
use think\facade\View;
|
||||
|
||||
@@ -175,6 +177,41 @@ class TopicNas extends Common
|
||||
*/
|
||||
public function help()
|
||||
{
|
||||
// 获取文章分类及文章数据
|
||||
$parent = ArticleCategoryModel::uniqueLabel('CATEGORY_681182e0a4529')->language($this->lang_id)->value('id');
|
||||
$article_categorys = ArticleCategoryModel::with(['article' => function($query) {
|
||||
$query->field(['id', 'title', 'category_id'])->limit(3);
|
||||
}])
|
||||
->field([
|
||||
'id',
|
||||
'name',
|
||||
'icon'
|
||||
])
|
||||
->language($this->lang_id)
|
||||
->parent($parent)
|
||||
->isShow(true)
|
||||
->select();
|
||||
View::assign('article_categorys', $article_categorys);
|
||||
|
||||
$contacts = [];
|
||||
// 获取banner数据
|
||||
$banners = SysBannerModel::with(['items' => function ($query) {
|
||||
$query->withoutField(['sort', 'created_at', 'updated_at', 'deleted_at']);
|
||||
}])
|
||||
->uniqueLabel(['BANNER_6819754be2dc6'])
|
||||
->language($this->lang_id)
|
||||
->enabled(true)
|
||||
->order(['sort' => 'asc', 'id' => 'desc'])
|
||||
->select();
|
||||
if (!$banners->isEmpty()) {
|
||||
$banners_map = [];
|
||||
foreach ($banners as $banner) {
|
||||
$banners_map[$banner->unique_label] = $banner;
|
||||
}
|
||||
$contacts = data_get($banners_map, 'BANNER_6819754be2dc6')?->items->toArray();
|
||||
}
|
||||
View::assign('contacts', $contacts);
|
||||
|
||||
return View::fetch('help');
|
||||
}
|
||||
|
||||
@@ -183,9 +220,49 @@ class TopicNas extends Common
|
||||
*/
|
||||
public function helpDetail()
|
||||
{
|
||||
$id = request()->get('id');
|
||||
// 获取文章详情
|
||||
$article = ArticleModel::bypk($id)->find();
|
||||
View::assign('article', $article);
|
||||
|
||||
// 获取文章分类及文章数据
|
||||
$parent = ArticleCategoryModel::uniqueLabel('CATEGORY_681182e0a4529')->value('id');
|
||||
$article_categorys = ArticleCategoryModel::with(['article' => function ($query) {
|
||||
$query->field(['id', 'title', 'category_id']);
|
||||
}])
|
||||
->field([
|
||||
'id',
|
||||
'name',
|
||||
'icon'
|
||||
])
|
||||
->language($this->lang_id)
|
||||
->parent($parent)
|
||||
->isShow(true)
|
||||
->select();
|
||||
View::assign('article_categorys', $article_categorys);
|
||||
|
||||
return View::fetch('help_detail');
|
||||
}
|
||||
|
||||
/**
|
||||
* 专题-Nas帮助中心搜索
|
||||
*/
|
||||
public function helpSearch()
|
||||
{
|
||||
$keywords = request()->post('keywords');
|
||||
// 根据关键词查询文章
|
||||
$articles = ArticleModel::field([
|
||||
'id',
|
||||
'title'
|
||||
])
|
||||
->withSearch(['title'], [
|
||||
'title' => $keywords??null
|
||||
])
|
||||
->language($this->lang_id)
|
||||
->select();
|
||||
|
||||
return success('success', $articles->toArray());
|
||||
}
|
||||
|
||||
/**
|
||||
* 专题-Nas软件下载页
|
||||
|
||||
Reference in New Issue
Block a user