user = $this->getUser(); $this->uid = $this->user['id']; } /** * 获取用户数据 * @return array|void */ protected function getUser() { try { $this->token = input('token') ?: $this->request->header('token'); if (empty($this->token)) $this->error('接口请求认证令牌不能为空!'); return UserService::instance()->get(['token' => $this->token]); } catch (HttpResponseException $exception) { throw $exception; } catch (\Exception $exception) { $this->error($exception->getMessage()); } } }