From 417ce665fcbdd839c069833e8db1634b2c98ef4f Mon Sep 17 00:00:00 2001 From: zwesy Date: Wed, 25 Nov 2020 20:15:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=EF=BC=9A=E5=8F=96=E6=B6=88?= =?UTF-8?q?=E8=B7=AF=E7=94=B1=E5=9C=B0=E5=9D=80=E8=AF=AD=E4=B9=89=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/Article.php | 56 +++++++++++++++++++------------------- app/controller/Page.php | 39 +++++++++----------------- app/widget/Menu.php | 1 + route/app.php | 16 ++++------- runtime/.gitignore | 4 --- view/index/index.html | 8 +++--- view/public/footer.html | 12 ++------ view/public/menu.html | 14 +++------- 8 files changed, 58 insertions(+), 92 deletions(-) delete mode 100644 runtime/.gitignore diff --git a/app/controller/Article.php b/app/controller/Article.php index 8ecaf54..6018362 100644 --- a/app/controller/Article.php +++ b/app/controller/Article.php @@ -50,32 +50,32 @@ class Article extends Base return $this->view($category['template_list'] ?? ''); } - //新闻列表 - public function news($categoryId) - { - dump('新闻资讯'); - dump($categoryId); - - } - - //新闻详情 - public function newsDetail($newsId) - { - dump('新闻资讯详情'); - dump($newsId); - } - - // 产品列表 - public function product($categoryId) - { - dump('产品列表'); - dump($categoryId); - } - - // 产品列表 - public function productDetail($productId) - { - dump('产品详情'); - dump($productId); - } +// //新闻列表 +// public function news($categoryId) +// { +// dump('新闻资讯'); +// dump($categoryId); +// +// } +// +// //新闻详情 +// public function newsDetail($newsId) +// { +// dump('新闻资讯详情'); +// dump($newsId); +// } +// +// // 产品列表 +//// public function product($categoryId) +//// { +//// dump('产品列表'); +//// dump($categoryId); +//// } +// +// // 产品列表 +// public function productDetail($productId) +// { +// dump('产品详情'); +// dump($productId); +// } } \ No newline at end of file diff --git a/app/controller/Page.php b/app/controller/Page.php index 878e3b3..03a57c0 100644 --- a/app/controller/Page.php +++ b/app/controller/Page.php @@ -8,38 +8,25 @@ class Page extends Base private function getPageCommonData($categoryId) { $resp = true; - $category = Category::getById($categoryId); - if ($category) { - $description = $category['description'] ? $category['description'] : $this->system['seo_description']; - $this->setSeo($category['title'], $this->system['seo_keywords'], $description); - } else { - $resp = false; - } - $childCategory = Category::getChildrenByParentId($categoryId); - $this->data['categoryId'] = $categoryId; - $this->data['category'] = $category; - $this->data['childCategory'] = $childCategory; - $this->data['blocks'] = Block::getByCategoryId($categoryId); + return $resp; } // 默认单页页面 public function index($categoryId) { - $resp = $this->getPageCommonData($categoryId); - if(!$resp) { - return $this->error('错误页面'); + $category = Category::getById($categoryId); + if ($category) { + $description = $category['description'] ? $category['description'] : $this->system['seo_description']; + $this->setSeo($category['title'], $this->system['seo_keywords'], $description); + } else { + return $this->error('页面错误'); } - return $this->view($this->data['category']['template_detail']); - } - - // 营销页面 - public function marketing($categoryId) - { - $resp = $this->getPageCommonData($categoryId); - if(!$resp) { - return $this->error('错误页面'); - } - return $this->view($this->data['category']['template_detail']); + $childCategory = Category::getChildrenByParentId($categoryId); + $this->data['categoryId'] = $categoryId; + $this->data['category'] = $category; + $this->data['childCategory'] = $childCategory; + $this->data['blocks'] = Block::getByCategoryId($categoryId); + return $this->view($category['template_detail']); } } \ No newline at end of file diff --git a/app/widget/Menu.php b/app/widget/Menu.php index 5059535..1cb97e7 100644 --- a/app/widget/Menu.php +++ b/app/widget/Menu.php @@ -9,6 +9,7 @@ class Menu public function index($categoryId) { $menus = Cache::get('front_menus'); + $menus = null; if(empty($menus)){ $menus = Category::getListForFrontMenu(); Cache::set('front_menus', $menus, 3600 * 12); diff --git a/route/app.php b/route/app.php index fca4837..e7c70a8 100644 --- a/route/app.php +++ b/route/app.php @@ -11,13 +11,9 @@ use think\facade\Route; Route::get('article/:id', "article/detail"); -Route::get('articles/:categoryId', "article/index"); -Route::get('page/:categoryId', "page/index"); -// 新闻 -Route::get('news/detail/:newsId', "article/newsDetail"); -Route::get('news/:categoryId', "article/news"); -// 产品 -Route::get('product/detail/:productId', "article/productDetail"); -Route::get('product/:categoryId', "article/product"); -// 营销 -Route::get('marketing/:categoryId', "page/marketing"); \ No newline at end of file +Route::get('articles/:category_id', "article/index"); +Route::get('page/:category_id', "page/index"); + + + + diff --git a/runtime/.gitignore b/runtime/.gitignore deleted file mode 100644 index bf1f8a9..0000000 --- a/runtime/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -* -!.gitignore - - diff --git a/view/index/index.html b/view/index/index.html index f9f1de9..8827328 100644 --- a/view/index/index.html +++ b/view/index/index.html @@ -34,7 +34,7 @@

