66 lines
1.8 KiB
Swift
66 lines
1.8 KiB
Swift
//
|
|
// EmergencyContactVC.swift
|
|
// QuickLocation
|
|
//
|
|
// Created by 八条 on 2026/6/11.
|
|
//
|
|
|
|
import UIKit
|
|
import RxSwift
|
|
import RxCocoa
|
|
import RxDataSources
|
|
|
|
class EmergencyContactVC: BaseViewController {
|
|
|
|
fileprivate var rootView: EmergencyContactView!
|
|
|
|
override func loadView() {
|
|
rootView = EmergencyContactView(frame: UIScreen.main.bounds)
|
|
view = rootView
|
|
}
|
|
|
|
private var viewModel = EmergencyContactViewModel()
|
|
|
|
override func viewDidLoad() {
|
|
super.viewDidLoad()
|
|
|
|
// Do any additional setup after loading the view.
|
|
bindViewModel()
|
|
}
|
|
|
|
override func viewWillAppear(_ animated: Bool) {
|
|
super.viewWillAppear(animated)
|
|
|
|
}
|
|
|
|
override func viewDidAppear(_ animated: Bool) {
|
|
super.viewDidAppear(animated)
|
|
requestEmergencyContactList()
|
|
}
|
|
|
|
private func bindViewModel() {
|
|
viewModel.output.sectionedItems
|
|
.bind(to: rootView.tableView.rx.items(dataSource: dataSource))
|
|
.disposed(by: disposeBag)
|
|
}
|
|
|
|
// MARK: - UITableViewDataSource
|
|
lazy private var dataSource: RxTableViewSectionedReloadDataSource<EmergencyContactListSectionModel> = {
|
|
return RxTableViewSectionedReloadDataSource<EmergencyContactListSectionModel>(
|
|
configureCell: { (_, tableView, indexPath, model) in
|
|
let cell: EmergencyContactCell = tableView.dequeueReusableCell(for: indexPath)
|
|
cell.configure(model)
|
|
return cell
|
|
})
|
|
}()
|
|
|
|
// MARK: - API 紧急联系人列表
|
|
private func requestEmergencyContactList() {
|
|
DLToast.showLoading()
|
|
UserService.emergencyContactList().subscribe(onNext: { response in
|
|
self.viewModel.loadData(response.list)
|
|
}, onError: { _ in }).disposed(by: disposeBag)
|
|
}
|
|
|
|
}
|