From 9052b70816c872c9ff3af5450a4f8f931d8faa95 Mon Sep 17 00:00:00 2001 From: jsasg <735273025@qq.com> Date: Mon, 14 Apr 2025 10:30:12 +0800 Subject: [PATCH 1/8] =?UTF-8?q?feat:=20=E8=8B=B1=E6=96=87nas=E7=9B=B8?= =?UTF-8?q?=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/us/controller/BaseController.php | 41 +++++ app/us/controller/TopsNas.php | 8 + app/us/view/include/top-header-nas.phtml | 15 -- app/us/view/tops_nas/download.phtml | 213 +++++++++++++++++++---- app/us/view/tops_nas/helper.phtml | 0 5 files changed, 230 insertions(+), 47 deletions(-) create mode 100644 app/us/view/tops_nas/helper.phtml diff --git a/app/us/controller/BaseController.php b/app/us/controller/BaseController.php index 84041d9..baf0cc6 100755 --- a/app/us/controller/BaseController.php +++ b/app/us/controller/BaseController.php @@ -175,6 +175,47 @@ class BaseController extends Controller { return $tree; } + protected function buildTree($data, $pid = 0) + { + $tree = []; + foreach ($data as $val) { + if ($val['pid'] == $pid) { + $children = $this->buildTree($data, $val['id']); + if (!empty($children)) { + $val['items'] = $children; + } + $tree[] = $val; + } + } + + return $tree; + } + + /** + * nasNavigation 获取并组装nas专题页的top导航和footer + */ + protected function nasNavigation() + { + $navs = Loader::model('Navigation')->field([ + 'id', + 'pid', + 'name', + 'url', + 'value', + 'data_type', + 'is_new_window_open', + ]) + ->where('stat', '=', 0) + ->where('nav_type', '=', 'tops_nas_header') + ->where('country_code', '=', $this->country_code) + ->order('sort') + ->select(); + + $navs_array = collection($navs)->toArray(); + $header = $this->NavDataDealWith($navs_array); + $this->assign('nav_header', $this->buildTree($header)); + } + //导航初始化 private function navInit(){ // 读取缓存数据 diff --git a/app/us/controller/TopsNas.php b/app/us/controller/TopsNas.php index c9a9935..f0d0864 100755 --- a/app/us/controller/TopsNas.php +++ b/app/us/controller/TopsNas.php @@ -7,8 +7,16 @@ class TopsNas extends BaseController public function _initialize() { parent::_initialize(); + parent::nasNavigation(); } + // 帮助中心 + public function helper() + { + + } + + // 下载 public function download() { return $this->fetch(); diff --git a/app/us/view/include/top-header-nas.phtml b/app/us/view/include/top-header-nas.phtml index 39c2f7f..ca5398f 100755 --- a/app/us/view/include/top-header-nas.phtml +++ b/app/us/view/include/top-header-nas.phtml @@ -7,21 +7,6 @@ onclick="location.href='{:url(\'TopsNas/index\')}'" />