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

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
+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'