diff --git a/api/auth.ts b/api/auth.ts index 1d8e953..c4f0dc4 100644 --- a/api/auth.ts +++ b/api/auth.ts @@ -85,7 +85,10 @@ export type RefreshTokenResponse = { * 密码登录 */ export function apiLogin(params: LoginParams): Promise | null> { - return post('/api/auth/login', params) + return post('/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 | null> { - return post('/api/auth/register', params) + const relations = ['爸爸', '妈妈', '爷爷', '奶奶', '外公', '外婆', '其他亲属'] + return post('/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 | null> { - return post('/api/auth/logout') + return post('/api/v1/Parents/Logout') } diff --git a/api/student.ts b/api/student.ts index cb79ab7..f2ad53d 100644 --- a/api/student.ts +++ b/api/student.ts @@ -268,14 +268,17 @@ export type VerifyAccountParams = { * 验证学生二维码 */ export function apiVerifyStudentQRCode(params: VerifyQRCodeParams): Promise | null> { - return post('/api/student/verify-qrcode', params) + return apiVerifyStudentAccount({ account: params.account, name: params.name }) } /** * 验证学生账号 */ export function apiVerifyStudentAccount(params: VerifyAccountParams): Promise | null> { - return post('/api/student/verify-account', params) + return get('/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 || '' } } + }) } /** diff --git a/pages/login/forgot-password.uvue b/pages/login/forgot-password.uvue index 1396553..b798dec 100644 --- a/pages/login/forgot-password.uvue +++ b/pages/login/forgot-password.uvue @@ -142,7 +142,7 @@ return } const res = await apiSendCode({ phone: p, type: 'forgot-password' }) - if (res && res.code === 0) { + if (res && res.code === 200) { uni.showToast({ title: '验证码已发送', icon: 'success' }) countdownBtnRef.value?.startCountdown() } @@ -171,7 +171,7 @@ resetToken: resetToken.value }) - if (res && res.code === 0) { + if (res && res.code === 200) { step.value = 3 } } diff --git a/pages/login/index.uvue b/pages/login/index.uvue index dc4e8f8..250fcc9 100644 --- a/pages/login/index.uvue +++ b/pages/login/index.uvue @@ -53,8 +53,6 @@ 登录 - - 验证码登录 @@ -131,15 +129,6 @@ } } - /** - * 切换到验证码登录 - */ - function handleSwitchToCodeLogin() { - uni.navigateTo({ - url: '/pages/login/verify-code' - }) - } - /** * 忘记密码 */ diff --git a/pages/login/verify-code.uvue b/pages/login/verify-code.uvue index 43fc28e..762e8d5 100644 --- a/pages/login/verify-code.uvue +++ b/pages/login/verify-code.uvue @@ -84,7 +84,7 @@ } const res = await apiSendCode({ phone: p, type: 'login' }) - if (res && res.code === 0) { + if (res && res.code === 200) { uni.showToast({ title: '验证码已发送', icon: 'success' }) countdownBtnRef.value?.startCountdown() } diff --git a/pages/profile/index.uvue b/pages/profile/index.uvue index 24e0a6a..7b34d4c 100644 --- a/pages/profile/index.uvue +++ b/pages/profile/index.uvue @@ -80,7 +80,7 @@ listFailed.value = false try { const res = await apiGetBoundStudents() - if (res && res.code === 0 && res.data) { + if (res && res.code === 200 && res.data) { students.value = res.data.students if (!selectedStudentId.value) selectedStudentId.value = res.data.currentStudentId ?? '' } else listFailed.value = true diff --git a/pages/profile/verify-student.uvue b/pages/profile/verify-student.uvue index c09474c..258ed05 100644 --- a/pages/profile/verify-student.uvue +++ b/pages/profile/verify-student.uvue @@ -62,7 +62,7 @@ loadFailed.value = false try { const res = await apiGetBoundStudents() - if (res && res.code === 0 && res.data) students.value = res.data.students + if (res && res.code === 200 && res.data) students.value = res.data.students else loadFailed.value = true } catch (_error) { loadFailed.value = true } finally { loading.value = false } @@ -93,7 +93,7 @@ verifying.value = true try { const res = qrCode ? await apiVerifyStudentQRCode({ qrCode, account: studentAccount, name: studentName }) : await apiVerifyStudentAccount({ account: studentAccount, name: studentName }) - if (res && res.code === 0 && res.data) { + if (res && res.code === 200 && res.data) { if (students.value.some(item => item.id === res.data!.id || item.account === res.data!.account)) uni.showToast({ title: '该学生已绑定', icon: 'none' }) else verified.value = res.data } diff --git a/pages/register/complete.uvue b/pages/register/complete.uvue index 3da125a..bf501d0 100644 --- a/pages/register/complete.uvue +++ b/pages/register/complete.uvue @@ -50,9 +50,6 @@ 去登录 - - 返回首页 - diff --git a/pages/register/input-student.uvue b/pages/register/input-student.uvue index 5167459..374004b 100644 --- a/pages/register/input-student.uvue +++ b/pages/register/input-student.uvue @@ -178,7 +178,7 @@ uni.hideLoading() - if (res && res.code === 0 && res.data) { + if (res && res.code === 200 && res.data) { // 检查是否重复绑定 const exists = studentList.value.find(s => s.account === res.data!.account) if (exists) { diff --git a/pages/register/parent-account.uvue b/pages/register/parent-account.uvue index 4140214..ae32968 100644 --- a/pages/register/parent-account.uvue +++ b/pages/register/parent-account.uvue @@ -112,9 +112,7 @@