feat: 专题 - 电力品线首页

This commit is contained in:
2025-11-20 11:57:03 +08:00
parent fec6dca03d
commit c72cfa2e43
4 changed files with 165 additions and 0 deletions

View File

@@ -0,0 +1,127 @@
<?php
declare(strict_types=1);
namespace app\index\controller;
use app\index\model\SysBannerModel;
use think\facade\View;
use think\Request;
/**
* 专题 - 电力品线控制器
*/
class TopicPowerProdline extends Common
{
/**
* 重写控制器初始化
*/
public function initialize()
{
// 获取国家/语言列表
$languages = $this->getLanguages();
// 输出国家/语言列表
if (get_platform() == 'mobile') {
View::assign('header_languages', $languages);
}
// 获取当前语言
$current_language = $this->getCurrentLanguage($languages);
if (!empty($current_language)) {
$this->lang_id = $current_language['id'];
}
// 获取产品分类
$categorys = $this->getProductCategory($this->lang_id);
// 输出产品分类
View::assign('header_categorys', $categorys);
// 获取系统配置
$configs = $this->getSysConfig($this->lang_id, ['basic', 'contact', 'media']);
$this->basic_config = $configs['basic'];
// 输出系统配置
View::assign('basic_config', $configs['basic']);
View::assign('contact_config', $configs['contact']);
View::assign('media_config', $configs['media']);
// 获取底部导航
$footer_navigation = $this->getNavigation('NAV_67f60be43df8d', $this->lang_id);
// 输出底部导航
View::assign('footer_navigation', $footer_navigation);
}
/**
* 专题 - 电力品线首页
*/
public function index()
{
$banners = SysBannerModel::with([
'items' => function ($query) {
$query->withoutField(['sort', 'created_at', 'updated_at', 'deleted_at'])
->order(['sort' => 'asc', 'id' => 'desc'])
->enabled(true);
}
])
->atPlatform(request()->from)
->uniqueLabel([
'BANNER_691e729f2428d',
'BANNER_691e732e4ad69',
'BANNER_691e752d2bbe2',
'BANNER_691e75561c4d3',
'BANNER_691e75ec9391c',
'BANNER_691e7616545bf',
'BANNER_691e763fc08f4',
'BANNER_691e765a27eba',
'BANNER_691e76b6af393',
])
->language($this->lang_id)
->enabled(true)
->order(['sort' => 'asc', 'id' => 'desc'])
->select();
$data = [];
if (!$banners->isEmpty()) {
$banners_map = [];
foreach ($banners as $banner) {
$banners_map[$banner->unique_label] = $banner;
}
// 焦点轮播图
$focus_image = data_get($banners_map, 'BANNER_691e729f2428d')?->items->toArray();
if (!empty($focus_image)) $data['focus_image'] = $focus_image;
// 分类
$category = data_get($banners_map, 'BANNER_691e732e4ad69')?->items->toArray();
if (!empty($category)) $data['category'] = $category;
// 为什么选择奥睿科相关数据
$why_choose = data_get($banners_map, 'BANNER_691e752d2bbe2')?->items->toArray();
if (!empty($why_choose)) $data['why_choose'] = $why_choose;
// 差旅充
$travel_charger = data_get($banners_map, 'BANNER_691e75561c4d3')?->items->toArray();
if (!empty($travel_charger)) $data['travel_charger'] = $travel_charger;
// 家居充
$home_charger = data_get($banners_map, 'BANNER_691e75ec9391c')?->items->toArray();
if (!empty($home_charger)) $data['home_charger'] = $home_charger;
// 桌面充
$desktop_charger = data_get($banners_map, 'BANNER_691e7616545bf')?->items->toArray();
if (!empty($desktop_charger)) $data['desktop_charger'] = $desktop_charger;
// 墙充
$wall_charger = data_get($banners_map, 'BANNER_691e763fc08f4')?->items->toArray();
if (!empty($wall_charger)) $data['wall_charger'] = $wall_charger;
// 转换器
$converter = data_get($banners_map, 'BANNER_691e765a27eba')?->items->toArray();
if (!empty($converter)) $data['converter'] = $converter;
// 底部介绍
$footer_info = data_get($banners_map, 'BANNER_691e76b6af393')?->items->toArray();
if (!empty($footer_info)) $data['footer_info'] = $footer_info;
}
View::assign('data', $data);
return View::fetch('index');
}
}

View File

@@ -105,6 +105,12 @@ Route::group('topic', function () {
// 专题-Nas软件下载页 // 专题-Nas软件下载页
Route::get('download', 'TopicNas/download'); Route::get('download', 'TopicNas/download');
}); });
// 专题 - 电力品线
Route::group("power_prodline", function() {
// 专题 - 电力品线首页
Route::get('index', 'TopicPowerProdline/index');
});
}); });
// 数据迁移 // 数据迁移

View File

@@ -0,0 +1,16 @@
{extend name="public/nas_base" /}
{block name="style"}
{/block}
{block name="header"}
<!-- 重置header头为空 -->
{/block}
{block name="main"}
{/block}
{block name="footer"}
<!-- 重置footer头为空 -->
{/block}
{block name="script"}
{/block}

View File

@@ -0,0 +1,16 @@
{extend name="public/nas_base" /}
{block name="style"}
{/block}
{block name="header"}
<!-- 重置header头为空 -->
{/block}
{block name="main"}
{/block}
{block name="footer"}
<!-- 重置footer头为空 -->
{/block}
{block name="script"}
{/block}