소스 검색

【综合】比较表、登陆新增购买类型

tangchao 3 달 전
부모
커밋
f389b4d123

+ 17 - 8
PDF Office/PDF Master/MemberCenter/Model/KMMemberInfo.swift

@@ -926,17 +926,26 @@ import Cocoa
         if KMMemberInfo.shared.isLogin {
             productCompareShow()
         } else {
-            KMLoginWindowsController.shared.openWindow() { [weak self] success in
-                guard let self = self else { return }
-                if success {
-                    if self.userScenarioType == .dmg_type16 ||
-                        self.userScenarioType == .dmg_type17 {
-                        
-                    } else {
-                        self.productCompareShow()
+            // 不是 AppStore 免费版
+            if KMIsAppStoreFreeVersion() == false {
+                KMLoginWindowsController.shared.openWindow() { [weak self] success in
+                    guard let self = self else { return }
+                    if success {
+                        if self.userScenarioType == .dmg_type16 ||
+                            self.userScenarioType == .dmg_type17 {
+                            
+                        } else {
+                            self.productCompareShow()
+                        }
                     }
                 }
+                return
             }
+            
+            // 是 AppStore 免费版
+            KMProductCompareWC.shared.orientation = true
+            KMProductCompareWC.shared.orientationType = .lite_Base
+            KMProductCompareWC.shared.openWindow(type: type)
         }
     }
     

+ 13 - 3
PDF Office/PDF Master/MemberCenter/View/KMSignUpView.swift

@@ -114,6 +114,8 @@ class KMSignUpView: KMBaseXibView {
     var signFinishBlock: KMCommonBlock?
     var buyBlock: KMCommonBlock?
     
+    var type: KMSubscribeWaterMarkType?
+    
     convenience init(model: KMSignUpViewModel, superView: NSView) {
         self.init(frame: superView.bounds)
         viewModel = model
@@ -281,9 +283,17 @@ class KMSignUpView: KMBaseXibView {
             self?.buyBlock?()
         }
         
-        self.topConst.constant = 25
-        self.bottomConst.constant = 68
-        self.checkTopConst.constant = 10
+        if let _ = type {
+            buyView_.isHidden = false
+            self.topConst.constant = 25
+            self.bottomConst.constant = 68
+            self.checkTopConst.constant = 10
+        } else {
+            buyView_.isHidden = true
+            self.topConst.constant = 46
+            self.bottomConst.constant = 47
+            self.checkTopConst.constant = 20
+        }
 #endif
 #endif
         

+ 1 - 1
PDF Office/PDF Master/MemberCenter/ViewModel/KMProductModel.swift

@@ -986,7 +986,7 @@ class KMProductModel: ObservableObject {
             if let info = KMAdvertisementManager.manager.info.StoreUserRecovery?.content?.first, !(info.show! as NSString).boolValue {
                 return false
             }
-            if let discounts = manager?.fourDevicesAllAccessPackNew12months_lite.product.discounts, discounts.count <= 0 {
+            if let discounts = manager?.fourDevicesAllAccessPackNew12months_lite.product?.discounts, discounts.count <= 0 {
                 return false
             }
 #endif

+ 19 - 0
PDF Office/PDF Master/MemberCenter/WindowsController/KMLoginWindowsController.swift

@@ -26,6 +26,13 @@ class KMLoginWindowsController: NSWindowController {
     
     var loginResult: LoginResultComplete?
     
+    private var subscribeType_: KMSubscribeWaterMarkType?
+    var subscribeType: KMSubscribeWaterMarkType? {
+        get {
+            return subscribeType_
+        }
+    }
+    
     private var viewModel = KMSignUpViewModel()
     private var cancellables = Set<AnyCancellable>()
 
@@ -59,6 +66,8 @@ class KMLoginWindowsController: NSWindowController {
     override func showWindow(_ sender: Any?) {
         super.showWindow(sender)
         
+        subscribeType_ = nil
+        signUpView?.type = nil
         _trackSignInEvent(params: ["Exposure" : "Exposure_Signin"])
         
         loginResult = nil
@@ -190,6 +199,16 @@ class KMLoginWindowsController: NSWindowController {
         loginResult = complete
     }
     
+    func newOpenWindow(type: KMSubscribeWaterMarkType?, _ complete: @escaping LoginResultComplete) -> Void {
+        openWindow(complete)
+        
+        subscribeType_ = type
+        signUpView?.type = type
+        DispatchQueue.main.async {
+            self.signUpView?.updateUI()
+        }
+    }
+    
     // MARK: - Actions
     
     @objc func closeAction() {

+ 30 - 5
PDF Office/PDF Master/MemberCenter/WindowsController/KMProductCompareWC.swift

@@ -143,6 +143,13 @@ class KMProductCompareWC: NSWindowController {
     private var model = KMProductModel.shared
     private var cancellables = Set<AnyCancellable>()
     
+    private var subscribeType_: KMSubscribeWaterMarkType?
+    var subscribeType: KMSubscribeWaterMarkType? {
+        get {
+            return subscribeType_
+        }
+    }
+    
     var orientation: Bool = false // 是否定向跳转
     var orientationType: KMCompareTableType = .trial // 定向跳转比较表
     
@@ -333,6 +340,7 @@ class KMProductCompareWC: NSWindowController {
     @objc override func showWindow(_ sender: Any?) {
         super.showWindow(sender)
         
+        subscribeType_ = nil
         _trackComparisonEvent(params: ["Exposure" : "ComparisonTable_Exposure"])
         
         alertingCodeForRefreshUserInfo_ = nil
@@ -359,6 +367,12 @@ class KMProductCompareWC: NSWindowController {
         
         comparativeStatementHead()
     }
+    
+    func openWindow(type: KMSubscribeWaterMarkType) {
+        showWindow(nil)
+        
+        subscribeType_ = type
+    }
 
     // MARK: - Private Methods
     
@@ -1180,7 +1194,7 @@ class KMProductCompareWC: NSWindowController {
 #else
     // AppStore 免费版本
 
-        if model.checkSubscriptionOffer(for: IAPProductsManager.default().fourDevicesAllAccessPackNew12months_lite.product) == .freeTrial {
+        if let product = IAPProductsManager.default().fourDevicesAllAccessPackNew12months_lite.product, model.checkSubscriptionOffer(for: product) == .freeTrial {
             
         }
 #endif
@@ -1201,6 +1215,12 @@ class KMProductCompareWC: NSWindowController {
     // MARK: Button Actions
     
     @IBAction func buttonItemClicked_Subscribe(_ sender: Any) {
+        if KMIsAppStoreFreeVersion() && subscribeType != nil && KMMemberInfo.shared.isLogin == false { // AppStore 免费版 + 付费功能进入 + 未登陆,跳转登陆
+            KMLoginWindowsController.shared.newOpenWindow(type: subscribeType) { success in
+                
+            }
+            return
+        }
         if KMMemberInfo.shared.validFlag == "5" {
             KMMemberPromptWC.shared.showWindow(nil)
             KMMemberPromptWC.shared.tipType = .signouting
@@ -1320,10 +1340,15 @@ class KMProductCompareWC: NSWindowController {
 #if !VERSION_DMG
         addWaitingView(to: window?.contentView ?? NSView())
 #endif
-        model.appstorePurchaseAction(sender.tag) { [weak self] success, msg in
-            guard let self = self else { return }
-            
-        }
+            if KMIsAppStoreFreeVersion() && subscribeType != nil && KMMemberInfo.shared.isLogin == false { // AppStore 免费版 + 付费功能进入 + 未登陆,跳转登陆
+                KMLoginWindowsController.shared.newOpenWindow(type: subscribeType) { success in
+                    
+                }
+                return
+            }
+            model.appstorePurchaseAction(sender.tag) { [weak self] success, msg in
+                guard let self = self else { return }
+            }
 #if VERSION_DMG
         close()
 #endif