From 536482bd2dea7b4345c85d96a68ed4c99511dfe6 Mon Sep 17 00:00:00 2001 From: zjx Date: Fri, 18 Jul 2025 18:25:40 +0800 Subject: [PATCH] =?UTF-8?q?1.1.1=E6=8F=90=E5=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Veloria.xcodeproj/project.pbxproj | 8 +- .../Player/View/VPPlayerRechargeView.swift | 5 +- Veloria/Libs/VPIAPManager/VPIAPManager.swift | 1 - .../JXIAPManager/JXIAPManager.swift | 79 ++++++++++++++----- 4 files changed, 66 insertions(+), 27 deletions(-) diff --git a/Veloria.xcodeproj/project.pbxproj b/Veloria.xcodeproj/project.pbxproj index b9a9be2..5205c42 100644 --- a/Veloria.xcodeproj/project.pbxproj +++ b/Veloria.xcodeproj/project.pbxproj @@ -1918,7 +1918,7 @@ CODE_SIGN_ENTITLEMENTS = Veloria/Veloria.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1; + CURRENT_PROJECT_VERSION = 2; DEVELOPMENT_TEAM = 394VH538M8; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = Veloria/Source/Info.plist; @@ -1937,7 +1937,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.1.0; + MARKETING_VERSION = 1.1.1; PRODUCT_BUNDLE_IDENTIFIER = com.qjwl168.veloria.ios; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -1961,7 +1961,7 @@ CODE_SIGN_ENTITLEMENTS = Veloria/Veloria.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1; + CURRENT_PROJECT_VERSION = 2; DEVELOPMENT_TEAM = 394VH538M8; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = Veloria/Source/Info.plist; @@ -1980,7 +1980,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.1.0; + MARKETING_VERSION = 1.1.1; PRODUCT_BUNDLE_IDENTIFIER = com.qjwl168.veloria.ios; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; diff --git a/Veloria/Class/Player/View/VPPlayerRechargeView.swift b/Veloria/Class/Player/View/VPPlayerRechargeView.swift index 66c5146..994a65f 100644 --- a/Veloria/Class/Player/View/VPPlayerRechargeView.swift +++ b/Veloria/Class/Player/View/VPPlayerRechargeView.swift @@ -227,7 +227,7 @@ class VPPlayerRechargeView: HWPanModalContentView { @objc private func handleCloseButton() { - let payTemplateModel = self.discountPayTemplateModel +// let payTemplateModel = self.discountPayTemplateModel self.dismiss(animated: true) { // if let payTemplateModel = payTemplateModel, payTemplateModel.list_sub_vip?.isEmpty == false { @@ -243,8 +243,7 @@ class VPPlayerRechargeView: HWPanModalContentView { } override func longFormHeight() -> PanModalHeight { -// return PanModalHeightMake(.content, UIScreen.height * (4 / 5)) - return PanModalHeightMake(.content, UIScreen.height - UIScreen.navBarHeight) + return PanModalHeightMake(.content, UIScreen.height - UIScreen.statusBarHeight) } override func showDragIndicator() -> Bool { diff --git a/Veloria/Libs/VPIAPManager/VPIAPManager.swift b/Veloria/Libs/VPIAPManager/VPIAPManager.swift index 45577e0..274cc01 100644 --- a/Veloria/Libs/VPIAPManager/VPIAPManager.swift +++ b/Veloria/Libs/VPIAPManager/VPIAPManager.swift @@ -83,7 +83,6 @@ class VPIAPManager { self.iapManager.start(productId: productId, orderId: self.orderCode ?? "", discount: discount) -// self.iapManager.showCodeRedemption() } } diff --git a/Veloria/Thirdparty/JXIAPManager/JXIAPManager.swift b/Veloria/Thirdparty/JXIAPManager/JXIAPManager.swift index 115e3fc..548ee76 100644 --- a/Veloria/Thirdparty/JXIAPManager/JXIAPManager.swift +++ b/Veloria/Thirdparty/JXIAPManager/JXIAPManager.swift @@ -10,7 +10,7 @@ import StoreKit @objc protocol JXIAPManagerDelegate { /// 获取到可购买商品列表 - @objc optional func jx_iapPayGotProducts(productIds: [String]) + @objc optional func jx_iapPayGotProducts(productIds: [SKProduct]) /// 购买成功 @objc optional func jx_iapPaySuccess(productId: String, receipt: String, transactionIdentifier: String?) /// 购买失败 @@ -34,28 +34,28 @@ import StoreKit case cancelled ///没有商品 case noProduct - } class JXIAPManager: NSObject { + enum OperationType { + case idle + case buy + case request + } + static let manager: JXIAPManager = JXIAPManager() weak var delegate: JXIAPManagerDelegate? + ///当前操作状态 + private var operationType = OperationType.idle + private var payment: SKPayment? private var product: SKProduct? private var productId: String? - /* - let discount = SKPaymentDiscount( - identifier: offerIdentifier,//促销优惠中设置的 ID - keyIdentifier: keyIdentifier, //订阅密钥ID - nonce: UUID(), //随机数 - signature: signature, //服务器生成的签名 - timestamp: timestamp //服务器生成签名的时间戳 - ) - */ + private var discount: SKPaymentDiscount? private var orderId: String? private var applicationUsername: String? { @@ -94,7 +94,39 @@ class JXIAPManager: NSObject { SKPaymentQueue.default().presentCodeRedemptionSheet() } + func requestProductList(productIdArr: [String]) { + guard self.operationType == .idle else { return } + self.operationType = .request + + let set = Set(productIdArr) + let productsRequest = SKProductsRequest(productIdentifiers: set) + productsRequest.delegate = self + productsRequest.start() + } + +// ///发起购买 +// func buyProduct(product: SKProduct, orderId: String, discount: SKPaymentDiscount? = nil) { +// guard self.operationType == .idle else { return } +// self.operationType = .buy +// +// self.product = product +// self.orderId = orderId +// +// // 要购买商品,开个小票 +// let payment = SKMutablePayment(product: product) +// payment.applicationUsername = applicationUsername +// if let discount = discount { +// payment.paymentDiscount = discount +// } +// +// // 去收银台排队,准备购买 +// SKPaymentQueue.default().add(payment) +// } + func start(productId: String, orderId: String, discount: SKPaymentDiscount? = nil) { + guard self.operationType == .idle else { return } + self.operationType = .buy + self.product = nil self.productId = productId self.orderId = orderId @@ -129,18 +161,25 @@ class JXIAPManager: NSObject { //MARK: -------------- SKProductsRequestDelegate -------------- extension JXIAPManager: SKProductsRequestDelegate { func productsRequest(_ request: SKProductsRequest, didReceive response: SKProductsResponse) { - guard let product = response.products.first else { - DispatchQueue.main.async { - if let productId = self.productId { - self.productId = nil - self.delegate?.jx_iapPayFailed?(productId: productId, code: .noProduct) + if self.operationType == .request { + self.delegate?.jx_iapPayGotProducts?(productIds: response.products) + self.operationType = .idle + } else if self.operationType == .buy { + + guard let product = response.products.first else { + DispatchQueue.main.async { + if let productId = self.productId { + self.productId = nil + self.delegate?.jx_iapPayFailed?(productId: productId, code: .noProduct) + } } + return } - return + self.product = product + + self.buyProduct() } - self.product = product - self.buyProduct() } } @@ -196,12 +235,14 @@ extension JXIAPManager { guard let productId = self.productId, productId == transaction.payment.productIdentifier else { return } + self.operationType = .idle self.productId = nil self.delegate?.jx_iapPaySuccess?(productId: productId, receipt: encodeStr, transactionIdentifier: transactionIdentifier) } private func failedTransaction(transaction: SKPaymentTransaction) { + self.operationType = .idle let error = transaction.error as? SKError guard let productId = self.productId else { return } self.productId = nil