实现订单 Tab 并接入扫码核销流程

This commit is contained in:
2026-07-06 16:59:53 +08:00
parent 9464e32a0a
commit c0ffe4c1d8
27 changed files with 4226 additions and 17 deletions

View File

@ -0,0 +1,76 @@
//
// OrderSourcePickerViewController.swift
// suixinkan
//
import SnapKit
import UIKit
///
final class OrderSourcePickerViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
var onPersonSelected: ((OrderSourcePerson) -> Void)?
var onLeadSelected: ((OrderSourceSelection) -> Void)?
private let people: [OrderSourcePerson]
private let leads: [OrderSourceLead]
private let selectedPerson: OrderSourcePerson?
private let tableView = UITableView(frame: .zero, style: .insetGrouped)
private var showingLeads = false
init(people: [OrderSourcePerson], leads: [OrderSourceLead], selectedPerson: OrderSourcePerson?) {
self.people = people
self.leads = leads
self.selectedPerson = selectedPerson
self.showingLeads = !leads.isEmpty
super.init(nibName: nil, bundle: nil)
}
@available(*, unavailable)
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func viewDidLoad() {
super.viewDidLoad()
title = showingLeads ? "选择带客单" : "选择获客员"
view.backgroundColor = UIColor(hex: 0xF5F5F5)
navigationItem.leftBarButtonItem = UIBarButtonItem(title: "关闭", style: .plain, target: self, action: #selector(closeTapped))
tableView.dataSource = self
tableView.delegate = self
view.addSubview(tableView)
tableView.snp.makeConstraints { $0.edges.equalToSuperview() }
}
@objc private func closeTapped() {
dismiss(animated: true)
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
showingLeads ? leads.count : people.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = UITableViewCell(style: .subtitle, reuseIdentifier: nil)
if showingLeads {
let lead = leads[indexPath.row]
cell.textLabel?.text = lead.displayText
cell.detailTextLabel?.text = lead.userMobile
} else {
let person = people[indexPath.row]
cell.textLabel?.text = person.name
cell.detailTextLabel?.text = person.phone
}
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if showingLeads, let person = selectedPerson {
let lead = leads[indexPath.row]
onLeadSelected?(OrderSourceSelection(person: person, lead: lead))
dismiss(animated: true)
} else {
onPersonSelected?(people[indexPath.row])
}
}
}