75 lines
2.1 KiB
Swift
75 lines
2.1 KiB
Swift
//
|
|
// AccountVC.swift
|
|
// QuickLocation
|
|
//
|
|
// Created by 八条 on 2026/6/10.
|
|
//
|
|
|
|
import UIKit
|
|
import RxSwift
|
|
import RxCocoa
|
|
import RxDataSources
|
|
|
|
class AccountVC: BaseViewController {
|
|
|
|
fileprivate var rootView: AccountView!
|
|
|
|
override func loadView() {
|
|
rootView = AccountView(frame: UIScreen.main.bounds)
|
|
view = rootView
|
|
}
|
|
|
|
override func viewDidLoad() {
|
|
super.viewDidLoad()
|
|
|
|
// Do any additional setup after loading the view.
|
|
|
|
reactiveAction()
|
|
|
|
DispatchQueue.global(qos: .background).async {
|
|
let totalByte = AppCacheManager.totalCacheSize()
|
|
let cacheText = AppCacheManager.formatByte(totalByte)
|
|
DispatchQueue.main.async {
|
|
// 赋值给 Label 展示
|
|
self.rootView.cacheLab.text = "\(cacheText)"
|
|
}
|
|
}
|
|
}
|
|
|
|
private func reactiveAction() {
|
|
rootView.logoutBtn.rx.tap.subscribe(onNext: { _ in
|
|
self.showConfirmPop(title: "温馨提醒",
|
|
message: "确定要退出账号吗?",
|
|
confirmText: "否",
|
|
confirmBlock: { },
|
|
cancelText: "是") {
|
|
self.requestLogout()
|
|
}
|
|
}).disposed(by: disposeBag)
|
|
|
|
rootView.cancelledBtn.rx.tap.subscribe(onNext: { _ in
|
|
CancellationPopView.show {
|
|
self.deleteAccount()
|
|
}
|
|
}).disposed(by: disposeBag)
|
|
}
|
|
|
|
// MARK: - API
|
|
private func requestLogout() {
|
|
DLToast.showLoading()
|
|
UserService.logout().subscribe(onNext: { response in
|
|
DLToast.dismiss()
|
|
AppContextManager.shared.deleteAccount()
|
|
GroupIMService.shared.logout()
|
|
AppDelegate.shared.showMainViewController()
|
|
}, onError: { _ in }).disposed(by: disposeBag)
|
|
}
|
|
|
|
private func deleteAccount() {
|
|
DLToast.showLoading()
|
|
UserService.deleteAccount().subscribe(onNext: { response in
|
|
DLToast.show(text: "申请成功")
|
|
}, onError: { _ in }).disposed(by: disposeBag)
|
|
}
|
|
}
|