fix
This commit is contained in:
parent
a284e3faa0
commit
0f98a356b7
@ -250,7 +250,7 @@ struct RegisterSubmitVerifyCodeView: View {
|
|||||||
self.isProcessing = true
|
self.isProcessing = true
|
||||||
Task { @MainActor in
|
Task { @MainActor in
|
||||||
do {
|
do {
|
||||||
let result = try await self.registerModel.submitVerifyCode(sessionId: sessionId, verifyCode: Int(self.code) ?? 0)
|
_ = try await self.registerModel.submitVerifyCode(sessionId: sessionId, verifyCode: Int(self.code) ?? 0)
|
||||||
withAnimation(.spring(duration: 0.6, bounce: 0.2)) {
|
withAnimation(.spring(duration: 0.6, bounce: 0.2)) {
|
||||||
self.registerModel.stage = .setPassword(sessionId: sessionId)
|
self.registerModel.stage = .setPassword(sessionId: sessionId)
|
||||||
self.registerModel.transitionEdge = .trailing
|
self.registerModel.transitionEdge = .trailing
|
||||||
@ -273,8 +273,9 @@ struct RegisterSetPasswordView: View {
|
|||||||
@State private var isProcessing = false
|
@State private var isProcessing = false
|
||||||
|
|
||||||
// 错误提示
|
// 错误提示
|
||||||
@State private var errorMessage: String?
|
@State private var showAlert: Bool = false
|
||||||
|
@State private var errorMessage: String = ""
|
||||||
|
|
||||||
// 提示错误信息
|
// 提示错误信息
|
||||||
var passwordError: String? {
|
var passwordError: String? {
|
||||||
if password.isEmpty || confirm.isEmpty {
|
if password.isEmpty || confirm.isEmpty {
|
||||||
@ -326,15 +327,21 @@ struct RegisterSetPasswordView: View {
|
|||||||
Spacer()
|
Spacer()
|
||||||
}
|
}
|
||||||
.padding(40)
|
.padding(40)
|
||||||
|
.alert(isPresented: $showAlert) {
|
||||||
|
Alert(title: Text("提示"), message: Text(self.errorMessage))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func handleRegister() {
|
private func handleRegister() {
|
||||||
self.isProcessing = true
|
self.isProcessing = true
|
||||||
Task { @MainActor in
|
Task { @MainActor in
|
||||||
do {
|
do {
|
||||||
let result = try await self.registerModel.register(sessionId: sessionId, password: self.password)
|
_ = try await self.registerModel.register(sessionId: sessionId, password: self.password)
|
||||||
|
self.showAlert = true
|
||||||
|
self.errorMessage = "注册成功"
|
||||||
} catch {
|
} catch {
|
||||||
self.errorMessage = error.localizedDescription
|
self.showAlert = true
|
||||||
|
self.errorMessage = "注册失败,重稍后重试"
|
||||||
}
|
}
|
||||||
self.isProcessing = false
|
self.isProcessing = false
|
||||||
}
|
}
|
||||||
|
|||||||
@ -207,6 +207,10 @@ struct ResetPasswordView: View {
|
|||||||
@State private var confirm = ""
|
@State private var confirm = ""
|
||||||
@State private var isProcessing = false
|
@State private var isProcessing = false
|
||||||
|
|
||||||
|
// 错误逻辑处理
|
||||||
|
@State private var showAlert = false
|
||||||
|
@State private var errorMessage = ""
|
||||||
|
|
||||||
// 判断输入是否合法
|
// 判断输入是否合法
|
||||||
var isInputValid: Bool {
|
var isInputValid: Bool {
|
||||||
!password.isEmpty && password == confirm && password.count >= 8
|
!password.isEmpty && password == confirm && password.count >= 8
|
||||||
@ -261,6 +265,9 @@ struct ResetPasswordView: View {
|
|||||||
Spacer()
|
Spacer()
|
||||||
}
|
}
|
||||||
.padding(40)
|
.padding(40)
|
||||||
|
.alert(isPresented: $showAlert) {
|
||||||
|
Alert(title: Text("提示"), message: Text(self.errorMessage))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func handleReset() {
|
private func handleReset() {
|
||||||
@ -270,8 +277,11 @@ struct ResetPasswordView: View {
|
|||||||
let result = try await resetPasswordModel.resetPassword(sessionId: sessionId, newPassword: password)
|
let result = try await resetPasswordModel.resetPassword(sessionId: sessionId, newPassword: password)
|
||||||
print("密码重置成功: \(result)")
|
print("密码重置成功: \(result)")
|
||||||
// 此处可添加重置成功后的跳转逻辑
|
// 此处可添加重置成功后的跳转逻辑
|
||||||
|
self.showAlert = true
|
||||||
|
self.errorMessage = "重置成功,重新登陆"
|
||||||
} catch {
|
} catch {
|
||||||
print("重置失败: \(error)")
|
self.showAlert = true
|
||||||
|
self.errorMessage = "重置失败, 请稍后重试"
|
||||||
}
|
}
|
||||||
self.isProcessing = false
|
self.isProcessing = false
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user