Ver Fonte

Merge branch 'develop_PDFReaderPro_V4.7.0' of git.kdan.cc:Mac_PDF/PDF_Office into develop_PDFReaderPro_V4.7.0

zenghong há 1 semana atrás
pai
commit
602b863e85

+ 2 - 0
PDF Office/PDF Master/MemberCenter/Assets/en.lproj/MemberCenterLocalizable.strings

@@ -104,3 +104,5 @@
 "Subscribe to All Access Pack to Enjoy More Expanded Features" = "Subscribe to All Access Pack to Enjoy More Expanded Features";
 "Auto-renewal | Billed yearly" = "Auto-renewal | Billed yearly";
 "(Tax Incl.)" = "(Tax Incl.)";
+"6-Month Plan" = "6-Month Plan";
+"Monthly Plan" = "Monthly Plan";

+ 2 - 0
PDF Office/PDF Master/MemberCenter/Assets/zh-Hans.lproj/MemberCenterLocalizable.strings

@@ -100,3 +100,5 @@
 "Subscribe to All Access Pack to Enjoy More Expanded Features" = "升级会员套餐解锁更多功能";
 "Auto-renewal | Billed yearly" = "自动续费 | 年订阅";
 "(Tax Incl.)" = "(含税)";
+"6-Month Plan" = "半年订阅";
+"Monthly Plan" = "月订阅";

+ 3 - 0
PDF Office/PDF Master/MemberCenter/Assets/zh-Hant.lproj/MemberCenterLocalizable.strings

@@ -100,3 +100,6 @@
 "Subscribe to All Access Pack to Enjoy More Expanded Features" = "升級會員套餐解鎖更多功能";
 "Auto-renewal | Billed yearly" = "自動續費 | 年訂閱";
 "(Tax Incl.)" = "(含稅)";
+
+"6-Month Plan" = "半年訂閱";
+"Monthly Plan" = "月訂閱";

+ 9 - 10
PDF Office/PDF Master/MemberCenter/KMMemberCenterConfig.swift

@@ -9,15 +9,14 @@ import Cocoa
 
 class KMMemberCenterConfig: NSObject {
     func activityBaseURL() -> String {
-//        #if DEBUG
-//        if kTestMode == 1{
-//            return "http://test-store.kdan.cn:3019"
-//        } else {
-//            return "https://store.filmagepro.com:3018"
-//        }
-//        #else
-//        return "https://store.filmagepro.com:3018"
-//        #endif
-        return "http://139.196.160.101:8081"
+        #if DEBUG
+        if kTestMode == 1{
+            return "http://139.196.160.101:8081"
+        } else {
+            return "https://test-pdf-pro.kdan.cn"
+        }
+        #else
+        return "https://test-pdf-pro.kdan.cn"
+        #endif
     }
 }

+ 44 - 9
PDF Office/PDF Master/MemberCenter/Model/KMMemberInfo.swift

@@ -35,11 +35,22 @@ import Cocoa
     case lite_old
 }
 
