BaseController.php 975 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace www\controllers;
  3. use biz\saas\services\StaffService;
  4. use common\components\util;
  5. use Yii;
  6. use yii\web\Controller;
  7. /**
  8. * 平台次级基类,次于PublicController
  9. */
  10. class BaseController extends PublicController
  11. {
  12. public $staff, $staffId, $userId, $user,$merchantId;
  13. public $isLogin = false;
  14. public $withoutLogin = [];//不需要登陆的方法名
  15. public $validate = true;
  16. public function beforeAction($action)
  17. {
  18. //token验证
  19. //$staffId = jwt::getLoginId();
  20. $staffId = 12540901;
  21. $userId = 12540901;
  22. $staff = 12540901;
  23. if (empty($staffId)) {
  24. $this->validate = false;
  25. }
  26. //游客可以访问的方法
  27. if (in_array($action->id, $this->withoutLogin)) {
  28. $this->validate = true;
  29. }
  30. if ($this->validate == false) {
  31. util::notLogin();
  32. }
  33. $this->staff = $staff;
  34. $this->staffId = $staffId;
  35. $this->user = $staff;
  36. $this->userId = $userId;
  37. $this->merchantId = 12359;
  38. return parent::beforeAction($action);
  39. }
  40. }