feat: 优化账号注销流程
This commit is contained in:
@@ -91,6 +91,10 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
||||
self, selector: #selector(handleStoreDeregistrationRestriction(_:)),
|
||||
name: NotificationName.storeAccountDeregistrationRestricted, object: nil
|
||||
)
|
||||
NotificationCenter.default.addObserver(
|
||||
self, selector: #selector(handleStoreDeregistrationSubmitted(_:)),
|
||||
name: NotificationName.storeAccountDeregistrationSubmitted, object: nil
|
||||
)
|
||||
NotificationCenter.default.addObserver(
|
||||
self,
|
||||
selector: #selector(handleSessionDidExpire),
|
||||
@@ -136,18 +140,44 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
||||
}
|
||||
|
||||
private func transitionToLogin() {
|
||||
clearAuthenticatedSession()
|
||||
AppRouter.setRoot(.login, on: window)
|
||||
}
|
||||
|
||||
/// 统一清除当前会话及依赖登录态的后台能力,不执行页面跳转。
|
||||
private func clearAuthenticatedSession() {
|
||||
deregistrationCoordinator?.cancelPendingCheck()
|
||||
sessionExpiredDialog?.dismiss(animated: false)
|
||||
sessionExpiredDialog = nil
|
||||
GlobalLoadingManager.shared.hideAll()
|
||||
PushNotificationManager.shared.handleLogout()
|
||||
PushNotificationManager.shared.setAccountBindingSuspended(false)
|
||||
AppStore.shared.logout()
|
||||
AppRouter.setRoot(.login, on: window)
|
||||
}
|
||||
|
||||
@objc private func handleUserDidLogout() {
|
||||
transitionToLogin()
|
||||
}
|
||||
|
||||
/// 申请明确受理后先退出,再展示只含“完成”的结果页;结果页不再依赖已清除的凭证。
|
||||
@objc private func handleStoreDeregistrationSubmitted(_ notification: Notification) {
|
||||
let identityName = notification.userInfo?[NotificationUserInfoKey.deregistrationIdentityName] as? String
|
||||
?? "当前门店身份"
|
||||
let coolingUntil = notification.userInfo?[NotificationUserInfoKey.deregistrationCoolingUntil] as? String
|
||||
clearAuthenticatedSession()
|
||||
guard !AppStore.shared.session.isLoggedIn else {
|
||||
AppRouter.setRoot(.login, on: window)
|
||||
return
|
||||
}
|
||||
let controller = StoreAccountDeregistrationSubmittedViewController(
|
||||
identityName: identityName,
|
||||
coolingUntil: coolingUntil
|
||||
) { [weak self] in
|
||||
AppRouter.setRoot(.login, on: self?.window)
|
||||
}
|
||||
AppRouter.setRoot(UINavigationController(rootViewController: controller), on: window)
|
||||
}
|
||||
|
||||
@objc private func handleUserDidLogin() {
|
||||
sessionExpiredDialog?.dismiss(animated: false)
|
||||
sessionExpiredDialog = nil
|
||||
|
||||
Reference in New Issue
Block a user