feat: 打包
This commit is contained in:
+17
-2
@@ -58,11 +58,11 @@ function readErrorMessage(data: unknown, fallback: string) {
|
||||
return fallback
|
||||
}
|
||||
|
||||
function request<T>(url: string, data: unknown): Promise<T> {
|
||||
function request<T>(url: string, data: unknown, method: 'POST' | 'GET' = 'POST'): Promise<T> {
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.request({
|
||||
url: `${API_BASE_URL}${url}`,
|
||||
method: 'POST',
|
||||
method,
|
||||
timeout: 10000,
|
||||
header: {
|
||||
'Content-Type': 'application/json'
|
||||
@@ -103,6 +103,21 @@ export function sendLoginCode(phone: string, scene: SendCodePayload['scene'] = '
|
||||
})
|
||||
}
|
||||
|
||||
export type InstitutionRecord = {
|
||||
id: number
|
||||
code: string
|
||||
name: string
|
||||
type: string
|
||||
level: string
|
||||
province: string
|
||||
city: string
|
||||
is_trial: boolean
|
||||
}
|
||||
|
||||
export function fetchInstitutions(): Promise<InstitutionRecord[]> {
|
||||
return request<InstitutionRecord[]>('/user/institution_list/', null, 'GET')
|
||||
}
|
||||
|
||||
export function loginWithCode(payload: LoginCodePayload): Promise<LoginResponse> {
|
||||
return request<LoginResponse>('/user/auth/login-code/', payload).then(response => {
|
||||
if (isLoginResponse(response)) return response
|
||||
|
||||
Reference in New Issue
Block a user