From d1d1dec42e0548d2e4eca7fb74ca21f6475448b3 Mon Sep 17 00:00:00 2001 From: king <2229249788@qq.com> Date: Tue, 18 Jul 2023 11:18:10 +0800 Subject: [PATCH] =?UTF-8?q?=E7=99=BB=E5=BD=95=E5=88=B7=E6=96=B0code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/user.ts | 10 ++++++---- src/pages/login/login.tsx | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/api/user.ts b/src/api/user.ts index 1a032c7..9ce1bd5 100644 --- a/src/api/user.ts +++ b/src/api/user.ts @@ -1,10 +1,12 @@ import {request} from "./request"; +interface Code { + image: string +} + interface Login { access_token: string - code?: { - image: string - } + code?: Code company: Company token: string user: User @@ -48,6 +50,6 @@ export const userApi = { return request(`/api/v1/user/detail`, "GET") }, code(catch_key: string) { - return request(`/api/v1/auth/login/code`, "GET", {open_id:catch_key}) + return request<{ code: Code }>(`/api/v1/auth/login/code`, "POST", {openid: catch_key}) } } diff --git a/src/pages/login/login.tsx b/src/pages/login/login.tsx index 9c16476..63507ee 100644 --- a/src/pages/login/login.tsx +++ b/src/pages/login/login.tsx @@ -26,8 +26,8 @@ const Bing: FC = ({code, catch_key}: BingProps) => { async function refreshCode() { try { - await userApi.code(catch_key) - + const {code} = await userApi.code(catch_key) + setUseCode(code.image) } catch (e) { } }