feat(payment): 支持赛里木湖品牌收款页与独立缓存
This commit is contained in:
@@ -42,9 +42,7 @@ final class PaymentCollectionDetailsViewModel {
|
||||
scenicName = appStore.session.currentScenicName
|
||||
staffId = appStore.session.userId
|
||||
isVoiceBroadcastOpen = appStore.payment.isOpenReceiveVoice
|
||||
if PayPageBrandingPolicy.isNalati(scenicId: scenicId) {
|
||||
payPageConfig = payPageConfigCache.config(scenicId: scenicId) ?? .nalatiDefault
|
||||
}
|
||||
restorePayPageConfig()
|
||||
}
|
||||
|
||||
var hasPayCode: Bool {
|
||||
@@ -60,8 +58,26 @@ final class PaymentCollectionDetailsViewModel {
|
||||
scenicName.isEmpty ? "暂无景区" : scenicName
|
||||
}
|
||||
|
||||
var usesNalatiBranding: Bool {
|
||||
PayPageBrandingPolicy.isNalati(scenicId: scenicId)
|
||||
/// 是否启用品牌收款页,包含那拉提与赛里木湖。
|
||||
var usesBranding: Bool {
|
||||
PayPageBrandingPolicy.defaultConfig(scenicId: scenicId) != nil
|
||||
}
|
||||
|
||||
/// 当前景区的随包背景资源名称。
|
||||
var brandBackgroundAssetName: String {
|
||||
scenicId == PayPageBrandingPolicy.sailimuScenicId
|
||||
? "payment_sailimu_background" : "payment_nalati_background"
|
||||
}
|
||||
|
||||
/// 当前景区的随包 Logo 资源名称。
|
||||
var brandLogoAssetName: String {
|
||||
scenicId == PayPageBrandingPolicy.sailimuScenicId
|
||||
? "payment_sailimu_logo" : "payment_nalati_logo"
|
||||
}
|
||||
|
||||
/// 品牌主标题的最大行数,赛里木湖允许两行展示。
|
||||
var brandTitleNumberOfLines: Int {
|
||||
scenicId == PayPageBrandingPolicy.sailimuScenicId ? 2 : 1
|
||||
}
|
||||
|
||||
var displayPhotographerName: String {
|
||||
@@ -80,14 +96,18 @@ final class PaymentCollectionDetailsViewModel {
|
||||
scenicName = appStore.session.currentScenicName
|
||||
staffId = appStore.session.userId
|
||||
isVoiceBroadcastOpen = appStore.payment.isOpenReceiveVoice
|
||||
if usesNalatiBranding {
|
||||
payPageConfig = payPageConfigCache.config(scenicId: scenicId) ?? .nalatiDefault
|
||||
} else {
|
||||
payPageConfig = .nalatiDefault
|
||||
}
|
||||
restorePayPageConfig()
|
||||
notifyStateChange()
|
||||
}
|
||||
|
||||
private func restorePayPageConfig() {
|
||||
guard let defaults = PayPageBrandingPolicy.defaultConfig(scenicId: scenicId) else {
|
||||
payPageConfig = .nalatiDefault
|
||||
return
|
||||
}
|
||||
payPageConfig = payPageConfigCache.config(scenicId: scenicId) ?? defaults
|
||||
}
|
||||
|
||||
func loadPayCode(api: PaymentAPI) async {
|
||||
guard !loading else { return }
|
||||
loading = true
|
||||
@@ -116,12 +136,14 @@ final class PaymentCollectionDetailsViewModel {
|
||||
|
||||
func loadPayPageConfig(api: PaymentAPI) async {
|
||||
let requestedScenicId = appStore.session.currentScenicId
|
||||
guard PayPageBrandingPolicy.isNalati(scenicId: requestedScenicId) else { return }
|
||||
guard let defaults = PayPageBrandingPolicy.defaultConfig(scenicId: requestedScenicId) else { return }
|
||||
|
||||
do {
|
||||
let response = try await api.payPageConfig(scenicId: requestedScenicId)
|
||||
guard appStore.session.currentScenicId == requestedScenicId else { return }
|
||||
let resolved = payPageConfig.merging(response)
|
||||
guard appStore.session.currentScenicId == requestedScenicId,
|
||||
scenicId == requestedScenicId else { return }
|
||||
let cached = payPageConfigCache.config(scenicId: requestedScenicId) ?? defaults
|
||||
let resolved = cached.merging(response)
|
||||
payPageConfigCache.save(resolved, scenicId: requestedScenicId)
|
||||
payPageConfig = resolved
|
||||
brandingRefreshVersion += 1
|
||||
|
||||
Reference in New Issue
Block a user