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) { } }