Commit 28da309c authored by Alex朱枝文's avatar Alex朱枝文

优化续签签证缴费

parent f156c248
......@@ -332,7 +332,6 @@ extension YHHKVisaRenewalPaymentVC {
let payMethodTips: ASAttributedString = .init(string: "提示:", .foreground(UIColor.yhOrangeColor)) + .init(string: "请先到下方“缴费成员”处") + .init(string: "复制档案号", .foreground(UIColor.yhOrangeColor)) + .init(string: "再缴费")
let webPageUrl = paymentListModel.payment_url
if webPageUrl.count > 0, URL(string: webPageUrl) != nil {
let qrImage = webPageUrl.generateQRCode()
let payMethodSection: [YHVisaRenewalItemDetailType] = [.sectionHeader("港府官网缴费方式", "缴费遇到问题?", { [weak self] in
guard let self = self else {
return
......@@ -345,7 +344,7 @@ extension YHHKVisaRenewalPaymentVC {
}
printLog("点击下方链接,跳转浏览器")
self.gotoWebVC(webPageUrl)
}), .payMethodQrcode("方式二", "用其他设备直接扫码,或长按保存图片,通过微信识别打开", qrImage)]
}), .payMethodQrcode("方式二", "用其他设备直接扫码,或长按保存图片,通过微信识别打开", webPageUrl)]
sections.append(payMethodSection)
}
var payMembersSection: [YHVisaRenewalItemDetailType] = [.sectionHeader("缴费成员", "电子签证范例", { [weak self] in
......@@ -510,9 +509,9 @@ extension YHHKVisaRenewalPaymentVC: UITableViewDelegate, UITableViewDataSource {
}
return cell
}
case let .payMethodQrcode(title, detail, image):
case let .payMethodQrcode(title, detail, qrCodeUrl):
if let cell = tableView.dequeueReusableCell(withIdentifier: YHVisaRenewalPayMethodQrcodeCell.cellReuseIdentifier) as? YHVisaRenewalPayMethodQrcodeCell {
cell.setupCellInfo(title: title, tips: detail, qrCode: image)
cell.setupCellInfo(title: title, tips: detail, qrCode: qrCodeUrl)
cell.onLongPressEvent = { [weak self] image in
self?.saveImage(image)
}
......
......@@ -14,7 +14,7 @@ enum YHVisaRenewalItemDetailType {
case tips(_ detail: ASAttributedString)
case residenceAction(_ title: String, _ status: YHVisaRenewalPresenceStatus, _ cellType: YHResignRoundCellType = .mid, _ action: (() -> Void)? = nil)
case payMethodUrl(_ title: String, _ tips: String, _ url: String, _ action: (() -> Void)? = nil)
case payMethodQrcode(_ title: String, _ tips: String, _ image: UIImage?)
case payMethodQrcode(_ title: String, _ tips: String, _ qrcodeUrl: String)
case subHeader(_ title: String, _ status: YHVisaRenewalPaymentStatus)
case subInfo(_ title: String, _ detail: String, _ actionTitle: String? = nil, _ cellType: YHResignRoundCellType = .mid, _ defaultMargin: CGFloat? = nil, _ showBottomLine: Bool = false, _ action: (() -> Void)? = nil)
case subContent(_ title: String, _ detail: String, _ actionTitle: String? = nil, _ cellType: YHResignRoundCellType = .mid, _ action: (() -> Void)? = nil)
......
......@@ -7,10 +7,12 @@
//
import UIKit
import Kingfisher
class YHVisaRenewalPayMethodQrcodeCell: YHResignDocumentCell {
static let cellReuseIdentifier = "YHVisaRenewalPayMethodQrcodeCell"
private var qrCode: String = ""
var onLongPressEvent: ((UIImage) -> Void)?
......@@ -52,15 +54,43 @@ class YHVisaRenewalPayMethodQrcodeCell: YHResignDocumentCell {
fatalError("init(coder:) has not been implemented")
}
func setupCellInfo(title: String, tips: String, qrCode: UIImage?) {
func setupCellInfo(title: String, tips: String, qrCode: String) {
infoTitleLabel.text = title
infoTipsLabel.text = tips
if let qrCode = qrCode {
qrcodeIcon.image = qrCode
qrcodeIcon.isUserInteractionEnabled = true
self.qrCode = qrCode
let cacheKey = "qrcode_\(qrCode)"
let currentCode = qrCode
func updateQRCode() {
DispatchQueue.global(qos: .userInitiated).async { [weak self] in
if let qrCodeImage = qrCode.generateQRCode() {
ImageCache.default.store(qrCodeImage, forKey: cacheKey)
DispatchQueue.main.async {
if let self = self, currentCode == self.qrCode {
self.qrcodeIcon.image = qrCodeImage
self.qrcodeIcon.isUserInteractionEnabled = true
}
}
}
}
}
if ImageCache.default.isCached(forKey: cacheKey) {
ImageCache.default.retrieveImage(forKey: cacheKey) { [weak self] result in
switch result {
case .success(let cacheResult):
if let self = self, currentCode == self.qrCode, let image = cacheResult.image {
self.qrcodeIcon.image = image
self.qrcodeIcon.isUserInteractionEnabled = true
}
case .failure:
updateQRCode()
}
}
} else {
updateQRCode()
}
}
}
extension YHVisaRenewalPayMethodQrcodeCell {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment