接入首页位置上报与在线倒计时,并优化上报交互体验。

持久化服务端 expired 过期时间戳以正确恢复倒计时,切换在线/离线与上报时展示定位 Loading,移除重复的成功 Alert,并将 Toast 调整为居中半透明样式。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-29 15:59:59 +08:00
parent d9f897038d
commit 560b52fcc8
19 changed files with 1028 additions and 204 deletions

View File

@ -7,12 +7,12 @@
import Foundation
/// 线
/// 线
enum LocationReportType: Int, CaseIterable, Identifiable {
case all = 0
case immediate = 1
case marked = 2
case onlineStatus = 3
case offlineReport = 3
var id: Int { rawValue }
@ -22,7 +22,7 @@ enum LocationReportType: Int, CaseIterable, Identifiable {
case .all: "全部"
case .immediate: "立即上报"
case .marked: "标记点"
case .onlineStatus: "在线状态"
case .offlineReport: "离线上报"
}
}
}
@ -33,7 +33,40 @@ struct LocationCoordinate: Equatable {
var longitude: Double
}
///
/// 线
struct LocationDetailResponse: Decodable, Equatable {
let status: Int
let needReport: Bool
let expireTime: Int
enum CodingKeys: String, CodingKey {
case status
case needReport = "need_report"
case expireTime = "expire_time"
}
///
init(status: Int, needReport: Bool, expireTime: Int) {
self.status = status
self.needReport = needReport
self.expireTime = expireTime
}
///
init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
status = try container.decodeLossyInt(forKey: .status) ?? 0
if let boolValue = try? container.decodeIfPresent(Bool.self, forKey: .needReport) {
needReport = boolValue
} else {
let raw = try container.decodeLossyInt(forKey: .needReport) ?? 0
needReport = raw != 0
}
expireTime = try container.decodeLossyInt(forKey: .expireTime) ?? 0
}
}
///
struct LocationReportSubmitResponse: Decodable, Equatable {
let staffId: String
let expired: Int