authService = new AuthService(); } public function login() { try { return Response::success($this->authService->loginWithCode($this->request->post()), '登录成功'); } catch (\Throwable $e) { return Response::error($e->getMessage(), $e->getCode() ?: 500); } } public function devLogin() { try { return Response::success( $this->authService->devLogin((int) ($this->request->post('mini_program_id', 2))), '登录成功' ); } catch (\Throwable $e) { return Response::error($e->getMessage(), $e->getCode() ?: 500); } } public function me() { try { return Response::success($this->authService->getUserInfo($this->getCurrentSmtUserId())); } catch (\Throwable $e) { return Response::error($e->getMessage(), $e->getCode() ?: 500); } } public function profile() { try { return Response::success($this->authService->updateProfile($this->getCurrentSmtUserId(), $this->request->post()), '更新成功'); } catch (\Throwable $e) { return Response::error($e->getMessage(), $e->getCode() ?: 500); } } public function miniProgramTestCode() { try { $image = $this->authService->getMiniProgramTestCode( $this->getCurrentSmtUserId(), (string) $this->request->get('path', ''), (int) $this->request->get('width', 280) ); return response($image) ->code(200) ->contentType('image/png') ->header(['Cache-Control' => 'no-store']); } catch (\Throwable $e) { return Response::error('获取小程序码失败', $e->getCode() ?: 500); } } }