修改登录,绑定学生相关界面

This commit is contained in:
tanxin
2026-11-03 15:00:52 +08:00
parent d509e80321
commit d1d44e250e
13 changed files with 170 additions and 51 deletions
+2 -2
View File
@@ -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
}
}
-11
View File
@@ -53,8 +53,6 @@
<text class="btn-text">登录</text>
</view>
<!-- 切换验证码登录 -->
<text class="switch-text" @tap="handleSwitchToCodeLogin">验证码登录</text>
</view>
<!-- 底部注册入口 -->
@@ -131,15 +129,6 @@
}
}
/**
* 切换到验证码登录
*/
function handleSwitchToCodeLogin() {
uni.navigateTo({
url: '/pages/login/verify-code'
})
}
/**
* 忘记密码
*/
+1 -1
View File
@@ -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()
}
+1 -1
View File
@@ -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
+2 -2
View File
@@ -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
}
-3
View File
@@ -50,9 +50,6 @@
<view class="btn-primary" @tap="handleGoHome">
<text class="btn-primary-text">去登录</text>
</view>
<view class="btn-secondary" @tap="handleGoLogin">
<text class="btn-secondary-text">返回首页</text>
</view>
</view>
</scroll-view>
</view>
+1 -1
View File
@@ -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) {
+11 -19
View File
@@ -112,9 +112,7 @@
<script setup lang="ts">
import { apiRegister } from '../../api/auth'
import { apiCheckPhone } from '../../api/student'
import { registrationStudents } from '../../store/registration'
import { setUserInfo } from '../../store/user'
type ParentAccountForm = {
parentName: string
@@ -177,17 +175,8 @@
}
return
}
// 检查手机号是否已注册
uni.showLoading({ title: '检查中...' })
const checkRes = await apiCheckPhone(form.phone)
uni.hideLoading()
if (checkRes && checkRes.data && checkRes.data.exists) {
uni.showToast({
title: '该手机号已注册,请直接登录',
icon: 'none'
})
if (students.value.length === 0 || students.value.some((student) => !Number.isSafeInteger(Number(student.id)) || Number(student.id) <= 0)) {
uni.showToast({ title: '学生信息无效,请重新验证', icon: 'none' })
return
}
@@ -195,20 +184,23 @@
uni.showLoading({ title: '注册中...' })
const studentIds = students.value.map(s => s.id)
const res = await apiRegister({
let res
try {
res = await apiRegister({
parentName: form.parentName,
phone: form.phone,
relationship: form.relationship,
password: form.password,
students: studentIds
})
} catch (error) {
console.error('注册请求失败', error)
uni.hideLoading()
return
}
uni.hideLoading()
if (res && res.code === 0 && res.data) {
// 保存用户信息
setUserInfo(res.data)
if (res && res.code === 200 && res.data) {
// 跳转到注册完成页
uni.redirectTo({
url: '/pages/register/complete'
+1 -1
View File
@@ -160,7 +160,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) {