修改登录,绑定学生相关界面
This commit is contained in:
+12
-3
@@ -85,7 +85,10 @@ export type RefreshTokenResponse = {
|
||||
* 密码登录
|
||||
*/
|
||||
export function apiLogin(params: LoginParams): Promise<ApiResponse<UserInfo> | null> {
|
||||
return post<UserInfo>('/api/auth/login', params)
|
||||
return post<any>('/api/v1/Parents/Login', { phone: params.phone, password: params.password, loginType: 0 }).then((res) => {
|
||||
if (!res || !res.data) return null
|
||||
return { code: res.code, message: res.message, data: { userId: String(res.data.parentId), phone: res.data.phone, nickname: res.data.name, avatar: '', token: res.data.token, refreshToken: '' } }
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -106,7 +109,13 @@ export function apiSendCode(params: SendCodeParams): Promise<ApiResponse<SendCod
|
||||
* 注册
|
||||
*/
|
||||
export function apiRegister(params: RegisterParams): Promise<ApiResponse<UserInfo> | null> {
|
||||
return post<UserInfo>('/api/auth/register', params)
|
||||
const relations = ['爸爸', '妈妈', '爷爷', '奶奶', '外公', '外婆', '其他亲属']
|
||||
return post<any>('/api/v1/Parents/Bind', {
|
||||
name: params.parentName,
|
||||
phone: params.phone,
|
||||
password: params.password,
|
||||
students: params.students.map((id) => ({ userId: Number(id), relation: relations.indexOf(params.relationship) + 1 }))
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -134,5 +143,5 @@ export function apiRefreshToken(params: RefreshTokenParams): Promise<ApiResponse
|
||||
* 退出登录
|
||||
*/
|
||||
export function apiLogout(): Promise<ApiResponse<null> | null> {
|
||||
return post<null>('/api/auth/logout')
|
||||
return post<null>('/api/v1/Parents/Logout')
|
||||
}
|
||||
|
||||
+5
-2
@@ -268,14 +268,17 @@ export type VerifyAccountParams = {
|
||||
* 验证学生二维码
|
||||
*/
|
||||
export function apiVerifyStudentQRCode(params: VerifyQRCodeParams): Promise<ApiResponse<StudentInfo> | null> {
|
||||
return post<StudentInfo>('/api/student/verify-qrcode', params)
|
||||
return apiVerifyStudentAccount({ account: params.account, name: params.name })
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证学生账号
|
||||
*/
|
||||
export function apiVerifyStudentAccount(params: VerifyAccountParams): Promise<ApiResponse<StudentInfo> | null> {
|
||||
return post<StudentInfo>('/api/student/verify-account', params)
|
||||
return get<any>('/api/v1/Parents/VerifyStudent', { RealName: params.name, Account: params.account }).then((res) => {
|
||||
if (!res || !res.data) return null
|
||||
return { code: res.code, message: res.message, data: { id: String(res.data.userId), name: res.data.name, account: res.data.account, avatar: res.data.avatar || '', grade: res.data.gradeLevel || '', class: res.data.className || '' } }
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user