+// 当前注销状态
+@objc enum KMCurrentLogoutStatus : Int {
+    case null = 0  //
+    case prompt_unsubscribe
+    case prompt_signout
+    case closeAccount
+    case closeVerification
+    case closeApply
+}
+
 @objcMembers class KMMemberInfo: NSObject {
     
     static let shared = KMMemberInfo()
     
     var isLogin: Bool = false
+    var currentLogoutStatus: KMCurrentLogoutStatus = .null
     
     /**
      登录
@@ -250,7 +261,7 @@ import Cocoa
             }
 #else
     // AppStore 免费版本
-            if IAPProductsManager.default().allAccessPack6months_lite.isSubscribed == true || 
+            if IAPProductsManager.default().allAccessPack6months_lite.isSubscribed == true ||
                 IAPProductsManager.default().allAccessPackNew6months_lite.isSubscribed == true ||
                 IAPProductsManager.default().allAccessPack12months_lite.isSubscribed == true ||
                 IAPProductsManager.default().allAccessProduct.isSubscribed == true {
@@ -262,7 +273,8 @@ import Cocoa
                     return .lite_type10
                 } else if KMMemberInfo.shared.vip_status == 4 {
                     return .lite_type11
-                } else if(KMMemberInfo.shared.vip_status == 1) {
+                } else if(KMMemberInfo.shared.vip_status == 1 && KMMemberInfo.shared.vip_paymentModel == "1") {
+                    // 订阅中
                     return .lite_type12
                 }
                 if KMMemberInfo.shared.vip_paymentModel == "1" && KMMemberInfo.shared.vip_payType == 0 {
@@ -333,7 +345,19 @@ import Cocoa
                 if IAPProductsManager.default().isAvailableAllFunction() == true {
                     return true
                 } else {
-                    if userScenarioType == .lite_type2 || userScenarioType == .lite_type4 || userScenarioType == .lite_type5 || userScenarioType == .lite_type6 {
+                    let platforms = KMMemberInfo.shared.vip_platforms
+                    let platformsArray = platforms
+                        .components(separatedBy: ",")
+                        .map { $0.trimmingCharacters(in: .whitespaces) }
+
+                    if userScenarioType == .lite_type5 ||
+                        userScenarioType == .lite_type4 {
+                        if(platformsArray.contains("mac")) {
+                            return true
+                        }
+                        
+                    } else if userScenarioType == .lite_type2 ||
+                                userScenarioType == .lite_type6 {
                         return true
                     }
                     return false
@@ -369,14 +393,24 @@ import Cocoa
                 if IAPProductsManager.default().isAvailableAdvancedPDFToOffice() {
                     return true
                 } else {
-                    if userScenarioType == .lite_type4 || 
-                        userScenarioType == .lite_type5 ||
-                        userScenarioType == .lite_type6 ||
-                        userScenarioType == .lite_type12 {
+                    let platforms = KMMemberInfo.shared.vip_platforms
+                    let platformsArray = platforms
+                        .components(separatedBy: ",")
+                        .map { $0.trimmingCharacters(in: .whitespaces) }
+
+                    if(userScenarioType == .lite_type2) {
                         return true
-                    } else {
-                        return false
+                    } else if userScenarioType == .lite_type5 ||
+                        userScenarioType == .lite_type4 {
+                        if(platformsArray.contains("mac")) { //购买了
+                            return true
+                        }
+                    } else if userScenarioType == .lite_type6 || userScenarioType == .lite_type12 {
+                        if KMMemberInfo.shared.vip_levels == "3" { //高级版本支持转档功能
+                            return true
+                        }
                     }
+                    return false
                 }
             } else {
                 if IAPProductsManager.default().isAvailableAdvancedPDFToOffice() {
@@ -444,6 +478,7 @@ import Cocoa
             return false
         }
     }
+
     
     // MARK: Public Method
     

+ 2 - 2
PDF Office/PDF Master/MemberCenter/View/KMSignUpView.xib

@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="23504" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22505" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
     <dependencies>
         <deployment identifier="macosx"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="23504"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22505"/>
         <capability name="Named colors" minToolsVersion="9.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>

+ 13 - 5
PDF Office/PDF Master/MemberCenter/ViewModel/KMSignUpViewModel.swift

@@ -168,7 +168,7 @@ class KMSignUpViewModel: ObservableObject {
     /**
      @abstract 刷新用户个人信息
      */
-    private func refreshUserInfo() -> Void {
+    private func refreshUserInfo(callback: ((Bool?, Any ...)->Void)?) -> Void {
         if KMMemberCenterManager.manager.isConnectionAvailable() == false {
             let alert = NSAlert()
             alert.alertStyle = .critical
@@ -176,9 +176,13 @@ class KMSignUpViewModel: ObservableObject {
             alert.informativeText = NSLocalizedString("Please make sure your internet connection is available.", comment: "")
             alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
             alert.runModal()
+            
+            callback?(nil)
             return
         }
-        KMUserInfoVCModel().refreshUserInfo { success, msg in
+        
+        KMUserInfoVCModel().refreshUserInfo(networkAlert: false) { success, msg in
+            callback?(success)
             if success {
                 KMMemberInfo.shared.isLogin = true
                 NotificationCenter.default.post(name: NSNotification.Name(rawValue: "MemberCenterLoginSuccess"), object: nil)
@@ -245,8 +249,6 @@ class KMSignUpViewModel: ObservableObject {
             return
         }
         KMMemberCenterManager.manager.emailLogin(email: email, code: code, type: signUpState) { [weak self] success, wrapper  in
-            callback?(success)
-            
             guard let self = self else { return }
             let resultDict = wrapper! as KMMemberCenterResult
             let msg = resultDict.msg
@@ -269,7 +271,7 @@ class KMSignUpViewModel: ObservableObject {
                 KMMemberInfo.shared.refresh_token = refresh_token!
                 KMMemberInfo.shared.access_token = access_token!
                 KMMemberInfo.shared.token_type = token_type!
-                self.refreshUserInfo()
+                self.refreshUserInfo(callback: callback)
                 
                 self.timer?.cancel()
                 self.sendContent = NSLocalizedString("Resend", tableName: "MemberCenterLocalizable", comment: "")
@@ -283,9 +285,13 @@ class KMSignUpViewModel: ObservableObject {
                         alert.informativeText = NSLocalizedString("Please make sure your internet connection is available.", comment: "")
                         alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
                         alert.runModal()
+                        
+                        callback?(false)
                         return
                     }
                     KMMemberCenterManager.manager.getUserDeviceList(email: self.email) { [weak self] success, result in
+                        callback?(false)
+                        
                         guard self != nil else { return }
                         if success {
                             KMMemberCenterWindowController.shared.showWindow(nil)
@@ -293,6 +299,8 @@ class KMSignUpViewModel: ObservableObject {
                         }
                     }
                 } else {
+                    callback?(false)
+                    
                     print("错误信息:%@", msg as Any)
                     let alert = NSAlert()
                     alert.messageText = NSLocalizedString(msg!, comment: "")

+ 2 - 2
PDF Office/PDF Master/MemberCenter/ViewModel/KMUserInfoVCModel.swift

@@ -22,8 +22,8 @@ class KMUserInfoVCModel: ObservableObject {
      @abstract 刷新个人权益
      @param
      */
-    func refreshUserInfo(_ complete: @escaping UserInfoComplete) -> Void {
-        if KMMemberCenterManager.manager.isConnectionAvailable() == false {
+    func refreshUserInfo(networkAlert: Bool = true ,_ complete: @escaping UserInfoComplete) -> Void {
+        if KMMemberCenterManager.manager.isConnectionAvailable() == false && networkAlert {
             let alert = NSAlert()
             alert.alertStyle = .critical
             alert.messageText = NSLocalizedString("Error Information", comment: "")

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

@@ -49,8 +49,19 @@ class KMLoginWindowsController: NSWindowController {
         NotificationCenter.default.addObserver(self, selector: #selector(loginSuccessNotification), name: NSNotification.Name(rawValue: "MemberCenterLoginSuccess"), object: nil)
         
         NotificationCenter.default.addObserver(self, selector: #selector(logoutSuccessNotification), name: NSNotification.Name(rawValue: "MemberCenterLogoutSuccess"), object: nil)
+        
+        rightBox.addObserver(self, forKeyPath: "contentView", options: [.new, .old], context: nil)
+    }
+    
+    override func showWindow(_ sender: Any?) {
+        super.showWindow(sender)
+        
+        initializeUI()
     }
     
+    deinit {
+        rightBox.removeObserver(self, forKeyPath: "contentView")
+    }
     
     // MARK: Private Action
     
@@ -140,4 +151,21 @@ class KMLoginWindowsController: NSWindowController {
             .store(in: &cancellables)
         
     }
+    
+    override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
+        if keyPath == "contentView" {
+            if let newContentView = change?[.newKey] as? NSView {
+                if newContentView is KMSignUpView {
+                    viewModel.screenType = .signUp
+                } else if newContentView is KMForgotPasswordView {
+                    viewModel.screenType = .forgotPassword
+                } else if newContentView is KMEnterVerificationCodeView {
+                    viewModel.screenType = .enterVerificationCode
+                } else if newContentView is KMEnterNewPasswordView {
+                    viewModel.screenType = .enterNewPassword
+                }
+                refreshSplitView()
+            }
+        }
+    }
 }