| 123456789101112131415161718192021222324252627282930313233343536373839 |
- <?php
- namespace pt\controllers;
- use bizHd\auth\services\PlatMenuService;
- use Yii;
- use common\services\xhWxOpenAdminService;
- /**
- * 平台次级基类,次于PublicController
- */
- class PlatformController extends PublicController
- {
-
- public $isLogin = false;
- public $guestAccess = [];//不需要登陆的方法名
- public $admin, $adminId, $menuList, $subMenuList;
-
- public function beforeAction($action)
- {
-
- //取一级菜单 二级菜单 ssh 2019.8.17
- $controllerName = $action->controller->id;
- $actionName = $action->id;
- $this->menuList = PlatMenuService::getMenu($controllerName);
- $this->subMenuList = PlatMenuService::getSubMenu($controllerName, $actionName);
-
- $this->isLogin = xhWxOpenAdminService::isLogin();
- if (!in_array($action->id, $this->guestAccess) && $this->isLogin == false) {
- $this->redirect(['main/login']);
- Yii::$app->end();
- }
- if ($this->isLogin) {
- $adminId = xhWxOpenAdminService::getId();
- $this->adminId = $adminId;
- }
- return parent::beforeAction($action);
- }
-
- }
|