| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <?php
- namespace www\controllers;
- use biz\saas\services\StaffService;
- use common\components\util;
- use Yii;
- use yii\web\Controller;
- /**
- * 平台次级基类,次于PublicController
- */
- class BaseController extends PublicController
- {
-
- public $staff, $staffId, $userId, $user,$merchantId;
- public $isLogin = false;
- public $withoutLogin = [];//不需要登陆的方法名
- public $validate = true;
-
- public function beforeAction($action)
- {
- //token验证
- //$staffId = jwt::getLoginId();
- $staffId = 12540901;
- $userId = 12540901;
- $staff = 12540901;
- if (empty($staffId)) {
- $this->validate = false;
- }
- //游客可以访问的方法
- if (in_array($action->id, $this->withoutLogin)) {
- $this->validate = true;
- }
- if ($this->validate == false) {
- util::notLogin();
- }
-
- $this->staff = $staff;
- $this->staffId = $staffId;
- $this->user = $staff;
- $this->userId = $userId;
- $this->merchantId = 12359;
- return parent::beforeAction($action);
- }
-
- }
|