jsdw_ios/QuickLocation/Section/Mine/Account/AccountVC.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)
}
}