feat(drone-dock): 接入游客确认交付并对齐网页样式
This commit is contained in:
@@ -8,6 +8,7 @@ final class DroneDockHomeViewController: BaseViewController {
|
||||
private let paymentControllerFactory: (() -> UIViewController)?
|
||||
private let preparationControllerFactory: ((DroneDockHomeOrder, DroneDockHomeContext) -> UIViewController)?
|
||||
private let materialsControllerFactory: ((DroneDockHomeOrder, DroneDockHomeContext) -> UIViewController)?
|
||||
private let confirmationControllerFactory: (DroneDockHomeOrder, DroneDockHomeContext) -> UIViewController
|
||||
private var refreshTask: Task<Void, Never>?
|
||||
private var loadMoreTask: Task<Void, Never>?
|
||||
private var isRefreshing = false
|
||||
@@ -34,11 +35,13 @@ final class DroneDockHomeViewController: BaseViewController {
|
||||
/// 注入可测试的数据源,不加载演示数据。
|
||||
init(viewModel: DroneDockHomeViewModel, paymentControllerFactory: (() -> UIViewController)? = nil,
|
||||
preparationControllerFactory: ((DroneDockHomeOrder, DroneDockHomeContext) -> UIViewController)? = nil,
|
||||
materialsControllerFactory: ((DroneDockHomeOrder, DroneDockHomeContext) -> UIViewController)? = nil) {
|
||||
materialsControllerFactory: ((DroneDockHomeOrder, DroneDockHomeContext) -> UIViewController)? = nil,
|
||||
confirmationControllerFactory: ((DroneDockHomeOrder, DroneDockHomeContext) -> UIViewController)? = nil) {
|
||||
self.viewModel = viewModel
|
||||
self.paymentControllerFactory = paymentControllerFactory
|
||||
self.preparationControllerFactory = preparationControllerFactory
|
||||
self.materialsControllerFactory = materialsControllerFactory
|
||||
self.confirmationControllerFactory = confirmationControllerFactory ?? DroneDockConfirmationEntry.makeController
|
||||
super.init(nibName: nil, bundle: nil)
|
||||
hidesBottomBarWhenPushed = true
|
||||
}
|
||||
@@ -296,7 +299,7 @@ final class DroneDockHomeViewController: BaseViewController {
|
||||
private func openAllOrders() {
|
||||
let controller = DroneDockOrdersViewController(
|
||||
viewModel: viewModel.makeOrdersViewModel(), preparationControllerFactory: preparationFactory,
|
||||
materialsControllerFactory: materialsFactory)
|
||||
materialsControllerFactory: materialsFactory, confirmationControllerFactory: confirmationControllerFactory)
|
||||
navigationController?.pushViewController(controller, animated: true)
|
||||
}
|
||||
|
||||
@@ -337,6 +340,10 @@ final class DroneDockHomeViewController: BaseViewController {
|
||||
|
||||
private func openPrimaryAction(orderID: String) {
|
||||
guard !isRefreshing, let order = viewModel.orders.first(where: { $0.orderID == orderID }) else { return }
|
||||
if order.primaryAction == "confirm_delivery" {
|
||||
openConfirmation(order: order)
|
||||
return
|
||||
}
|
||||
if order.primaryAction == "view_materials" {
|
||||
openMaterials(orderID: orderID)
|
||||
return
|
||||
@@ -354,6 +361,16 @@ final class DroneDockHomeViewController: BaseViewController {
|
||||
navigationController?.pushViewController(controller, animated: true)
|
||||
}
|
||||
|
||||
private func openConfirmation(order: DroneDockHomeOrder) {
|
||||
guard navigationController?.topViewController === self, presentedViewController == nil,
|
||||
order.canConfirm == true || order.orderStatus == 30 || order.confirmStatus == 2 else { return }
|
||||
guard DroneDockHomeMetric.usableText(order.orderNumber) != nil else {
|
||||
showAlert(title: "订单交付确认", message: "缺少订单号,请刷新工作台后重试")
|
||||
return
|
||||
}
|
||||
navigationController?.pushViewController(confirmationControllerFactory(order, viewModel.context), animated: true)
|
||||
}
|
||||
|
||||
@objc private func receiptTapped() {
|
||||
let controller = paymentControllerFactory?() ?? DroneDockPaymentViewController()
|
||||
navigationController?.pushViewController(controller, animated: true)
|
||||
|
||||
Reference in New Issue
Block a user