feat(payment): 支持赛里木湖品牌收款页与独立缓存

This commit is contained in:
2026-09-23 15:08:48 +08:00
parent 3823d10423
commit d12dbc6bb0
9 changed files with 224 additions and 41 deletions
@@ -101,15 +101,16 @@ final class PaymentCollectionDetailsViewController: BaseViewController {
}
override func setupNavigationBar() {
title = viewModel.usesNalatiBranding ? nil : "收款详情"
title = viewModel.usesBranding ? nil : "收款详情"
}
override func setupUI() {
let usesBranding = viewModel.usesNalatiBranding
let usesBranding = viewModel.usesBranding
view.backgroundColor = usesBranding ? .clear : AppColor.pageBackground
scrollView.showsVerticalScrollIndicator = !usesBranding
scrollView.isScrollEnabled = true
scrollView.alwaysBounceVertical = true
scrollView.contentInsetAdjustmentBehavior = .always
contentStack.axis = .vertical
contentStack.spacing = usesBranding ? brandSectionSpacing : AppSpacing.md
@@ -187,7 +188,7 @@ final class PaymentCollectionDetailsViewController: BaseViewController {
configureBrandHeader()
backgroundImageView.contentMode = .scaleAspectFill
backgroundImageView.clipsToBounds = true
backgroundImageView.image = UIImage(named: "payment_nalati_background")
backgroundImageView.image = UIImage(named: viewModel.brandBackgroundAssetName)
view.addSubview(backgroundImageView)
}
@@ -320,30 +321,24 @@ final class PaymentCollectionDetailsViewController: BaseViewController {
}
override func setupConstraints() {
if viewModel.usesNalatiBranding {
if viewModel.usesBranding {
backgroundImageView.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
}
scrollView.snp.makeConstraints { make in
if viewModel.usesNalatiBranding {
make.leading.trailing.equalToSuperview()
make.top.equalTo(view.safeAreaLayoutGuide.snp.top).offset(-44)
make.bottom.equalTo(view.safeAreaLayoutGuide)
} else {
make.edges.equalTo(view.safeAreaLayoutGuide)
}
make.edges.equalToSuperview()
}
contentContainerView.snp.makeConstraints { make in
make.edges.equalToSuperview()
make.width.equalTo(scrollView.snp.width)
if viewModel.usesNalatiBranding {
make.edges.equalTo(scrollView.contentLayoutGuide)
make.width.equalTo(scrollView.frameLayoutGuide)
if viewModel.usesBranding {
make.height.greaterThanOrEqualTo(scrollView.snp.height)
}
}
contentStack.snp.makeConstraints { make in
make.width.equalTo(scrollView.snp.width).offset(-AppSpacing.screenHorizontalInset * 2)
if viewModel.usesNalatiBranding {
if viewModel.usesBranding {
make.centerX.equalToSuperview()
make.top.bottom.equalToSuperview().inset(AppSpacing.screenHorizontalInset)
} else {
@@ -403,7 +398,7 @@ final class PaymentCollectionDetailsViewController: BaseViewController {
}
override var preferredStatusBarStyle: UIStatusBarStyle {
viewModel.usesNalatiBranding ? .darkContent : .default
viewModel.usesBranding ? .darkContent : .default
}
private func loadData() async {
@@ -426,7 +421,7 @@ final class PaymentCollectionDetailsViewController: BaseViewController {
if viewModel.isPayCodeLoading {
qrImageView.isHidden = true
qrContainerView.isHidden = true
qrPlaceholderView.backgroundColor = viewModel.usesNalatiBranding
qrPlaceholderView.backgroundColor = viewModel.usesBranding
? .white
: AppColor.inputBackground
qrPlaceholderView.isHidden = false
@@ -437,7 +432,7 @@ final class PaymentCollectionDetailsViewController: BaseViewController {
} else if let image = viewModel.qrImage {
qrImageView.image = image
qrImageView.isHidden = false
qrContainerView.isHidden = !viewModel.usesNalatiBranding
qrContainerView.isHidden = !viewModel.usesBranding
qrPlaceholderView.isHidden = true
qrLoadingIndicator.stopAnimating()
setActionRowAvailable(true)
@@ -527,7 +522,7 @@ final class PaymentCollectionDetailsViewController: BaseViewController {
brandHeaderStack.alignment = .center
brandHeaderStack.spacing = brandScreenHeight <= 700 ? 6 : 8
brandLogoImageView.image = UIImage(named: "payment_nalati_logo")
brandLogoImageView.image = UIImage(named: viewModel.brandLogoAssetName)
brandLogoImageView.contentMode = .scaleAspectFit
brandLogoImageView.setContentCompressionResistancePriority(.defaultLow, for: .horizontal)
@@ -537,7 +532,7 @@ final class PaymentCollectionDetailsViewController: BaseViewController {
)
brandTitleLabel.textColor = UIColor(hex: 0x102D54)
brandTitleLabel.textAlignment = .center
brandTitleLabel.numberOfLines = 1
brandTitleLabel.numberOfLines = viewModel.brandTitleNumberOfLines
brandTitleLabel.adjustsFontSizeToFitWidth = true
brandTitleLabel.minimumScaleFactor = 0.8
@@ -604,7 +599,7 @@ final class PaymentCollectionDetailsViewController: BaseViewController {
@MainActor
private func applyBrandConfigIfNeeded() {
guard viewModel.usesNalatiBranding else { return }
guard viewModel.usesBranding else { return }
let config = viewModel.payPageConfig
brandTitleLabel.text = config.title
brandSubtitleLabel.text = config.subtitle
@@ -615,13 +610,13 @@ final class PaymentCollectionDetailsViewController: BaseViewController {
setBrandImage(
backgroundImageView,
urlString: config.background,
fallbackName: "payment_nalati_background",
fallbackName: viewModel.brandBackgroundAssetName,
forceRefresh: forceRefresh
)
setBrandImage(
brandLogoImageView,
urlString: config.logo,
fallbackName: "payment_nalati_logo",
fallbackName: viewModel.brandLogoAssetName,
forceRefresh: forceRefresh
)
appliedBrandConfig = config
@@ -639,6 +634,7 @@ final class PaymentCollectionDetailsViewController: BaseViewController {
guard let url = URL(string: trimmed),
url.scheme?.lowercased() == "https",
url.host != nil else {
imageView.kf.cancelDownloadTask()
imageView.image = fallback
return
}
@@ -655,7 +651,7 @@ final class PaymentCollectionDetailsViewController: BaseViewController {
}
private func applyBrandNavigationAppearanceIfNeeded() {
guard viewModel.usesNalatiBranding, let navigationBar = navigationController?.navigationBar else { return }
guard viewModel.usesBranding, let navigationBar = navigationController?.navigationBar else { return }
previousStandardAppearance = navigationBar.standardAppearance
previousScrollEdgeAppearance = navigationBar.scrollEdgeAppearance
previousCompactAppearance = navigationBar.compactAppearance
@@ -677,7 +673,7 @@ final class PaymentCollectionDetailsViewController: BaseViewController {
}
private func restoreNavigationAppearanceIfNeeded() {
guard viewModel.usesNalatiBranding, let navigationBar = navigationController?.navigationBar else { return }
guard viewModel.usesBranding, let navigationBar = navigationController?.navigationBar else { return }
if let previousStandardAppearance {
navigationBar.standardAppearance = previousStandardAppearance
}