PlatformController.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace pt\controllers;
  3. use bizHd\auth\services\PlatMenuService;
  4. use Yii;
  5. use common\services\xhWxOpenAdminService;
  6. /**
  7. * 平台次级基类,次于PublicController
  8. */
  9. class PlatformController extends PublicController
  10. {
  11. public $isLogin = false;
  12. public $guestAccess = [];//不需要登陆的方法名
  13. public $admin, $adminId, $menuList, $subMenuList;
  14. public function beforeAction($action)
  15. {
  16. //取一级菜单 二级菜单 ssh 2019.8.17
  17. $controllerName = $action->controller->id;
  18. $actionName = $action->id;
  19. $this->menuList = PlatMenuService::getMenu($controllerName);
  20. $this->subMenuList = PlatMenuService::getSubMenu($controllerName, $actionName);
  21. $this->isLogin = xhWxOpenAdminService::isLogin();
  22. if (!in_array($action->id, $this->guestAccess) && $this->isLogin == false) {
  23. $this->redirect(['main/login']);
  24. Yii::$app->end();
  25. }
  26. if ($this->isLogin) {
  27. $adminId = xhWxOpenAdminService::getId();
  28. $this->adminId = $adminId;
  29. }
  30. return parent::beforeAction($action);
  31. }
  32. }