// // SearchLocationResultView.swift // QuickLocation // import UIKit import RxSwift import RxCocoa import Lottie class SearchLocationResultView: UIView { var disposeBag = DisposeBag() let headerView = SearchLocationHeaderView() private func setupUI() { addSubview(unlockVipView) addSubview(navBgView) addSubview(navView) addSubview(scrollView) navBgView.layoutChain .edges(excludingEdge: .bottom) .heightToWidth(160 / 375) navView.layoutChain .edges(excludingEdge: .bottom) .height(kNaviHeight) unlockVipView.layoutChain.edges() scrollView.layoutChain .topToBottomOfView(navView) .edges(excludingEdge: .top) } func startMarqueeAnimation() { headerView.startMarqueeAnimation() } func configureResult(status: String, disclaimer: String, showInviteRow: Bool) { statusPillLab.text = status disclaimerLab.text = disclaimer disclaimerLab.textAlignment = disclaimer.contains("去查看") ? .center : .left disclaimerIcon.isHidden = disclaimer.contains("去查看") inviteView.isHidden = !showInviteRow // 隐藏时高度归零,避免仍占 72pt 把卡片撑高 inviteView.layoutChain .topToBottomOfView(disclaimerLab, offset: showInviteRow ? 16 : 0) .height(showInviteRow ? 72 : 0) } lazy var navBgView: UIImageView = { let iv = UIImageView() iv.image = UIImage(named: "Common/navBar_bg_2") iv.contentMode = .scaleAspectFill return iv }() lazy var navView: BaseNavigationView = { BaseNavigationView(title: " ") }() lazy var scrollView: UIScrollView = { let view = UIScrollView() view.backgroundColor = .clear view.showsVerticalScrollIndicator = false view.bounces = false let contentView = UIView() contentView.backgroundColor = .clear view.addSubview(contentView) contentView.layoutChain.edges().widthToView(view) contentView.addSubview(headerView) headerView.layoutChain.top(12).edgesHorzontal() contentView.addSubview(resultCard) resultCard.layoutChain .topToBottomOfView(headerView, offset: 20) .edgesHorzontal(15) contentView.addSubview(actionBtn) actionBtn.layoutChain .topToBottomOfView(resultCard, offset: 24) .edgesHorzontal(30) .height(56) .bottom(kSafeBottomMargin + 30) return view }() lazy var resultCard: UIView = { let card = UIView() card.backgroundColor = UIColor(hexStr: "#EFF9FF") card.cornerRadius = 16 let locationRow = UIView() card.addSubview(locationRow) let pinIcon = UIImageView(image: UIImage(named: "Home/member_location")) pinIcon.contentMode = .scaleAspectFit locationRow.addSubview(pinIcon) locationRow.addSubview(phoneAreaLab) pinIcon.layoutChain.left().top().bottom().width(18).height(18) phoneAreaLab.layoutChain .leftToRightOfView(pinIcon, offset: 6) .right() .centerY(pinIcon) locationRow.layoutChain.top(20).centerX() let pillContainer = UIView() pillContainer.backgroundColor = .white pillContainer.cornerRadius = 14 card.addSubview(pillContainer) pillContainer.addSubview(statusPillLab) statusPillLab.layoutChain.edgesHorzontal(58).edgesVertical(13) pillContainer.layoutChain .topToBottomOfView(locationRow, offset: 11) .centerX() .height(48) card.addSubview(disclaimerIcon) disclaimerIcon.layoutChain .topToBottomOfView(pillContainer, offset: 14) .left(24) .width(12) .height(12) card.addSubview(disclaimerLab) disclaimerLab.layoutChain .topToBottomOfView(pillContainer, offset: 11) .leftToRightOfView(disclaimerIcon, offset: 3) .right(23) card.addSubview(inviteView) inviteView.layoutChain .topToBottomOfView(disclaimerLab, offset: 0) .edgesHorzontal(12) .height(0) .bottom(16) return card }() lazy var phoneAreaLab: UILabel = { let label = UILabel() label.font = .systemFont(ofSize: 18, weight: .bold) label.textColor = UIColor(hexStr: "#293445") return label }() lazy var statusPillLab: UILabel = { let label = UILabel() label.font = .systemFont(ofSize: 16, weight: .medium) label.textColor = UIColor(hexStr: "#16B3FF") label.textAlignment = .center return label }() private lazy var disclaimerIcon: UIImageView = { let iv = UIImageView(image: UIImage(named: "SearchLocation/warning")) iv.contentMode = .scaleAspectFit return iv }() lazy var disclaimerLab: UILabel = { let label = UILabel() label.font = .systemFont(ofSize: 12, weight: .regular) label.textColor = UIColor(hexStr: "#999999") label.numberOfLines = 0 return label }() lazy var actionBtn: UIButton = { let btn = UIButton(type: .custom) btn.setTitleColor(.white, for: .normal) btn.titleLabel?.font = FontManager.boboBold(18) btn.setBackgroundImage(UIImage(named: "Common/button_bg_2"), for: .normal) btn.cornerRadius = 20 btn.isHidden = true return btn }() var inviteBtn: UIButton { actionBtn } lazy var inviteView: UIView = { let view = UIView() view.backgroundColor = .white view.cornerRadius = 12 view.isHidden = true view.addSubview(successBtn) successBtn.layoutChain.right(12).centerY().width(90).height(36) view.addSubview(successTipsLab) successTipsLab.layoutChain.topToCenterYOfView(view).left(12) view.addSubview(phoneLab) phoneLab.layoutChain.bottomToCenterYOfView(view).left(12) return view }() lazy var phoneLab: UILabel = { let label = UILabel() label.font = .systemFont(ofSize: 16, weight: .bold) label.textColor = UIColor(hexStr: "#333333") return label }() lazy var successTipsLab: UILabel = { let label = UILabel() label.font = .systemFont(ofSize: 10, weight: .medium) label.textColor = UIColor(hexStr: "#999999") return label }() lazy var successBtn: UIButton = { let btn = UIButton(type: .custom) btn.setTitleColor(.white, for: .normal) btn.titleLabel?.font = .systemFont(ofSize: 14, weight: .medium) btn.backgroundColor = UIColor(hexStr: "#16B3FF") btn.cornerRadius = 18 return btn }() // 兼容 VC 旧引用 lazy var messageLab: UILabel = statusPillLab lazy var tipsLab: UILabel = disclaimerLab lazy var normalLottieView: LottieAnimationView = { let view = LottieAnimationView() view.isHidden = true return view }() lazy var successLottieView: LottieAnimationView = { let view = LottieAnimationView(name: "phone_search_fireworks") view.isHidden = true return view }() lazy var unlockVipView: UIView = { let view = UIView() view.backgroundColor = .white view.isHidden = true let heroPlaceholder = UIImageView() heroPlaceholder.backgroundColor = UIColor(hexStr: "#F5F5F5") heroPlaceholder.cornerRadius = 16 view.addSubview(heroPlaceholder) heroPlaceholder.layoutChain .top(120) .edgesHorzontal(40) .height(200) view.addSubview(unlockVipPhoneAreaLab) unlockVipPhoneAreaLab.layoutChain .topToBottomOfView(heroPlaceholder, offset: 16) .centerX() let unlockVipBtn = UIButton() unlockVipBtn.setTitle("开通会员", for: .normal) unlockVipBtn.setTitleColor(.white, for: .normal) unlockVipBtn.titleLabel?.font = FontManager.boboBold(16) unlockVipBtn.backgroundColor = UIColor(hexStr: "#16B3FF") unlockVipBtn.cornerRadius = 25 unlockVipBtn.rx.tap.subscribe(onNext: { _ in AppRouter.push(Route.vipRecharge) }).disposed(by: disposeBag) view.addSubview(unlockVipBtn) unlockVipBtn.layoutChain .edgesHorzontal(15) .bottom(kSafeBottomMargin + 20) .height(50) let unlockVipTitleLab = UILabel() unlockVipTitleLab.text = "再迈一步,你就能看到:" unlockVipTitleLab.font = .systemFont(ofSize: 14, weight: .medium) unlockVipTitleLab.textColor = UIColor(hexStr: "#16B3FF") view.addSubview(unlockVipTitleLab) unlockVipTitleLab.layoutChain .bottomToTopOfView(unlockVipBtn, offset: -60) .centerX() return view }() lazy var unlockVipLottieView: LottieAnimationView = { let view = LottieAnimationView(name: "phone_search_no_vip") view.isHidden = true return view }() lazy var unlockVipPhoneAreaLab: UILabel = { let label = UILabel() label.font = .systemFont(ofSize: 20, weight: .semibold) label.textColor = UIColor(hexStr: "#16B3FF") return label }() override init(frame: CGRect) { super.init(frame: .zero) backgroundColor = .white setupUI() } required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } }