6faaf539
杨鑫
APP 登录门店对接
|
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
export interface UsAppLoginInput {
email: string
password: string
uuid?: string
code?: string
}
export interface UsAppLoginOutputDto {
token: string
refreshToken: string
locations: UsAppBoundLocationDto[]
}
function normalizeLocation(raw: Record<string, unknown>): UsAppBoundLocationDto {
return {
id: String(raw.id ?? raw.Id ?? ''),
locationCode: String(raw.locationCode ?? raw.LocationCode ?? ''),
locationName: String(raw.locationName ?? raw.LocationName ?? ''),
fullAddress: String(raw.fullAddress ?? raw.FullAddress ?? ''),
state: raw.state !== false && raw.State !== false,
}
}
function normalizeLoginOutput(raw: unknown): UsAppLoginOutputDto {
const o = raw as Record<string, unknown>
const locs = o.locations ?? o.Locations
const arr = Array.isArray(locs) ? locs : []
return {
token: String(o.token ?? o.Token ?? ''),
refreshToken: String(o.refreshToken ?? o.RefreshToken ?? ''),
locations: arr.map((x) => normalizeLocation(x as Record<string, unknown>)),
}
}
function normalizeLocationList(raw: unknown): UsAppBoundLocationDto[] {
const arr = Array.isArray(raw) ? raw : []
return arr.map((x) => normalizeLocation(x as Record<string, unknown>))
}
|
6faaf539
杨鑫
APP 登录门店对接
|
51
52
53
54
55
56
57
58
59
60
61
62
|
data: {
email: input.email.trim(),
password: input.password,
...(input.uuid ? { uuid: input.uuid } : {}),
...(input.code != null ? { code: input.code } : {}),
},
})
return normalizeLoginOutput(raw)
}
/** GET /api/app/us-app-auth/my-locations */
export async function usAppFetchMyLocations(): Promise<UsAppBoundLocationDto[]> {
|