Browse Source

【综合】AI接会员权益

tangchao 3 months ago
parent
commit
4127400216

+ 3 - 0
PDF Office/PDF Master/AppDelegate.swift

@@ -208,6 +208,8 @@ class AppDelegate: NSObject, NSApplicationDelegate, iRateDelegate{
             KMHTTP.OEM_POST(urlString: kURLAPI_oemGetPermissions, parameter: nil, headers: header) { success, dataModel, err in
                 if success == false { // App 启动 Token 过期 退出登陆 & 解除设备绑定,需用户重新登陆再绑定
                     KMDataManager.ud_set("", forKey: kAccountTokenKey)
+                    AccountManager.manager.isVip = false
+                    AccountManager.manager.hasAiPermissions = false
                     VerificationManager.default().unactivateDeviceWithcomplention { status, infoDict, err in
                         VerificationManager.default().verification {status1 , infoDict1, err1 in
                             
@@ -217,6 +219,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, iRateDelegate{
                 }
                 let model = AccountRightModel(dict: dataModel?.data as? [String : Any] ?? [:])
                 AccountManager.manager.isVip = model.isVip == 1
+                AccountManager.manager.hasAiPermissions = model.hasAiPermissions == 1
             }
         }
     }

+ 2 - 1
PDF Office/PDF Master/Class/AIInfo/AIConfigWindowController/AINewConfigWindowController.swift

@@ -291,7 +291,8 @@ protocol AIConfigWindowDelegate: AnyObject {
     }
     
     func chooseAIFunctionWithType(_ aiConfigType: AIConfigType) -> Void {
-        if AIInfoManager.default().aiInfo.infoDict.keys.count == 0 {
+        if AccountManager.manager.hasAiPermissions == false {
+//        if AIInfoManager.default().aiInfo.infoDict.keys.count == 0 {
 #if VERSION_DMG
             KMPurchaseCompareWindowController.dmgPurchaseInstance().showWindow(nil)
 #else

+ 2 - 0
PDF Office/PDF Master/Class/Account/Controller/AccountProfileController.swift

@@ -179,6 +179,7 @@ class AccountProfileController: NSViewController {
                 let isVip = model.isVip
                 
                 AccountManager.manager.isVip = model.isVip == 1
+                AccountManager.manager.hasAiPermissions = model.hasAiPermissions == 1
                 if isVip == 1 {
                     self.showRight()
                 } else {
@@ -232,6 +233,7 @@ class AccountProfileController: NSViewController {
                             self?.view.window?.windowController?.km_quick_endSheet()
                             KMDataManager.ud_set("", forKey: kAccountTokenKey)
                             AccountManager.manager.isVip = false
+                            AccountManager.manager.hasAiPermissions = false
                         }
                     }
                 } else {

+ 2 - 0
PDF Office/PDF Master/Class/Account/Manager/AccountManager.swift

@@ -13,5 +13,7 @@ import Cocoa
     
     var isVip = false
     
+    var hasAiPermissions = false
+    
     var canUseAdvanceFlag = false
 }

+ 8 - 0
PDF Office/PDF Master/Class/Account/Model/AccountRightModel.swift

@@ -73,6 +73,12 @@ class AccountRightModel: NSObject {
     // 当前设备是否为Vip 0为否 1为是(如果用户只买了win的产品,mac端登录就为0)
     var isVip: Int = 0
     
+    // 当前是否有AI权益 0为无 1为有
+    var hasAiPermissions: Int = 0
+    
+    // AI购买链接
+    var aiBuyUrl: String = ""
+    
     // 有效权益记录
     var rightsInterestsData: [AccountRightInfoModel] = []
     
@@ -88,6 +94,8 @@ class AccountRightModel: NSObject {
         self.init()
         
         self.isVip = dict["isVip"] as? Int ?? 0
+        self.hasAiPermissions = dict["hasAiPermissions"] as? Int ?? 0
+        self.aiBuyUrl = dict["aiBuyUrl"] as? String ?? ""
         
         if let info = dict["trialData"] as? [String : Any] {
             self.trialData = AccountTrialModel(dict: info)

+ 3 - 0
PDF Office/PDF Master/Class/Account/Window/AccountCenterWindowController.swift

@@ -68,6 +68,7 @@ class AccountCenterWindowController: NSWindowController {
                 }
                 let model = AccountRightModel(dict: dataModel?.data as? [String : Any] ?? [:])
                 AccountManager.manager.isVip = model.isVip == 1
+                AccountManager.manager.hasAiPermissions = model.hasAiPermissions == 1
                 
                 self.gotoCenter(model: model, infoModel: nil)
             }
@@ -118,6 +119,7 @@ class AccountCenterWindowController: NSWindowController {
                     let rmodel = AccountRightModel(dict: dataModel?.data as? [String : Any] ?? [:])
                     
                     AccountManager.manager.isVip = rmodel.isVip == 1
+                    AccountManager.manager.hasAiPermissions = rmodel.hasAiPermissions == 1
                     self.gotoCenter(model: rmodel, infoModel: model)
                 }
             }
@@ -163,6 +165,7 @@ class AccountCenterWindowController: NSWindowController {
                     let rmodel = AccountRightModel(dict: dataModel?.data as? [String : Any] ?? [:])
                     
                     AccountManager.manager.isVip = rmodel.isVip == 1
+                    AccountManager.manager.hasAiPermissions = rmodel.hasAiPermissions == 1
                     self.gotoCenter(model: rmodel, infoModel: model)
                 }
             }

+ 6 - 0
PDF Office/PDF Master/Class/Purchase/DMG/Verification/VerificationManager/AIInfoManager.h

@@ -62,6 +62,12 @@ typedef void(^AIActivityComplention)(NSDictionary *info, NSError *error);
 
 @end
 
+#if VERSION_DMG
+@interface AIInfoManager (PDFull)
+
+@end
+#endif
+
 #if DEBUG
 @interface AIInfoManager (KMTest)
 

+ 12 - 0
PDF Office/PDF Master/Class/Purchase/DMG/Verification/VerificationManager/AIInfoManager.m

@@ -505,6 +505,18 @@ static AIInfoManager *__Manager = nil;
 
 @end
 
+#if VERSION_DMG
+
+@implementation AIInfoManager (PDFull)
+
+- (BOOL)aiInfoValid {
+    return AccountManager.manager.hasAiPermissions;
+}
+
+@end
+
+#endif
+
 #if DEBUG
 @implementation AIInfoManager (KMTest)