125 lines
4.4 KiB
Swift
125 lines
4.4 KiB
Swift
//
|
||
// 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")
|
||
}
|
||
}
|