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