Base.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @file Index.php
  5. * @date 2019-02-27 14:49:36
  6. * @author huwhis<huuwhois>
  7. * @version 0.0.6
  8. */
  9. namespace app\controller;
  10. use app\BaseController;
  11. use think\facade\View;
  12. use think\App;
  13. use app\model\Category;
  14. use think\facade\Env;
  15. class Base extends BaseController
  16. {
  17. /**
  18. * seo
  19. */
  20. protected $seo = [];
  21. /**
  22. * makeHtmlFile
  23. */
  24. protected $html = false;
  25. /**
  26. * 构造方法
  27. * @access public
  28. * @param App $app 应用对象
  29. */
  30. public function __construct(App $app)
  31. {
  32. parent::__construct($app);
  33. // 控制器初始化
  34. $this->initialize();
  35. }
  36. // 初始化
  37. protected function initialize()
  38. {
  39. // SEO标题
  40. $system = \app\model\System::find(1);
  41. $this->seo = [
  42. 'title' => $system->title,
  43. 'key' => $system->key,
  44. 'des' => $system->des,
  45. ];
  46. View::assign('seo', $this->seo);
  47. if (Env::get('app.app_env', false)=='dev') {
  48. View::assign('bdtongji', "");
  49. } else {
  50. View::assign('bdtongji', $system->tongji);
  51. }
  52. // 栏目菜单(nav)
  53. $categories = Category::getList(['is_nav'=>0]);
  54. View::assign('categories', $categories);
  55. // 一般栏目
  56. $cate_lists = Category::getList(['type'=>0]);
  57. View::assign('cate_lists', $cate_lists);
  58. }
  59. }