实现订单 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

@ -12,6 +12,8 @@ final class MainTabBarController: UITabBarController {
private var tabNavigationControllers: [AppTab: TabNavigationController] = [:]
private var isSyncingTabSelection = false
private let scanHandler = MainTabScanHandler(api: NetworkServices.shared.orderAPI)
///
var onScanTabSelected: (() -> Void)?
@ -47,6 +49,7 @@ final class MainTabBarController: UITabBarController {
configureTabBarAppearance()
configureTabs()
bindBadgeViewModel()
bindScanHandler()
badgeViewModel.refreshPendingWriteOffCount()
}
@ -118,10 +121,50 @@ final class MainTabBarController: UITabBarController {
tabNavigationControllers[.orders]?.tabBarItem.badgeValue = badgeValue
}
private func bindScanHandler() {
scanHandler.onShowMessage = { [weak self] message in
self?.showScanToast(message)
}
scanHandler.onShowSignIn = { [weak self] response in
guard let self else { return }
OrderSignInAlertController.present(from: self, response: response)
}
scanHandler.onShowWriteOff = { [weak self] response in
guard let self else { return }
WriteOffResultAlertController.present(from: self, response: response)
}
scanHandler.onShowMultiVerifySheet = { [weak self] spots, selected in
self?.presentMultiVerifySheet(spots: spots, selected: selected)
}
}
private func showScanToast(_ message: String) {
let alert = UIAlertController(title: nil, message: message, preferredStyle: .alert)
present(alert, animated: true)
DispatchQueue.main.asyncAfter(deadline: .now() + 1.5) {
alert.dismiss(animated: true)
}
}
private func presentMultiVerifySheet(spots: [MultiTravelScenicSpotEntity], selected: MultiTravelScenicSpotEntity?) {
let controller = MultiVerifyScenicSpotViewController(spots: spots, selected: selected)
controller.onConfirm = { [weak self] spot in
guard let self, let pending = self.scanHandler.pendingMultiVerify else { return }
Task { await self.scanHandler.confirmMultiVerify(pending: pending, spot: spot) }
}
let nav = UINavigationController(rootViewController: controller)
nav.modalPresentationStyle = .pageSheet
present(nav, animated: true)
}
private func presentGlobalScanner() {
guard presentedViewController == nil else { return }
let scanner = ScanPlaceholderViewController()
let scanner = QRCodeScannerViewController()
scanner.onScanResult = { [weak self] result in
guard let self else { return }
Task { await self.scanHandler.handleScanResult(result) }
}
let navigationController = UINavigationController(rootViewController: scanner)
navigationController.modalPresentationStyle = .fullScreen
present(navigationController, animated: true)