76 lines
		
	
	
		
			2.9 KiB
		
	
	
	
		
			PHP
		
	
	
		
		
			
		
	
	
			76 lines
		
	
	
		
			2.9 KiB
		
	
	
	
		
			PHP
		
	
	
| 
								 | 
							
								<?php
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								namespace app\controller;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								use app\model\{Category, Block, History, Honour, Model as MModel, Article as MArticle, PositionModel};
							 | 
						||
| 
								 | 
							
								use think\response\View;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								class Page extends Base
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    /**
							 | 
						||
| 
								 | 
							
								     * @return View|void
							 | 
						||
| 
								 | 
							
								     */
							 | 
						||
| 
								 | 
							
								    public function index()
							 | 
						||
| 
								 | 
							
								    {
							 | 
						||
| 
								 | 
							
								        $rule     = $this->request->rule();
							 | 
						||
| 
								 | 
							
								        $rule     = $rule->getRule();
							 | 
						||
| 
								 | 
							
								        $category = Category::getById($this->request->param("category_id"));
							 | 
						||
| 
								 | 
							
								        //没有category_id  则通过路由查询
							 | 
						||
| 
								 | 
							
								        $category = $category ? $category : Category::getByRuleAlias($rule);
							 | 
						||
| 
								 | 
							
								        if ($category) {
							 | 
						||
| 
								 | 
							
								            $description = $category['seo_description'] ?: $this->system['seo_description'];
							 | 
						||
| 
								 | 
							
								            $keywords    = $category['seo_keywords'] ?: $this->system['seo_keywords'];
							 | 
						||
| 
								 | 
							
								            $title       = $category['seo_title'] ?: $category['title'].' | '.$this->system['seo_title'];
							 | 
						||
| 
								 | 
							
								            $this->setSeo($title, $keywords, $description);
							 | 
						||
| 
								 | 
							
								        } else {
							 | 
						||
| 
								 | 
							
								            $this->redirect('/404.html');
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 | 
							
								        $childCategory   = Category::getChildrenByParentId($category['id']);
							 | 
						||
| 
								 | 
							
								        $parentCategory  = Category::getById($category['parent_id']);
							 | 
						||
| 
								 | 
							
								        $brotherCategory = Category::getChildrenByParentId($category['parent_id']);
							 | 
						||
| 
								 | 
							
								        $blocks          = Block::getByCategoryId($category['id']);
							 | 
						||
| 
								 | 
							
								        $blocks          = Block::convertValue($blocks);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        // 父级单页配置的公共信息
							 | 
						||
| 
								 | 
							
								        $parentBlocks = [];
							 | 
						||
| 
								 | 
							
								        if (!empty($parentCategory) && $parentCategory['model_id'] == MModel::MODEL_PAGE) {
							 | 
						||
| 
								 | 
							
								            $parentBlocks = Block::getByCategoryId($parentCategory['id']);
							 | 
						||
| 
								 | 
							
								            $parentBlocks = Block::convertValue($parentBlocks);
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        $this->handleExtraShow($category);
							 | 
						||
| 
								 | 
							
								        $this->data['categoryId']      = $category['id'];
							 | 
						||
| 
								 | 
							
								        $this->data['category']        = $category;
							 | 
						||
| 
								 | 
							
								        $this->data['childCategory']   = $childCategory;
							 | 
						||
| 
								 | 
							
								        $this->data['blocks']          = $blocks;
							 | 
						||
| 
								 | 
							
								        $this->data['parentBlocks']    = $parentBlocks;
							 | 
						||
| 
								 | 
							
								        $this->data['rule']            = $rule;
							 | 
						||
| 
								 | 
							
								        $this->data['parentCategory']  = $parentCategory;
							 | 
						||
| 
								 | 
							
								        $this->data['brotherCategory'] = $brotherCategory;
							 | 
						||
| 
								 | 
							
								        $this->data['bodyClass']       = 'main';
							 | 
						||
| 
								 | 
							
								        $this->setExtraBaseConfig();
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        return $this->view($category['template_detail']);
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    // 补充显示的信息
							 | 
						||
| 
								 | 
							
								    private function handleExtraShow($category)
							 | 
						||
| 
								 | 
							
								    {
							 | 
						||
| 
								 | 
							
								        // 关于我们
							 | 
						||
| 
								 | 
							
								        if ($category['template_detail'] == 'about') {
							 | 
						||
| 
								 | 
							
								            // 发展历程
							 | 
						||
| 
								 | 
							
								            $this->data['historyList'] = History::order('sort', 'asc')->select();
							 | 
						||
| 
								 | 
							
								            // 荣誉资质
							 | 
						||
| 
								 | 
							
								            $this->data['honourList'] = Honour::order('sort', 'desc')->select()->toArray();
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        // 职位发展
							 | 
						||
| 
								 | 
							
								        if ($category['alias'] == 'career') {
							 | 
						||
| 
								 | 
							
								            // 职位招聘
							 | 
						||
| 
								 | 
							
								            $this->data['positionList'] = PositionModel::order('sort', 'desc')
							 | 
						||
| 
								 | 
							
								                ->where('visible', 1)
							 | 
						||
| 
								 | 
							
								                ->order('id', 'desc')->select()->toArray();
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								}
							 |