jsdw_ios/QuickLocation/Section/Home/SearchLocation/SearchLocationVC.swift

91 lines
3.1 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// SearchLocationVC.swift
// QuickLocation
//
// Created by 八条 on 2026/6/27.
//
import UIKit
import RxSwift
import RxCocoa
import Lottie
class SearchLocationVC: BaseViewController {
fileprivate var rootView: SearchLocationView!
override func loadView() {
rootView = SearchLocationView(frame: UIScreen.main.bounds)
view = rootView
}
private var searchBtn: UIButton {
rootView.searchBtn
}
private var code: Int = -999
private var memberData: [String : Any] = [:]
override func viewDidLoad() {
super.viewDidLoad()
fd_interactivePopDisabled = true
searchBtn.rx.tap.subscribe(onNext: { _ in
guard let phone = self.rootView.phoneInputTF.text, phone.isPhoneNumber else {
DLToast.show(text: "请输入正确的手机号码")
return
}
self.rootView.phoneInputTF.resignFirstResponder()
self.requestSearchPhone(phone: phone)
// self.rootView.searchProgressView.isHidden = false
// self.rootView.playVideo {
// self.rootView.videoView.isHidden = true
// self.rootView.searchProgressView.isHidden = true
//
// guard self.code != -999 else {
// DLToast.show(text: "发生未知错误,请重试")
// return
// }
//
// if self.code == 0 {
// AppRouter.push(Route.searchLocationResult, userInfo: ["phone": phone,
// "code": self.code,
// "memberData": self.memberData])
// }
// else {
// AppRouter.push(Route.searchLocationResult, userInfo: ["phone": phone, "code": self.code])
// }
// }
}).disposed(by: disposeBag)
}
// MARK: - 查找号码
private func requestSearchPhone(phone: String) {
DLToast.showLoading()
SystemService.search(op_type: "phone",
number: phone).subscribe(onNext: { response in
self.code = 0
/**
"group_name" : "",
"user_id" : "X16097989",
"is_online" : true,
"group_key" : "smartdrive\/X2804080\/1002",
"last_position" : "29.613138:106.509789:星光一路"
*/
if let data = response.data {
self.memberData = data
}
AppRouter.push(Route.searchLocationResult, userInfo: ["phone": phone,
"code": self.code,
"memberData": self.memberData])
}, onError: { (error) in
guard let code = error.underlyingError?.code else { return }
self.code = code
AppRouter.push(Route.searchLocationResult, userInfo: ["phone": phone, "code": self.code])
}).disposed(by: disposeBag)
}
}