fix: 优化收款码加载态,避免首屏错误占位闪现
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@ -28,6 +28,7 @@ final class PaymentCollectionDetailsViewModel {
|
||||
|
||||
private var staticPayURL = ""
|
||||
private var dynamicPayURL = ""
|
||||
private var hasCompletedPayCodeRequest = false
|
||||
private let appStore: AppStore
|
||||
private let payPageConfigCache: PayPageConfigCaching
|
||||
|
||||
@ -50,6 +51,11 @@ final class PaymentCollectionDetailsViewModel {
|
||||
qrImage != nil && !staticPayURL.isEmpty
|
||||
}
|
||||
|
||||
/// 是否应在二维码区域展示加载状态,首次请求开始前也视为加载中,避免短暂闪现错误占位。
|
||||
var isPayCodeLoading: Bool {
|
||||
loading || !hasCompletedPayCodeRequest
|
||||
}
|
||||
|
||||
var displayScenicName: String {
|
||||
scenicName.isEmpty ? "暂无景区" : scenicName
|
||||
}
|
||||
@ -85,11 +91,11 @@ final class PaymentCollectionDetailsViewModel {
|
||||
|
||||
func loadPayCode(api: PaymentAPI) async {
|
||||
guard !loading else { return }
|
||||
refreshLocalState()
|
||||
loading = true
|
||||
notifyStateChange()
|
||||
refreshLocalState()
|
||||
defer {
|
||||
loading = false
|
||||
hasCompletedPayCodeRequest = true
|
||||
notifyStateChange()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user