Implement orders tab aligned with Android, including scan verify flows.
Add role-based order/deposit lists, AVFoundation QR scanning, verify dialogs, and ViewModel tests so photographers, scenic admins, and store admins match Android behavior. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
76
suixinkan/UI/Orders/OrderSourcePickerViewController.swift
Normal file
76
suixinkan/UI/Orders/OrderSourcePickerViewController.swift
Normal 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])
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user