params['ptStyle'] = 3; $userId = jwt::getLoginId(); $sjId = 0; if (in_array($action->id, $this->guestAccess) == false){ $header = httpUtil::getHeader(); $shopId = isset($header['account']) ? $header['account'] : 0; if (empty($shopId)) { util::fail('没有找到门店'); } $shop = ShopClass::getById($shopId); if (empty($shop)) { util::fail('没有找到门店哦'); } $sjId = $shop['merchantId'] ?? 0; if (empty($sjId)) { util::fail('没有找到商家哦'); } $sj = MerchantService::getMerchantById($sjId); if (empty($sj)) { util::fail('没有找到商家'); } $this->sjId = $sjId; $this->sj = $sj; $this->shopId = $shopId; $this->shop = $shop; $this->sjExtend = MerchantExtendService::getByMerchantId($sjId); } $this->isWx = util::isWx(); if (empty($userId)) { $this->validate = false; } else { $this->validate = true; $this->userId = $userId; $userInfo = UserService::getUserInfo($userId); if (empty($userInfo)) { util::fail('没有用户信息'); } $this->user = $userInfo; if (in_array($action->id, $this->guestAccess) == false) { $custom = CustomClass::replaceCustom($sjId, $userInfo); $this->custom = $custom; $customId = $custom['id'] ?? 0; $this->customId = $customId; } } //游客可以访问的方法 if (in_array($action->id, $this->guestAccess)) { $this->validate = true; } if ($this->validate == false) { util::notLogin(); } return parent::beforeAction($action); } }