修复合作获客扫码绑定崩溃与 Toast 层级,并接入分成比例修改。
将扫码页提升到列表层弹出并补齐 AppDelegate.window,避免扫码时 UIKit 取主窗口崩溃;Toast 改用独立 UIWindow 显示在 sheet 之上;合作获客员支持短信验证修改分成比例,同时优化冷启动根视图创建时机并补充相关测试。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@ -15,6 +15,7 @@ final class BindAcquirerViewModel: ObservableObject {
|
||||
@Published var isLoading = false
|
||||
@Published var isAlreadyBound = false
|
||||
@Published var errorMessage: String?
|
||||
@Published var commissionRateDraft = ""
|
||||
|
||||
private var saleUserId = 0
|
||||
|
||||
@ -27,6 +28,7 @@ final class BindAcquirerViewModel: ObservableObject {
|
||||
if self.saleUserId == saleUserId && (inviteInfo != nil || isAlreadyBound) { return }
|
||||
self.saleUserId = saleUserId
|
||||
isAlreadyBound = false
|
||||
commissionRateDraft = ""
|
||||
isLoading = true
|
||||
errorMessage = nil
|
||||
defer { isLoading = false }
|
||||
@ -54,10 +56,21 @@ final class BindAcquirerViewModel: ObservableObject {
|
||||
}
|
||||
}
|
||||
|
||||
/// 更新分账比例输入,只保留数字且最多 3 位。
|
||||
func updateCommissionRateDraft(_ text: String) {
|
||||
commissionRateDraft = String(text.filter(\.isNumber).prefix(3))
|
||||
}
|
||||
|
||||
/// 提交接受绑定。
|
||||
func acceptBind(api: CooperationOrderServing) async throws {
|
||||
guard saleUserId > 0, !isAlreadyBound else { return }
|
||||
try await api.saleUserAcceptBind(saleUserId: saleUserId)
|
||||
guard let commissionRate = Int(commissionRateDraft.trimmingCharacters(in: .whitespacesAndNewlines)) else {
|
||||
throw CooperationOrderCommissionRateValidationError(message: "请输入分账比例")
|
||||
}
|
||||
guard (0...100).contains(commissionRate) else {
|
||||
throw CooperationOrderCommissionRateValidationError(message: "分账比例需在0到100之间")
|
||||
}
|
||||
try await api.saleUserAcceptBind(saleUserId: saleUserId, commissionRate: commissionRate)
|
||||
}
|
||||
|
||||
/// 处理绑定错误,识别已绑定状态。
|
||||
|
||||
Reference in New Issue
Block a user