修改登录,绑定学生相关界面
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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'
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 忘记密码
|
||||
*/
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user