64 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			PHP
		
	
	
		
		
			
		
	
	
			64 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			PHP
		
	
	
| 
								 | 
							
								<?php
							 | 
						||
| 
								 | 
							
								namespace app\controller;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								use app\model\Category;
							 | 
						||
| 
								 | 
							
								use app\model\Model;
							 | 
						||
| 
								 | 
							
								use app\model\SpecialRoute;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								class Error extends BaseController
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    protected $data = [];
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    public function __call($method, $args)
							 | 
						||
| 
								 | 
							
								    {
							 | 
						||
| 
								 | 
							
								        //特殊路径处理
							 | 
						||
| 
								 | 
							
								        $specialRoute = SpecialRoute::findOneByUrl($this->request->baseUrl());
							 | 
						||
| 
								 | 
							
								        if(!empty($specialRoute)){
							 | 
						||
| 
								 | 
							
								            switch ($specialRoute["type"]){
							 | 
						||
| 
								 | 
							
								                case SpecialRoute::type_archives:
							 | 
						||
| 
								 | 
							
								                    return action("article/detail",["id"=>$specialRoute->relation_id]);
							 | 
						||
| 
								 | 
							
								                    break;
							 | 
						||
| 
								 | 
							
								                case SpecialRoute::type_archives_category:
							 | 
						||
| 
								 | 
							
								                    $category = Category::findInfoById($specialRoute->relation_id);
							 | 
						||
| 
								 | 
							
								                    if(empty($category)){
							 | 
						||
| 
								 | 
							
								                        break;
							 | 
						||
| 
								 | 
							
								                    }
							 | 
						||
| 
								 | 
							
								                    switch ($category->model_id){
							 | 
						||
| 
								 | 
							
								                        case Model::MODEL_PRODUCT:
							 | 
						||
| 
								 | 
							
								                            return action("product/index",["id"=>$specialRoute->relation_id]);
							 | 
						||
| 
								 | 
							
								                            break;
							 | 
						||
| 
								 | 
							
								                        case Model::MODEL_ARTICLE:
							 | 
						||
| 
								 | 
							
								                            return action("article/index",["categoryId"=>$specialRoute->relation_id]);
							 | 
						||
| 
								 | 
							
								                            break;
							 | 
						||
| 
								 | 
							
								                        case Model::MODEL_PAGE:
							 | 
						||
| 
								 | 
							
								                            return action("page/index",["categoryId"=>$specialRoute->relation_id]);
							 | 
						||
| 
								 | 
							
								                            break;
							 | 
						||
| 
								 | 
							
								                    }
							 | 
						||
| 
								 | 
							
								                    break;
							 | 
						||
| 
								 | 
							
								            }
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 | 
							
								        $this->data['seoTitle'] = '404';
							 | 
						||
| 
								 | 
							
								        return $this->redirect('/404.html');
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								    
							 | 
						||
| 
								 | 
							
								    public function jump()
							 | 
						||
| 
								 | 
							
								    {
							 | 
						||
| 
								 | 
							
								        $param = request()->param();
							 | 
						||
| 
								 | 
							
								        return view()->assign($param);
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    // 404
							 | 
						||
| 
								 | 
							
								    public function notFind()
							 | 
						||
| 
								 | 
							
								    {
							 | 
						||
| 
								 | 
							
								        $this->data['seoTitle'] = '404';
							 | 
						||
| 
								 | 
							
								        return view('error/404')->assign($this->data);
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    // 500
							 | 
						||
| 
								 | 
							
								    public function serviceFail()
							 | 
						||
| 
								 | 
							
								    {
							 | 
						||
| 
								 | 
							
								        $this->data['seoTitle'] = '500';
							 | 
						||
| 
								 | 
							
								        return view('error/500')->assign($this->data);
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								}
							 |