43 lines
1.2 KiB
Swift
43 lines
1.2 KiB
Swift
//
|
|
// EmergencyContactAddVC.swift
|
|
// QuickLocation
|
|
//
|
|
// Created by 八条 on 2026/6/11.
|
|
//
|
|
|
|
import UIKit
|
|
import RxSwift
|
|
import RxCocoa
|
|
|
|
class EmergencyContactAddVC: BaseViewController {
|
|
|
|
fileprivate var rootView: EmergencyContactAddView!
|
|
|
|
override func loadView() {
|
|
rootView = EmergencyContactAddView(frame: UIScreen.main.bounds)
|
|
view = rootView
|
|
}
|
|
|
|
override func viewDidLoad() {
|
|
super.viewDidLoad()
|
|
rootView.saveBtn.rx.tap.subscribe(onNext: { [weak self] _ in
|
|
self?.requestEmergencyContactAdd()
|
|
}).disposed(by: disposeBag)
|
|
}
|
|
|
|
private func requestEmergencyContactAdd() {
|
|
let name = rootView.nameTF.text?.trimmingCharacters(in: .whitespacesAndNewlines) ?? ""
|
|
let phone = rootView.phoneTF.text ?? ""
|
|
guard !name.isEmpty, phone.count == 11 else {
|
|
DLToast.show(text: "请填写姓名和11位手机号")
|
|
return
|
|
}
|
|
DLToast.showLoading()
|
|
UserService.emergencyContactAdd(requestData: ["name": name, "phone": phone]).subscribe(onNext: { _ in
|
|
DLToast.show(text: "添加成功") {
|
|
AppRouter.shared.popOrDismiss()
|
|
}
|
|
}, onError: { _ in }).disposed(by: disposeBag)
|
|
}
|
|
}
|