|
@@ -16,6 +16,21 @@ import Cocoa
|
|
|
case alipay
|
|
|
}
|
|
|
|
|
|
+@objc enum KMDMGProductType: UInt32 {
|
|
|
+
|
|
|
+ case advanced_annual_subscription_trail = 0 // 全平台高级版年订阅 99.9 美金,带免费试用
|
|
|
+ case advanced_annual_subscription // 全平台高级版年订阅 99.9 美金
|
|
|
+ case advanced_annual_subscription_blackFive // 全平台高级版年订阅 99.9 美金,黑五订单,优惠价格不为空
|
|
|
+
|
|
|
+ case standard_annual_subscription // 全平台标准版年订阅 79.9 美金
|
|
|
+
|
|
|
+ case advanced_permanent // Mac & Win 双平台高级永久 119.99 美金
|
|
|
+ case advanced_permanent_blackFive // Mac & Win 双平台高级永久 119.99 美金,黑五订单,优惠价格不为空
|
|
|
+
|
|
|
+ case ai_subscription_year_trail // AI 年订阅 125.99 美金,带免费试用
|
|
|
+ case ai_subscription_month // AI 月订阅 14.99 美金
|
|
|
+}
|
|
|
+
|
|
|
class KMPurchaseEmbeddedWindowController: NSWindowController {
|
|
|
|
|
|
@IBOutlet weak var mainBox: NSBox!
|
|
@@ -31,6 +46,9 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
|
|
|
@IBOutlet weak var originalPriceLabel1: NSTextField! // 原价
|
|
|
@IBOutlet weak var discountPriceLabel1: NSTextField! // 折扣
|
|
|
|
|
|
+ @IBOutlet weak var usualAddonView: NSView!
|
|
|
+ @IBOutlet weak var usualAddCountView: NSView!
|
|
|
+
|
|
|
@IBOutlet weak var aiAddOnView: NSView!
|
|
|
@IBOutlet weak var aiAddOnButton: NSButton!
|
|
|
@IBOutlet weak var aiAddOnLabel: NSTextField!
|
|
@@ -131,6 +149,9 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
|
|
|
@IBOutlet weak var successfullyLabel: NSTextField!
|
|
|
@IBOutlet weak var imageBottomLayout: NSLayoutConstraint!
|
|
|
@IBOutlet weak var image2BottomLayout: NSLayoutConstraint!
|
|
|
+
|
|
|
+ private var _dmgProductType: KMDMGProductType = .advanced_annual_subscription_trail
|
|
|
+ private var _product_Info: KMListingProductsModel = KMListingProductsModel(id: "23", productName: "PDF Reader Pro Advanced - Annual Plan", price: NSNumber(value: 99.99), maxDeviceNum: 4, levels: "3", platforms: "Windows,Android,Mac,iOS", productLineId: 1, paymentModel: 1, cycle: 4, code: "advanced-annual-subscription-trail", cnyPrice: 0)
|
|
|
|
|
|
private var pdfCount: Int = 1
|
|
|
private var _paymentMethod: KMPaymentType = .paypal
|
|
@@ -218,6 +239,18 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
|
|
|
private var licenseAI1 = ""
|
|
|
private var isApplyCoupon: Bool = false
|
|
|
|
|
|
+ @objc static func currentWC(_ productInfo: KMListingProductsModel) -> KMPurchaseEmbeddedWindowController {
|
|
|
+ if currentWindowController != nil {
|
|
|
+ currentWindowController.product_Info = productInfo
|
|
|
+ return currentWindowController
|
|
|
+ } else {
|
|
|
+ let configWC: KMPurchaseEmbeddedWindowController = KMPurchaseEmbeddedWindowController.init(windowNibName: "KMPurchaseEmbeddedWindowController")
|
|
|
+ currentWindowController = configWC;
|
|
|
+ currentWindowController.product_Info = productInfo
|
|
|
+ return currentWindowController
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@objc static func currentFirstTrialWC(_ productId: String) -> KMPurchaseEmbeddedWindowController {
|
|
|
if currentWindowController != nil {
|
|
|
currentWindowController.productID = productId
|
|
@@ -254,6 +287,15 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
|
|
|
self.clearEventData()
|
|
|
}
|
|
|
|
|
|
+ // MARK: DMG Action
|
|
|
+ func isMoreCountViewShouldHidden(_ productinfo: KMListingProductsModel) -> Bool {
|
|
|
+ //买断版本才能一次购买多个,并且购买多个时,不会自动绑定,需要在后台给自己绑定才能有会员权益
|
|
|
+ if productinfo.paymentModel == 2 {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ return true
|
|
|
+ }
|
|
|
+
|
|
|
// MARK: UI
|
|
|
|
|
|
private func xibInitialization() -> Void {
|
|
@@ -272,74 +314,106 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
|
|
|
discountPriceLabel1.textColor = NSColor(named: "KMPurchaseDiscountColor")
|
|
|
discountPriceLabel1.font = NSFont.SFProTextRegularFont(9.0)
|
|
|
refreshLicenseCodeView(isReveal: false)
|
|
|
- if productType == .ipaConvert || productType == .ipaAI {
|
|
|
+ usualAddCountView.isHidden = isMoreCountViewShouldHidden(product_Info)
|
|
|
+
|
|
|
+ if _dmgProductType == .advanced_annual_subscription_trail {
|
|
|
aiAddOnView.isHidden = true
|
|
|
extendedView.isHidden = true
|
|
|
|
|
|
- if productType == .ipaConvert {
|
|
|
- pdfReaderProLabel.stringValue = NSLocalizedString("PDF to Office", comment: "")
|
|
|
- prmiumLabel.stringValue = NSLocalizedString("Export PDF to Word(.docx), Excel (.xlsx), PowerPoint(.pptx)", comment: "")
|
|
|
- oneLicenseLabel.stringValue = NSLocalizedString("and more offline. It's one time purchase.", comment: "")
|
|
|
- licenseCodeLabel.stringValue = NSLocalizedString("License Code", comment: "")
|
|
|
- licenseCodeLabel.textColor = NSColor(named: "KMPurchaseTitleColor1")
|
|
|
- licenseCodeLabel.font = NSFont.SFProTextRegularFont(14.0)
|
|
|
- licenseCodeTextField.placeholderString = NSLocalizedString("Input license code previously activated the app", comment: "")
|
|
|
- licenseCodeTextField.delegate = self
|
|
|
- licenseCodeBox.borderColor = NSColor(named: "KMPurchase_DADBDE")!
|
|
|
- licenseCodeBox.fillColor = NSColor(named: "KMPurchase_FFFFFF")!
|
|
|
- notFoundButton.title = NSLocalizedString("Not Found?", comment: "")
|
|
|
- notFoundButton.setTitleColor(color: NSColor(named: "KMPurchaseCouponColor")!, font: NSFont(name: "body-s-regular", size: 14))
|
|
|
- licenseCodeTextField.stringValue = VerificationManager.default().originLicenseCode ?? ""
|
|
|
- refreshLicenseCodeView(isReveal: true)
|
|
|
- licenseCodeErrorLabel.stringValue = NSLocalizedString("Please enter right license code. How to Retrieve License.", comment: "")
|
|
|
- licenseCodeErrorLabel.textColor = NSColor(named: "KMPurchaseErrorColor")
|
|
|
- licenseCodeErrorLabel.font = NSFont.SFProTextRegularFont(11.0)
|
|
|
- refreshLicenseCodeErrorView(isReveal: false)
|
|
|
- } else if productType == .ipaAI {
|
|
|
- pdfReaderProLabel.stringValue = NSLocalizedString("PDF Reader Pro AI Tools", comment: "")
|
|
|
- prmiumLabel.stringValue = NSLocalizedString("50 credits for 30 days", comment: "")
|
|
|
- oneLicenseLabel.stringValue = NSLocalizedString("Manually renew at USD 14.99", comment: "")
|
|
|
- }
|
|
|
- } else {
|
|
|
- pdfReaderProLabel.stringValue = NSLocalizedString("PDF Reader Pro for Mac", comment: "")
|
|
|
- if productToType(originalProductID) == .ipaPremium {
|
|
|
- prmiumLabel.stringValue = NSLocalizedString("Premium", comment: "")
|
|
|
- oneLicenseLabel.stringValue = NSLocalizedString("One license for one device. One time purchase.", comment: "")
|
|
|
- } else if productToType(originalProductID) == .ipaPermanent {
|
|
|
- prmiumLabel.stringValue = NSLocalizedString("Permanent version (with PDF to Office Pack)", comment: "")
|
|
|
- oneLicenseLabel.stringValue = NSLocalizedString("One license for one device. One time purchase.", comment: "")
|
|
|
- }
|
|
|
- aiAddOnButton.image = NSImage(named: "EmbeddedPayment06")
|
|
|
- aiAddOnLabel.stringValue = NSLocalizedString("AI Add-on", comment: "")
|
|
|
- aiAddOnLabel.textColor = NSColor(named: "KMPurchaseTitleColor")
|
|
|
- aiAddOnLabel.font = NSFont.SFProTextRegularFont(14.0)
|
|
|
- IndividualLabel.stringValue = NSLocalizedString("Individual monthly plan. Manually renew.", comment: "")
|
|
|
- IndividualLabel.textColor = NSColor(named: "KMPurchaseSubTitleColor")
|
|
|
- IndividualLabel.font = NSFont.SFProTextRegularFont(12.0)
|
|
|
- originalPriceLabel2.textColor = NSColor(named: "KMPurchaseTitleColor")
|
|
|
- originalPriceLabel2.font = NSFont.SFProTextRegularFont(16.0)
|
|
|
- discountPriceLabel2.textColor = NSColor(named: "KMPurchaseDiscountColor")
|
|
|
- discountPriceLabel2.font = NSFont.SFProTextRegularFont(9.0)
|
|
|
+ pdfReaderProLabel.stringValue = NSLocalizedString("PDF Reader Pro Standard - Annual Plan", comment: "")
|
|
|
|
|
|
- if originalProductID == "com.brother.pdfreaderpro.mac.product_3" {
|
|
|
- extendedLabel.stringValue = NSLocalizedString("Extended Device Access", comment: "")
|
|
|
- accessLabel.stringValue = NSLocalizedString("Get access to your plan on up to 2 devices.", comment: "")
|
|
|
- extendedImageView.isHidden = false
|
|
|
- } else {
|
|
|
- extendedLabel.stringValue = NSLocalizedString("PDF to Office Pack", comment: "")
|
|
|
- accessLabel.stringValue = NSLocalizedString("One time purchase", comment: "")
|
|
|
- extendedImageView.isHidden = true
|
|
|
- }
|
|
|
- extendedButton.image = NSImage(named: "EmbeddedPayment06")
|
|
|
- extendedLabel.textColor = NSColor(named: "KMPurchaseTitleColor")
|
|
|
- extendedLabel.font = NSFont.SFProTextRegularFont(14.0)
|
|
|
- accessLabel.textColor = NSColor(named: "KMPurchaseSubTitleColor")
|
|
|
- accessLabel.font = NSFont.SFProTextRegularFont(12.0)
|
|
|
- originalPriceLabel3.textColor = NSColor(named: "KMPurchaseTitleColor")
|
|
|
- originalPriceLabel3.font = NSFont.SFProTextRegularFont(16.0)
|
|
|
- discountPriceLabel3.textColor = NSColor(named: "KMPurchaseDiscountColor")
|
|
|
- discountPriceLabel3.font = NSFont.SFProTextRegularFont(9.0)
|
|
|
+ let tipsString = NSLocalizedString("%.2@/year, auto-renewal", comment: "")
|
|
|
+ let fullString = String(format: tipsString, product_Info.price)
|
|
|
+ prmiumLabel.stringValue = fullString
|
|
|
+
|
|
|
+
|
|
|
+ oneLicenseLabel.stringValue = NSLocalizedString("and more offline. It's one time purchase.", comment: "")
|
|
|
+ licenseCodeLabel.stringValue = NSLocalizedString("License Code", comment: "")
|
|
|
+ licenseCodeLabel.textColor = NSColor(named: "KMPurchaseTitleColor1")
|
|
|
+ licenseCodeLabel.font = NSFont.SFProTextRegularFont(14.0)
|
|
|
+ licenseCodeTextField.placeholderString = NSLocalizedString("Input license code previously activated the app", comment: "")
|
|
|
+ licenseCodeTextField.delegate = self
|
|
|
+ licenseCodeBox.borderColor = NSColor(named: "KMPurchase_DADBDE")!
|
|
|
+ licenseCodeBox.fillColor = NSColor(named: "KMPurchase_FFFFFF")!
|
|
|
+ notFoundButton.title = NSLocalizedString("Not Found?", comment: "")
|
|
|
+ notFoundButton.setTitleColor(color: NSColor(named: "KMPurchaseCouponColor")!, font: NSFont(name: "body-s-regular", size: 14))
|
|
|
+ licenseCodeTextField.stringValue = VerificationManager.default().originLicenseCode ?? ""
|
|
|
+ refreshLicenseCodeView(isReveal: true)
|
|
|
+ licenseCodeErrorLabel.stringValue = NSLocalizedString("Please enter right license code. How to Retrieve License.", comment: "")
|
|
|
+ licenseCodeErrorLabel.textColor = NSColor(named: "KMPurchaseErrorColor")
|
|
|
+ licenseCodeErrorLabel.font = NSFont.SFProTextRegularFont(11.0)
|
|
|
+ refreshLicenseCodeErrorView(isReveal: false)
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+// if productType == .ipaConvert || productType == .ipaAI {
|
|
|
+// aiAddOnView.isHidden = true
|
|
|
+// extendedView.isHidden = true
|
|
|
+//
|
|
|
+// if productType == .ipaConvert {
|
|
|
+// pdfReaderProLabel.stringValue = NSLocalizedString("PDF to Office", comment: "")
|
|
|
+// prmiumLabel.stringValue = NSLocalizedString("Export PDF to Word(.docx), Excel (.xlsx), PowerPoint(.pptx)", comment: "")
|
|
|
+// oneLicenseLabel.stringValue = NSLocalizedString("and more offline. It's one time purchase.", comment: "")
|
|
|
+// licenseCodeLabel.stringValue = NSLocalizedString("License Code", comment: "")
|
|
|
+// licenseCodeLabel.textColor = NSColor(named: "KMPurchaseTitleColor1")
|
|
|
+// licenseCodeLabel.font = NSFont.SFProTextRegularFont(14.0)
|
|
|
+// licenseCodeTextField.placeholderString = NSLocalizedString("Input license code previously activated the app", comment: "")
|
|
|
+// licenseCodeTextField.delegate = self
|
|
|
+// licenseCodeBox.borderColor = NSColor(named: "KMPurchase_DADBDE")!
|
|
|
+// licenseCodeBox.fillColor = NSColor(named: "KMPurchase_FFFFFF")!
|
|
|
+// notFoundButton.title = NSLocalizedString("Not Found?", comment: "")
|
|
|
+// notFoundButton.setTitleColor(color: NSColor(named: "KMPurchaseCouponColor")!, font: NSFont(name: "body-s-regular", size: 14))
|
|
|
+// licenseCodeTextField.stringValue = VerificationManager.default().originLicenseCode ?? ""
|
|
|
+// refreshLicenseCodeView(isReveal: true)
|
|
|
+// licenseCodeErrorLabel.stringValue = NSLocalizedString("Please enter right license code. How to Retrieve License.", comment: "")
|
|
|
+// licenseCodeErrorLabel.textColor = NSColor(named: "KMPurchaseErrorColor")
|
|
|
+// licenseCodeErrorLabel.font = NSFont.SFProTextRegularFont(11.0)
|
|
|
+// refreshLicenseCodeErrorView(isReveal: false)
|
|
|
+// } else if productType == .ipaAI {
|
|
|
+// pdfReaderProLabel.stringValue = NSLocalizedString("PDF Reader Pro AI Tools", comment: "")
|
|
|
+// prmiumLabel.stringValue = NSLocalizedString("50 credits for 30 days", comment: "")
|
|
|
+// oneLicenseLabel.stringValue = NSLocalizedString("Manually renew at USD 14.99", comment: "")
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// pdfReaderProLabel.stringValue = NSLocalizedString("PDF Reader Pro for Mac", comment: "")
|
|
|
+// if productToType(originalProductID) == .ipaPremium {
|
|
|
+// prmiumLabel.stringValue = NSLocalizedString("Premium", comment: "")
|
|
|
+// oneLicenseLabel.stringValue = NSLocalizedString("One license for one device. One time purchase.", comment: "")
|
|
|
+// } else if productToType(originalProductID) == .ipaPermanent {
|
|
|
+// prmiumLabel.stringValue = NSLocalizedString("Permanent version (with PDF to Office Pack)", comment: "")
|
|
|
+// oneLicenseLabel.stringValue = NSLocalizedString("One license for one device. One time purchase.", comment: "")
|
|
|
+// }
|
|
|
+// aiAddOnButton.image = NSImage(named: "EmbeddedPayment06")
|
|
|
+// aiAddOnLabel.stringValue = NSLocalizedString("AI Add-on", comment: "")
|
|
|
+// aiAddOnLabel.textColor = NSColor(named: "KMPurchaseTitleColor")
|
|
|
+// aiAddOnLabel.font = NSFont.SFProTextRegularFont(14.0)
|
|
|
+// IndividualLabel.stringValue = NSLocalizedString("Individual monthly plan. Manually renew.", comment: "")
|
|
|
+// IndividualLabel.textColor = NSColor(named: "KMPurchaseSubTitleColor")
|
|
|
+// IndividualLabel.font = NSFont.SFProTextRegularFont(12.0)
|
|
|
+// originalPriceLabel2.textColor = NSColor(named: "KMPurchaseTitleColor")
|
|
|
+// originalPriceLabel2.font = NSFont.SFProTextRegularFont(16.0)
|
|
|
+// discountPriceLabel2.textColor = NSColor(named: "KMPurchaseDiscountColor")
|
|
|
+// discountPriceLabel2.font = NSFont.SFProTextRegularFont(9.0)
|
|
|
+//
|
|
|
+// if originalProductID == "com.brother.pdfreaderpro.mac.product_3" {
|
|
|
+// extendedLabel.stringValue = NSLocalizedString("Extended Device Access", comment: "")
|
|
|
+// accessLabel.stringValue = NSLocalizedString("Get access to your plan on up to 2 devices.", comment: "")
|
|
|
+// extendedImageView.isHidden = false
|
|
|
+// } else {
|
|
|
+// extendedLabel.stringValue = NSLocalizedString("PDF to Office Pack", comment: "")
|
|
|
+// accessLabel.stringValue = NSLocalizedString("One time purchase", comment: "")
|
|
|
+// extendedImageView.isHidden = true
|
|
|
+// }
|
|
|
+// extendedButton.image = NSImage(named: "EmbeddedPayment06")
|
|
|
+// extendedLabel.textColor = NSColor(named: "KMPurchaseTitleColor")
|
|
|
+// extendedLabel.font = NSFont.SFProTextRegularFont(14.0)
|
|
|
+// accessLabel.textColor = NSColor(named: "KMPurchaseSubTitleColor")
|
|
|
+// accessLabel.font = NSFont.SFProTextRegularFont(12.0)
|
|
|
+// originalPriceLabel3.textColor = NSColor(named: "KMPurchaseTitleColor")
|
|
|
+// originalPriceLabel3.font = NSFont.SFProTextRegularFont(16.0)
|
|
|
+// discountPriceLabel3.textColor = NSColor(named: "KMPurchaseDiscountColor")
|
|
|
+// discountPriceLabel3.font = NSFont.SFProTextRegularFont(9.0)
|
|
|
+// }
|
|
|
removeButton1.isEnabled = false
|
|
|
amountTextField1.delegate = self
|
|
|
amountTextField2.isEditable = false
|
|
@@ -1166,6 +1240,32 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
|
|
|
|
|
|
// MARK: get & set
|
|
|
|
|
|
+ var product_Info: KMListingProductsModel {
|
|
|
+ get {
|
|
|
+ return _product_Info
|
|
|
+ }
|
|
|
+ set {
|
|
|
+ _product_Info = newValue
|
|
|
+ xibInitialization()
|
|
|
+ priceRefresh()
|
|
|
+
|
|
|
+ confirmPayment(isConfirm: false)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ var dmgProductType: KMDMGProductType {
|
|
|
+ get {
|
|
|
+ return _dmgProductType
|
|
|
+ }
|
|
|
+ set {
|
|
|
+ _dmgProductType = newValue
|
|
|
+ xibInitialization()
|
|
|
+ priceRefresh()
|
|
|
+
|
|
|
+ confirmPayment(isConfirm: false)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private var paymentMethod : KMPaymentType {
|
|
|
get {
|
|
|
return _paymentMethod
|