feat(drone-dock): 实现局域网扫码直传交付

This commit is contained in:
2026-10-30 14:50:34 +08:00
parent 0bc801f399
commit f99a175f99
25 changed files with 3084 additions and 74 deletions
@@ -21,12 +21,12 @@ final class DroneDeliveryUploadViewController: BaseViewController {
weak var delegate: DroneDeliveryUploadViewControllerDelegate?
/// 页面阶段只管理展示导航,不参与上传成功或拍摄次数计算。
private enum Phase: Equatable { case method, nearby, point, picker, queue }
private enum Phase: Equatable { case method, point, picker, queue }
/// 队列摘要与主体使用独立分区。
private enum Section: Hashable { case summary, content }
/// 每一项依靠稳定业务身份更新,选择与进度不改变 Diffable 标识。
private enum Item: Hashable {
case nearbyMethod, cloudMethod, nearbyMessage, point(String), video(String), upload(String), summary, empty
case nearbyMethod, cloudMethod, point(String), video(String), upload(String), summary, empty
}
private var phase: Phase
@@ -53,6 +53,7 @@ final class DroneDeliveryUploadViewController: BaseViewController {
/// 返回前台或结束预览后只刷新本地状态,不自动启动暂停队列。
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
navigationController?.setNavigationBarHidden(true, animated: false)
viewModel.refresh()
if dataSource != nil { applySnapshot(animated: false) }
}
@@ -145,7 +146,6 @@ final class DroneDeliveryUploadViewController: BaseViewController {
let height: CGFloat
switch self.phase {
case .method: height = 88
case .nearby: height = 170
case .point: height = self.viewModel.points.isEmpty ? 180 : 52
case .picker: height = 180
case .queue: height = self.viewModel.batch?.items.isEmpty == false ? 82 : 180
@@ -174,7 +174,7 @@ final class DroneDeliveryUploadViewController: BaseViewController {
case .nearbyMethod, .cloudMethod:
let cell = list.dequeueReusableCell(withReuseIdentifier: "method", for: indexPath) as! DroneDeliveryUploadMethodCell
if item == .nearbyMethod {
cell.apply(title: "面对面闪传", detail: "近距离传给游客 · 流程待确认", symbol: "wifi",
cell.apply(title: "面对面闪传", detail: "同一 Wi-Fi 扫码接收 · 无需上传", symbol: "wifi",
identifier: "drone.delivery.upload.method.nearby")
} else {
cell.apply(title: "云端上传", detail: "选择打卡点,演示上传成片", symbol: "icloud.and.arrow.up",
@@ -215,11 +215,9 @@ final class DroneDeliveryUploadViewController: BaseViewController {
self.delegate?.deliveryUploadViewControllerDidRequestReview(self)
}
return cell
case .nearbyMessage, .empty:
case .empty:
let cell = list.dequeueReusableCell(withReuseIdentifier: "message", for: indexPath) as! DroneDeliveryUploadMessageCell
if item == .nearbyMessage {
cell.apply(title: "闪传流程待确认", detail: "热点连接与游客接收流程暂未接入。\n现在可以先体验云端演示上传。", symbol: "wifi")
} else if self.phase == .point {
if self.phase == .point {
cell.apply(title: "暂无可交付点位", detail: "当前订单没有可用点位,请稍后重试。", symbol: "mappin.slash.circle")
} else if self.phase == .picker {
cell.apply(title: "暂无可选演示视频", detail: "本点位的示例视频已交付,可返回选择其他点位。", symbol: "video.slash")
@@ -256,7 +254,6 @@ final class DroneDeliveryUploadViewController: BaseViewController {
let items: [Item]
switch phase {
case .method: items = [.nearbyMethod, .cloudMethod]
case .nearby: items = [.nearbyMessage]
case .point: items = viewModel.points.isEmpty ? [.empty] : viewModel.points.map { .point($0.id) }
case .picker: items = viewModel.availableVideos.isEmpty ? [.empty] : viewModel.availableVideos.map { .video($0.id) }
case .queue: items = uploadItems.isEmpty ? [.empty] : uploadItems.map { .upload($0.id) }
@@ -276,9 +273,6 @@ final class DroneDeliveryUploadViewController: BaseViewController {
case .method:
headerView.apply(title: "交付成片", customer: customer, detail: "请选择本次交付方式")
footerView.apply(primaryTitle: nil, enabled: false, identifier: "", detail: "可分批演示交付多个作品,不影响拍摄次数", secondaryTitle: nil)
case .nearby:
headerView.apply(title: "面对面闪传", customer: customer, detail: "本次仅展示交付入口")
footerView.apply(primaryTitle: "改用云端上传", enabled: true, identifier: "drone.delivery.upload.useCloud", detail: "", secondaryTitle: "返回交付方式")
case .point:
headerView.apply(title: "选择打卡点", customer: customer, detail: "云端上传 · 请选择本批成片对应的打卡点")
footerView.apply(primaryTitle: "去演示相册选视频", enabled: viewModel.selectedPoint != nil && !viewModel.isUploadLocked,
@@ -320,7 +314,6 @@ final class DroneDeliveryUploadViewController: BaseViewController {
private func primaryTapped() {
switch phase {
case .method: break
case .nearby: openCloudFlow()
case .point: if viewModel.selectedPoint != nil { showPhase(.picker) }
case .picker:
if viewModel.startUpload() { showPhase(.queue); startDemoUpload() }
@@ -338,6 +331,25 @@ final class DroneDeliveryUploadViewController: BaseViewController {
}
}
/// 演示入口也使用同一局域网页面,但必须显式选择本机视频才会开放传输。
private func openNearbyFlow() {
let nearby = DroneDockNearbyTransferViewController(customerTitle: "面对面交付")
if let navigation = navigationController {
nearby.onClose = { [weak navigation] in navigation?.popViewController(animated: true) }
navigation.sheetPresentationController?.animateChanges {
navigation.sheetPresentationController?.selectedDetentIdentifier = .large
}
navigation.setNavigationBarHidden(false, animated: true)
navigation.pushViewController(nearby, animated: true)
} else {
let navigation = UINavigationController(rootViewController: nearby)
navigation.modalPresentationStyle = .pageSheet
navigation.sheetPresentationController?.detents = [.large()]
nearby.onClose = { [weak navigation] in navigation?.dismiss(animated: true) }
present(navigation, animated: true)
}
}
/// 选择云端仅恢复原队列或进入选点,不清除批次,也不自动继续上传。
private func openCloudFlow() {
showPhase(viewModel.batch == nil ? .point : .queue)
@@ -346,7 +358,7 @@ final class DroneDeliveryUploadViewController: BaseViewController {
private func secondaryTapped() {
switch phase {
case .method: break
case .nearby, .point: showPhase(.method)
case .point: showPhase(.method)
case .picker: showPhase(.point)
case .queue: finish()
}
@@ -402,7 +414,7 @@ extension DroneDeliveryUploadViewController: UICollectionViewDelegate {
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
guard let item = dataSource.itemIdentifier(for: indexPath) else { return }
switch item {
case .nearbyMethod: showPhase(.nearby)
case .nearbyMethod: openNearbyFlow()
case .cloudMethod: openCloudFlow()
case .point(let id): viewModel.selectPoint(id: id); applySnapshot(animated: true)
case .upload(let id):