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

125 lines
4.4 KiB
Swift
Raw Permalink 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.

//
// SearchLocationResultVC.swift
// QuickLocation
//
// Created by on 2026/6/27.
//
import UIKit
import RxSwift
import RxCocoa
import Lottie
class SearchLocationResultVC: BaseViewController {
fileprivate var rootView: SearchLocationResultView!
override func loadView() {
rootView = SearchLocationResultView(frame: UIScreen.main.bounds)
view = rootView
}
private let phone: String
private let code: Int
private let memberData: [String : Any]
override func viewDidLoad() {
super.viewDidLoad()
rootView.unlockVipView.isHidden = AppContextManager.shared.vip > 1
AppContextManager.shared.vip > 1 ? nil : rootView.unlockVipLottieView.play()
reactiveAction()
requestPhoneArea()
}
private func reactiveAction() {
rootView.successBtn.rx.tap.subscribe(onNext: { _ in
if self.code == 0 { //
NotificationCenter.default.post(name: .ShowMemberLocationNotification,
object: nil,
userInfo: self.memberData)
AppRouter.shared.popToRoot()
}
else { // Ta
}
}).disposed(by: disposeBag)
}
private func handleCode() {
guard AppContextManager.shared.vip > 1 else { return }
var fileName = ""
var message = ""
var tips = ""
switch code {
case 0: //
fileName = "phone_search_success"
message = "定位成功"
tips = "点击去查看可获得具体位置"
rootView.inviteView.isHidden = false
rootView.successTipsLab.text = "已获得具体位置"
rootView.successBtn.setTitle("去查看", for: .normal)
rootView.phoneLab.text = phone
rootView.successLottieView.play()
case 20004: //
fileName = "phone_search_fail"
message = "此用户未注册"
tips = "根据最新的相关法规需用户双方均安装该APP才可实现定位未安装APP的用户将不再提供具体定位功能。"
rootView.inviteBtn.isHidden = false
case 20005: //
fileName = "phone_search_success"
message = "定位成功"
tips = "根据最新的相关法规,您查询的用户与您不在同一个圈子时, 不再提供具体的位置定位邀请ta加入你的圈子后可随时查看位置。"
rootView.inviteView.isHidden = false
rootView.successTipsLab.text = "邀请加入圈子后分享位置"
rootView.successBtn.setTitle("邀请他", for: .normal)
rootView.phoneLab.text = phone
rootView.successLottieView.play()
requestGroupInfo()
default:
break
}
if let path = Bundle.main.path(forResource: fileName, ofType: "json") {
self.rootView.normalLottieView.animation = LottieAnimation.filepath(path)
self.rootView.normalLottieView.play()
}
self.rootView.messageLab.text = message
self.rootView.tipsLab.text = tips
}
// MARK: -
private func requestPhoneArea() {
SystemService.phoneArea(phone: phone).subscribe(onNext: { response in
guard let data = response.data else { return }
self.handleCode()
let province = data["Province"].safeString
let city = data["City"].safeString
self.rootView.phoneAreaLab.text = "\(province)·\(city)"
self.rootView.unlockVipPhoneAreaLab.text = "\(province)·\(city)"
}).disposed(by: disposeBag)
}
// MARK: -
private func requestGroupInfo() {
GroupService.groupInfo().subscribe { response in
guard let model = response.model else { return }
}.disposed(by: disposeBag)
}
// MARK: - Init
init(phone: String, code: Int, memberData: [String : Any] = [:]) {
self.phone = phone
self.code = code
self.memberData = memberData
super.init(nibName: nil, bundle: nil)
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}