{$product['summary']|raw}

- 了解详情+ + 了解详情+ {:str_pad($idx + 1, 2, '0', STR_PAD_LEFT)}
@@ -49,7 +49,7 @@
{$blocks['marketing_name']['value'] ?? ''}

{$blocks['marketing_describe']['value'] ?? ''}

- 了解详情+ + 了解详情+
@@ -62,7 +62,7 @@ {if isset($newsEnterprises) && count($newsEnterprises) > 0} {foreach $newsEnterprises as $news}
  • - + {$news['title']|raw} {$news['create_time']|date='Y-m-d'} @@ -75,7 +75,7 @@ {if isset($newsIndustries) && count($newsIndustries) > 0} {foreach $newsIndustries as $news}
  • - + {$news['title']|raw} {$news['create_time']|date='Y-m-d'} diff --git a/view/public/footer.html b/view/public/footer.html index 32f1b98..6a34334 100644 --- a/view/public/footer.html +++ b/view/public/footer.html @@ -6,16 +6,8 @@ {if isset($footerMenus) && count($footerMenus) > 0} {foreach footerMenus as $menu} {php} - $aHref = 'javascript:;'; - if (!empty($menu['url'])) { - $aHref = $menu['url']; - } elseif ($menu['is_index']) { - $aHref = url('/'); - } elseif (!empty($menu['template_list'])) { - $aHref = url('/'.$menu['template_list'].'/'.$menu['id']); - } elseif (!empty($menu['template'])) { - $aHref = url('/'.$menu['template'].'/'.$menu['id']); - } + $aHref = getUri($menu); + $aHref = empty($aHref) ? 'javascript:;' : $aHref; {/php} {$menu['title']} {/foreach} diff --git a/view/public/menu.html b/view/public/menu.html index 895ad49..1bdcc2b 100644 --- a/view/public/menu.html +++ b/view/public/menu.html @@ -8,21 +8,15 @@ function getMenus($menus, $level = 1, $currentFirstId, $categoryId) { if($level > 1) { $menuHtml .= '
    '; } + + foreach ($menus as $menu) { $activeClass = ''; - $aHref = 'javascript:;'; if ($currentFirstId == $menu['id'] || $categoryId == $menu['id'] || ($currentFirstId == 0 && $menu['is_index'])) { $activeClass = ' active'; } - if (!empty($menu['url'])) { - $aHref = $menu['url']; - } elseif ($menu['is_index']) { - $aHref = url('/'); - } elseif (!empty($menu['template_list'])) { - $aHref = url('/'.$menu['template_list'].'/'.$menu['id']); - } elseif (!empty($menu['template'])) { - $aHref = url('/'.$menu['template'].'/'.$menu['id']); - } + $aHref = getUri($menu); + $aHref = empty($aHref) ? 'javascript:;' : $aHref; if($level == 1) { $menuHtml .= '
  • '; $menuHtml .= ''.$menu['title'].'';