Procházet zdrojové kódy

【会员系统】- 整理Store免费、付费版本,从高级功能弹比较表类型

wangshuai před 3 měsíci
rodič
revize
007d858afa

+ 105 - 90
PDF Office/PDF Master/MemberCenter/Model/KMMemberInfo.swift

@@ -261,10 +261,12 @@ 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 {
+                IAPProductsManager.default().allAccessPack12months_lite.isSubscribed == true {
+                // 有旧订阅
+                return .lite_type12
+            } else if (IAPProductsManager.default().allAccessProduct.isSubscribed == true) {
                 // 有旧买断
                 if KMMemberInfo.shared.canTrail && KMMemberInfo.shared.vip_levels == "1" {
                     return .lite_type9
@@ -282,7 +284,7 @@ import Cocoa
                 }
                 return .lite_type9
             } else {
-                // 无旧买断
+                // 无旧订阅、买断
                 if KMMemberInfo.shared.canTrail && KMMemberInfo.shared.vip_levels == "1" {
                     return .lite_type1
                 }
@@ -511,101 +513,114 @@ import Cocoa
             .components(separatedBy: ",")
             .map { $0.trimmingCharacters(in: .whitespaces) }
         if KMMemberInfo.shared.isLogin {
-            if userScenarioType == .lite_type1 ||
-                userScenarioType == .lite_type3 ||
-                userScenarioType == .lite_type11 ||
-                userScenarioType == .lite_type4 ||
-                userScenarioType == .lite_type5 ||
-                userScenarioType == .lite_type9 ||
-                userScenarioType == .lite_type13 ||
-                userScenarioType == .lite_type7 || 
-                userScenarioType == .lite_type8 {
-                KMProductCompareWC.shared.orientation = true
-                if userScenarioType == .lite_type1 {
-                    KMProductCompareWC.shared.orientationType = .trial
-                } else if userScenarioType == .lite_type3 || userScenarioType == .lite_type11 {
-                    KMProductCompareWC.shared.orientationType = .lite_Base
-                } else if userScenarioType == .lite_type4 || userScenarioType == .lite_type5 || userScenarioType == .lite_type9 || userScenarioType == .lite_type13 {
-                    KMProductCompareWC.shared.orientationType = .lite_MacWindows
-                } else if userScenarioType == .lite_type7 || userScenarioType == .lite_type8 {
-                    if KMMemberInfo.shared.vip_paymentModel == "1" && KMMemberInfo.shared.vip_cycle == 4 && platformsArray.count == 4 {
-                        KMProductCompareWC.shared.orientationType = .lite_MacWindows
-                    } else {
-                        KMProductCompareWC.shared.orientationType = .lite_Base
-                    }
-                }
-                KMProductCompareWC.shared.showWindow(nil)
-            } else if userScenarioType == .lite_type2 || 
-                        userScenarioType == .lite_type6 ||
-                        userScenarioType == .lite_type10 ||
-                        userScenarioType == .lite_type12 ||
-                        userScenarioType == .pro_type2 ||
-                        userScenarioType == .pro_type5 {
-                
-            } else if userScenarioType == .pro_type1 ||
-                        userScenarioType == .pro_type3 ||
-                        userScenarioType == .pro_type4 {
-                KMProductCompareWC.shared.orientation = true
-                if userScenarioType == .pro_type1 ||
-                    userScenarioType == .pro_type4 {
-                    KMProductCompareWC.shared.orientationType = .pro_Advanced
-                } else if userScenarioType == .pro_type3 {
-                    KMProductCompareWC.shared.orientationType = .pro_Base
-                }
-                KMProductCompareWC.shared.showWindow(nil)
-            }
+            productCompareShow()
         } else {
             KMLoginWindowsController.shared.openWindow() { [weak self] success in
                 guard let self = self else { return }
                 if success {
-                    if self.userScenarioType == .lite_type1 ||
-                        self.userScenarioType == .lite_type3 ||
-                        self.userScenarioType == .lite_type11 ||
-                        self.userScenarioType == .lite_type4 ||
-                        self.userScenarioType == .lite_type5 ||
-                        self.userScenarioType == .lite_type9 ||
-                        self.userScenarioType == .lite_type13 ||
-                        self.userScenarioType == .lite_type7 ||
-                        self.userScenarioType == .lite_type8 {
-                        KMProductCompareWC.shared.orientation = true
-                        if self.userScenarioType == .lite_type1 {
-                            KMProductCompareWC.shared.orientationType = .trial
-                        } else if self.userScenarioType == .lite_type3 || self.userScenarioType == .lite_type11 {
-                            KMProductCompareWC.shared.orientationType = .lite_Base
-                        } else if self.userScenarioType == .lite_type4 || self.userScenarioType == .lite_type5 || self.userScenarioType == .lite_type9 || self.userScenarioType == .lite_type13 {
-                            KMProductCompareWC.shared.orientationType = .lite_MacWindows
-                        } else if self.userScenarioType == .lite_type7 || self.userScenarioType == .lite_type8 {
-                            if KMMemberInfo.shared.vip_paymentModel == "1" && KMMemberInfo.shared.vip_cycle == 4 && platformsArray.count == 4 {
-                                KMProductCompareWC.shared.orientationType = .lite_MacWindows
-                            } else {
-                                KMProductCompareWC.shared.orientationType = .lite_Base
-                            }
-                        }
-                        KMProductCompareWC.shared.showWindow(nil)
-                    } else if self.userScenarioType == .lite_type2 || 
-                                self.userScenarioType == .lite_type6 ||
-                                self.userScenarioType == .lite_type10 ||
-                                self.userScenarioType == .lite_type12 ||
-                                self.userScenarioType == .pro_type2 ||
-                                self.userScenarioType == .pro_type5{
-                        
-                    } else if self.userScenarioType == .pro_type1 ||
-                                self.userScenarioType == .pro_type3 ||
-                                self.userScenarioType == .pro_type4 {
-                        KMProductCompareWC.shared.orientation = true
-                        if self.userScenarioType == .pro_type1 ||
-                            self.userScenarioType == .pro_type4 {
-                            KMProductCompareWC.shared.orientationType = .pro_Advanced
-                        } else if self.userScenarioType == .pro_type3 {
-                            KMProductCompareWC.shared.orientationType = .pro_Base
-                        }
-                        KMProductCompareWC.shared.showWindow(nil)
-                    }
+                    productCompareShow()
                 }
             }
         }
     }
     
+    func productCompareShow() -> Void {
+        let platforms = KMMemberInfo.shared.vip_platforms
+        let platformsArray = platforms
+            .components(separatedBy: ",")
+            .map { $0.trimmingCharacters(in: .whitespaces) }
+#if VERSION_FREE
+#if VERSION_DMG
+    // DMG
+        
+#else
+    // AppStore 免费版本
+        KMProductCompareWC.shared.orientation = true
+        
+        // 无旧订阅、买断
+        if userScenarioType == .lite_type1 {
+            // 试用比较表
+            KMProductCompareWC.shared.orientationType = .trial
+        } else if userScenarioType == .lite_type3 ||
+                    userScenarioType == .lite_type7 {
+            // 购买比较表
+            KMProductCompareWC.shared.orientationType = .lite_Base
+        } else if userScenarioType == .lite_type5 {
+            // 升级比较表
+            // 有账号(单、多平台)高级永久权益,升级全平台权益
+            if platformsArray.count == 1 {
+                // 单平台升级
+                KMProductCompareWC.shared.orientationType = .lite_MacWindows
+            } else {
+                // 多平台升级
+                KMProductCompareWC.shared.orientationType = .lite_MacWindows
+            }
+        }
+        
+        // 有旧买断
+        if userScenarioType == .lite_type9 ||
+            userScenarioType == .lite_type11 {
+            // 升级比较表
+            if KMMemberInfo.shared.vip_paymentModel == "2" {
+                // 有账号(单、多平台)高级永久权益,升级全平台权益
+                if (platformsArray.count == 1) {
+                    // 单平台升级
+                    KMProductCompareWC.shared.orientationType = .lite_MacWindows
+                } else {
+                    // 多平台升级
+                    KMProductCompareWC.shared.orientationType = .lite_MacWindows
+                }
+            } else {
+                // 有本地单平台高级永久权益,升级全平台权益
+                KMProductCompareWC.shared.orientationType = .lite_MacWindows
+            }
+        }
+        
+        KMProductCompareWC.shared.showWindow(nil)
+#endif
+#else
+    // AppStore 付费版
+        KMProductCompareWC.shared.orientation = true
+        
+        // 无旧订阅
+        if userScenarioType == .pro_type3 {
+            // 升级比较表
+            // 有本地单平台标准永久权益,升级全平台、升级单平台高级权益
+            KMProductCompareWC.shared.orientationType = .pro_Base
+        } else if userScenarioType == .pro_type4 {
+            // 升级比较表
+            // 有账号(单、多平台)高级永久权益,升级全平台权益
+            if (platformsArray.count == 1) {
+                // 单平台升级
+                KMProductCompareWC.shared.orientationType = .pro_Advanced
+            } else {
+                // 多平台升级
+                KMProductCompareWC.shared.orientationType = .pro_Advanced
+            }
+        }
+        
+        // 有旧订阅
+        if userScenarioType = .pro_type1 {
+            // 升级比较表
+            if KMMemberInfo.shared.vip_paymentModel == "2" {
+                // 有账号(单、多平台)高级永久权益,升级全平台权益
+                if (platformsArray.count == 1) {
+                    // 单平台升级
+                    KMProductCompareWC.shared.orientationType = .pro_Advanced
+                } else {
+                    // 多平台升级
+                    KMProductCompareWC.shared.orientationType = .pro_Advanced
+                }
+            } else {
+                // 有本地单平台高级永久权益,升级全平台权益
+                KMProductCompareWC.shared.orientationType = .pro_Advanced
+            }
+        }
+        
+        KMProductCompareWC.shared.showWindow(nil)
+#endif
+    }
+    
     func aiSubscription() -> Bool {
         let oldAIPoints = AIInfoManager.default().aiInfo.totalToken - AIInfoManager.default().aiInfo.usedTimes // 旧版AI点数
         if oldAIPoints > 0 {