88 lines
2.7 KiB
Swift
88 lines
2.7 KiB
Swift
//
|
|
// QueueManagementViewControllers.swift
|
|
// suixinkan
|
|
//
|
|
// Created by Codex on 2026/6/26.
|
|
//
|
|
|
|
import UIKit
|
|
|
|
/// 排队管理页。
|
|
final class QueueManagementViewController: ModuleTableViewController {
|
|
private let viewModel = QueueManagementViewModel()
|
|
|
|
override func viewDidLoad() {
|
|
title = "排队管理"
|
|
navigationItem.rightBarButtonItem = UIBarButtonItem(
|
|
title: "设置",
|
|
style: .plain,
|
|
target: self,
|
|
action: #selector(openSettings)
|
|
)
|
|
super.viewDidLoad()
|
|
wireViewModel(viewModel) { [weak self] in self?.updateTitle() }
|
|
}
|
|
|
|
override func tableRowCount() -> Int { viewModel.items.count }
|
|
|
|
override func configureCell(_ cell: TitleSubtitleTableViewCell, at indexPath: IndexPath) {
|
|
let item = viewModel.items[indexPath.row]
|
|
cell.configure(title: item.phoneMasked, subtitle: item.statusText, detail: item.queueCode)
|
|
}
|
|
|
|
override func reloadContent() async {
|
|
await viewModel.reload(
|
|
api: services.scenicQueueAPI,
|
|
scenicId: services.currentScenicId,
|
|
userId: services.userId,
|
|
spots: services.scenicSpotContext.spots
|
|
)
|
|
updateTitle()
|
|
}
|
|
|
|
private func updateTitle() {
|
|
title = "排队 \(viewModel.queueCount)"
|
|
}
|
|
|
|
@objc private func openSettings() {
|
|
navigationController?.pushViewController(ScenicQueueSettingsViewController(), animated: true)
|
|
}
|
|
}
|
|
|
|
extension QueueManagementViewModel: ViewModelBindable {}
|
|
|
|
/// 排队设置页。
|
|
final class ScenicQueueSettingsViewController: ModuleTableViewController {
|
|
private let viewModel = ScenicQueueSettingsViewModel()
|
|
|
|
override func viewDidLoad() {
|
|
title = "排队设置"
|
|
super.viewDidLoad()
|
|
wireViewModel(viewModel) { }
|
|
}
|
|
|
|
override func tableRowCount() -> Int { viewModel.scenicSpots.count }
|
|
|
|
override func configureCell(_ cell: TitleSubtitleTableViewCell, at indexPath: IndexPath) {
|
|
let spot = viewModel.scenicSpots[indexPath.row]
|
|
let selected = viewModel.selectedSpotId == spot.id
|
|
cell.configure(title: spot.name, subtitle: selected ? "当前打卡点" : nil)
|
|
cell.accessoryType = selected ? .checkmark : .none
|
|
}
|
|
|
|
override func didSelectTableRow(at indexPath: IndexPath) {
|
|
viewModel.selectedSpotId = viewModel.scenicSpots[indexPath.row].id
|
|
}
|
|
|
|
override func reloadContent() async {
|
|
await viewModel.load(
|
|
api: services.scenicQueueAPI,
|
|
scenicId: services.currentScenicId,
|
|
userId: services.userId,
|
|
spots: services.scenicSpotContext.spots
|
|
)
|
|
}
|
|
}
|
|
|
|
extension ScenicQueueSettingsViewModel: ViewModelBindable {}
|