Ver código fonte

【综合】功能串接

tangchao 4 meses atrás
pai
commit
734bae0c46

+ 33 - 3
PDF Office/PDF Master/Class/Account/Controller/AccountProfileController.swift

@@ -113,8 +113,14 @@ class AccountProfileController: NSViewController {
         self.logoutButton.target = self
         self.logoutButton.action = #selector(logoutAction)
         
-        self.nameLabel.stringValue = userInfoModel?.first_name ?? ""
-        self.tipLabel.stringValue = NSLocalizedString("You have tried it for 6 days.", comment: "")
+        self.nameLabel.stringValue = String(format: NSLocalizedString("Hi,%@", comment: ""), userInfoModel?.first_name ?? "")
+        let status = self.model?.trialData?.status ?? 0
+        if status == 1 {
+            self.tipLabel.isHidden = false
+            self.tipLabel.stringValue = String(format: NSLocalizedString("You have tried it for %d days.", comment: ""), self.model?.trialData?.triedDay ?? 0)
+        } else {
+            self.tipLabel.isHidden = true
+        }
         
         let isVip = model?.isVip ?? 0
         if isVip == 1 {
@@ -122,6 +128,8 @@ class AccountProfileController: NSViewController {
         } else {
             self.showBenefit()
         }
+        
+        self.activateDevice()
     }
     
     func showBenefit() {
@@ -165,6 +173,8 @@ class AccountProfileController: NSViewController {
                 } else {
                     self.showBenefit()
                 }
+                
+                self.activateDevice()
             }
         }
     }
@@ -237,7 +247,7 @@ class AccountProfileController: NSViewController {
             }
             self?.unSubwinC_?.window?.orderOut(nil)
             self?.unSubwinC_ = nil
-            if idx == 2 {
+            if idx == 1 {
                 KMTools.openURL(urlString: kCancelSubscriptionUrlString)
                 return
             }
@@ -292,4 +302,24 @@ class AccountProfileController: NSViewController {
     func hideLoading() {
         self.loadingView_.removeFromSuperview()
     }
+    
+    func activateDevice() {
+        if IAPProductsManager.default().isAvailableAllFunction() {
+            return
+        }
+        
+        var licence: String?
+        for model in self.model?.rightsInterestsData ?? [] {
+            if let data = model.product_code, data.isEmpty == false {
+                licence = data
+                break
+            }
+        }
+        
+        if let data = licence {
+            VerificationManager.default().activateDevice(withInfo: ["cdkey" : data]) { status, info, err in
+                KMPrint("")
+            }
+        }
+    }
 }

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

@@ -50,12 +50,12 @@ extension AccountRightController: NSTableViewDelegate, NSTableViewDataSource {
             }
 
             if row == 0 {
-                cell?.titleLabel.stringValue = NSLocalizedString("Rights and interests", comment: "")
+                cell?.titleLabel.stringValue = NSLocalizedString("Rights and Interests", comment: "")
             } else {
                 cell?.titleLabel.stringValue = NSLocalizedString("Expired Benefits", comment: "")
             }
             
-            cell?.moreButton.title = NSLocalizedString("Get More benefits", comment: "") + " >"
+            cell?.moreButton.title = NSLocalizedString("Get Benefits", comment: "") + " >"
             cell?.moreButton.isHidden = row != 0
             cell?.moreButton.setTitleColor(KMAppearance.themeColor())
             

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

@@ -7,6 +7,23 @@
 
 import Cocoa
 
+class AccountTrialModel: NSObject {
+    // 试用状态 0为试用已过期 1为试用中
+    var status: Int = 0
+    // 已试用天数
+    var triedDay: Int = 0
+    // 试用产品序列码
+    var product_code: String?
+    
+    convenience init(dict: [String : Any]) {
+        self.init()
+        
+        self.status = dict["status"] as? Int ?? 0
+        self.triedDay = dict["triedDay"] as? Int ?? 0
+        self.product_code = dict["product_code"] as? String
+    }
+}
+
 class AccountRightInfoModel: NSObject {
     // 权益产品名称
     var name: String?
@@ -30,6 +47,9 @@ class AccountRightInfoModel: NSObject {
     // 购买链接
     var buy_url: String?
     
+    // 产品序列码
+    var product_code: String?
+    
     convenience init(dict: [String : Any]) {
         self.init()
         
@@ -44,6 +64,8 @@ class AccountRightInfoModel: NSObject {
         self.total_num = dict["total_num"] as? Int ?? 0
         self.surplus_num = dict["surplus_num"] as? Int ?? 0
         self.buy_url = dict["buy_url"] as? String
+        
+        self.product_code = dict["product_code"] as? String
     }
 }
 
@@ -60,11 +82,17 @@ class AccountRightModel: NSObject {
     // 更多权益产品购买数据
     var moreBenefits: [ProductListModel] = []
     
+    var trialData: AccountTrialModel?
+    
     convenience init(dict: [String : Any]) {
         self.init()
         
         self.isVip = dict["isVip"] as? Int ?? 0
         
+        if let info = dict["trialData"] as? [String : Any] {
+            self.trialData = AccountTrialModel(dict: info)
+        }
+        
         if let array = dict["rightsInterestsData"] as? [Any] {
             var datas: [AccountRightInfoModel] = []
             for data in array {

+ 4 - 4
PDF Office/PDF Master/Class/Account/View/AccountRightCellView.swift

@@ -152,14 +152,14 @@ class AccountRightCellView: NSTableCellView {
                 self.button_.title = NSLocalizedString("Cancel Subscription", comment: "")
                 self.button_.setTitleColor(NSColor(hex: "#666666"))
                 
-                self.expireDatelabel_.attributedStringValue = .init(string: NSLocalizedString("Expires: ", comment: "") + expireTime)
+                self.expireDatelabel_.attributedStringValue = .init(string: NSLocalizedString("Expires:", comment: "") + expireTime)
             } else if status == 2 {
                 self.button_.layer?.borderWidth = 0
                 self.button_.layer?.backgroundColor = KMAppearance.themeColor().cgColor
                 self.button_.title = NSLocalizedString("Renew", comment: "")
                 self.button_.setTitleColor(.white)
                 
-                var attri = NSMutableAttributedString(string: NSLocalizedString("Expires: ", comment: ""))
+                var attri = NSMutableAttributedString(string: NSLocalizedString("Expires:", comment: ""))
                 attri.append(.init(string: expireTime, attributes: [.foregroundColor : NSColor(hex: "#FF0000")]))
                 self.expireDatelabel_.attributedStringValue = attri
                 
@@ -173,7 +173,7 @@ class AccountRightCellView: NSTableCellView {
             let num = self.model?.surplus_num ?? 0
             let totalNum = self.model?.total_num ?? 0
             if isSubscribing {
-                var attri = NSMutableAttributedString(string: NSLocalizedString("Device Available: ", comment: ""))
+                var attri = NSMutableAttributedString(string: NSLocalizedString("Device", comment: "")+NSLocalizedString("Available:", comment: ""))
  
                 if num <= 0 {
                     attri.append(.init(string: "\(num)/\(totalNum)", attributes: [.foregroundColor : NSColor(hex: "#FF0000")]))
@@ -187,7 +187,7 @@ class AccountRightCellView: NSTableCellView {
                 self.button_.isHidden = false
                 self.statelabel_.isHidden = false
             } else {
-                self.devicelabel_.attributedStringValue = .init(string: NSLocalizedString("Device Available: ", comment: "") + "\(num)/\(totalNum)", attributes: [.foregroundColor : NSColor(hex: "#333333").withAlphaComponent(0.3)])
+                self.devicelabel_.attributedStringValue = .init(string: NSLocalizedString("Device", comment: "") + NSLocalizedString("Available:", comment: "") + "\(num)/\(totalNum)", attributes: [.foregroundColor : NSColor(hex: "#333333").withAlphaComponent(0.3)])
             }
         }
     }

+ 2 - 2
PDF Office/PDF Master/Strings/ar.lproj/Localizable.strings

@@ -4764,8 +4764,8 @@
 "Unable to connect to server, please check your connection."="Não é possível conectar-se ao servidor, verifique sua conexão.";
 "The account doesn't exist."="A conta não existe.";
 "Your password has been changed. Please login again."="Sua senha foi alterada. Faça login novamente.";
-"Hi,XXX"="Oi,XXX";
-"You have tried it for 6 days."="Você tentou por 6 dias.";
+"Hi,%@"="Oi,%@";
+"You have tried it for %d days."="Você tentou por %d dias.";
 "Purchase and unlock all features"="Compre e desbloqueie todos os recursos";
 "Win+Mac"="Win+Mac";
 "Win"="Win";

+ 2 - 2
PDF Office/PDF Master/Strings/de.lproj/Localizable.strings

@@ -3133,8 +3133,8 @@
 "Unable to connect to server, please check your connection."="Die Verbindung zum Server kann nicht hergestellt werden, bitte überprüfen Sie Ihre Verbindung.";
 "The account doesn't exist."="Das Konto existiert nicht.";
 "Your password has been changed. Please login again."="Ihr Passwort wurde geändert. Bitte melden Sie sich erneut an.";
-"Hi,XXX"="Hallo, XXXX";
-"You have tried it for 6 days."="Sie haben es 6 Tage lang ausprobiert.";
+"Hi,%@"="Hallo, %@";
+"You have tried it for %d days."="Sie haben es %d Tage lang ausprobiert.";
 "Purchase and unlock all features"="Kaufen und alle Funktionen freischalten";
 "Win+Mac"="Win+Mac";
 "Win"="Win";

+ 2 - 2
PDF Office/PDF Master/Strings/en.lproj/Localizable.strings

@@ -4296,8 +4296,8 @@
 "Unable to connect to server, please check your connection."="Unable to connect to server, please check your connection.";
 "The account doesn't exist."="The account doesn't exist.";
 "Your password has been changed. Please login again."="Your password has been changed. Please login again.";
-"Hi,XXX"="Hi,XXX";
-"You have tried it for 6 days."="You have tried it for 6 days.";
+"Hi,%@"="Hi,%@";
+"You have tried it for %d days."="You have tried it for %d days.";
 "Purchase and unlock all features"="Purchase and unlock all features";
 "Win+Mac"="Win+Mac";
 "Win"="Win";

+ 2 - 2
PDF Office/PDF Master/Strings/es.lproj/Localizable.strings

@@ -3215,8 +3215,8 @@
 "Unable to connect to server, please check your connection."="No se puede conectar al servidor, por favor compruebe su conexión.";
 "The account doesn't exist."="La cuenta no existe.";
 "Your password has been changed. Please login again."="Su contraseña ha sido cambiada. Por favor, conéctese de nuevo.";
-"Hi,XXX"="Hola,XXX";
-"You have tried it for 6 days."="Lo has probado durante 6 días.";
+"Hi,%@"="Hola,%@";
+"You have tried it for %d days."="Lo has probado durante %d días.";
 "Purchase and unlock all features"="Compra y desbloquea todas las funciones";
 "Win+Mac"="Win+Mac";
 "Win"="Win";

+ 2 - 2
PDF Office/PDF Master/Strings/fr.lproj/Localizable.strings

@@ -3095,8 +3095,8 @@
 "Unable to connect to server, please check your connection."="Impossible de se connecter au serveur, veuillez vérifier votre connexion.";
 "The account doesn't exist."="Le compte n'existe pas.";
 "Your password has been changed. Please login again."="Votre mot de passe a été modifié. Veuillez vous connecter à nouveau.";
-"Hi,XXX"="Bonjour,XXX";
-"You have tried it for 6 days."="Vous avez essayé pendant 6 jours.";
+"Hi,%@"="Bonjour,%@";
+"You have tried it for %d days."="Vous avez essayé pendant %d jours.";
 "Purchase and unlock all features"="Acheter et débloquer toutes les fonctionnalités";
 "Win+Mac"="Win+Mac";
 "Win"="Win";

+ 2 - 2
PDF Office/PDF Master/Strings/it.lproj/Localizable.strings

@@ -3012,8 +3012,8 @@
 "Unable to connect to server, please check your connection."="Impossibile connettersi al server, verificare la connessione.";
 "The account doesn't exist."="L'account non esiste.";
 "Your password has been changed. Please login again."="La password è stata modificata. Effettuare nuovamente il login.";
-"Hi,XXX"="Ciao,XXX";
-"You have tried it for 6 days."="Hai provato per 6 giorni.";
+"Hi,%@"="Ciao,%@";
+"You have tried it for %d days."="Hai provato per %d giorni.";
 "Purchase and unlock all features"="Acquista e sblocca tutte le funzioni";
 "Win+Mac"="Win+Mac";
 "Win"="Win";

+ 2 - 2
PDF Office/PDF Master/Strings/ja.lproj/Localizable.strings

@@ -3290,8 +3290,8 @@
 "Unable to connect to server, please check your connection."="サーバーに接続できません。接続を確認してください。";
 "The account doesn't exist."="アカウントが存在しません。";
 "Your password has been changed. Please login again."="パスワードが変更されました。もう一度ログインしてください。";
-"Hi,XXX"="こんにちは,XXXX";
-"You have tried it for 6 days."="あなたは6日間試してみました。";
+"Hi,%@"="こんにちは,%@";
+"You have tried it for %d days."="あなたは%d日間試してみました。";
 "Purchase and unlock all features"="購入し、すべての機能をアンロックする";
 "Win+Mac"="Win+Mac";
 "Win"="Win";

+ 2 - 2
PDF Office/PDF Master/Strings/nl.lproj/Localizable.strings

@@ -3171,8 +3171,8 @@
 "Unable to connect to server, please check your connection."="Kan geen verbinding maken met de server, controleer uw verbinding.";
 "The account doesn't exist."="De account bestaat niet.";
 "Your password has been changed. Please login again."="Uw wachtwoord is gewijzigd. Log opnieuw in.";
-"Hi,XXX"="Hallo,XXX";
-"You have tried it for 6 days."="Je hebt het 6 dagen geprobeerd.";
+"Hi,%@"="Hallo,%@";
+"You have tried it for %d days."="Je hebt het %d dagen geprobeerd.";
 "Purchase and unlock all features"="Koop en ontgrendel alle functies";
 "Win+Mac"="Win+Mac";
 "Win"="Win";

+ 2 - 2
PDF Office/PDF Master/Strings/pl.lproj/Localizable.strings

@@ -3227,8 +3227,8 @@
 "Unable to connect to server, please check your connection."="Nie można połączyć się z serwerem, sprawdź połączenie.";
 "The account doesn't exist."="Konto nie istnieje.";
 "Your password has been changed. Please login again."="Twoje hasło zostało zmienione. Zaloguj się ponownie.";
-"Hi,XXX"="Cześć , XXX";
-"You have tried it for 6 days."="Próbowałeś przez 6 dni.";
+"Hi,%@"="Cześć , %@";
+"You have tried it for %d days."="Próbowałeś przez %d dni.";
 "Purchase and unlock all features"="Kup i odblokuj wszystkie funkcje";
 "Win+Mac"="Win+Mac";
 "Win"="Win";

+ 2 - 2
PDF Office/PDF Master/Strings/pt.lproj/Localizable.strings

@@ -4685,8 +4685,8 @@
 "Unable to connect to server, please check your connection."="Não é possível conectar-se ao servidor, verifique sua conexão.";
 "The account doesn't exist."="A conta não existe.";
 "Your password has been changed. Please login again."="Sua senha foi alterada. Faça login novamente.";
-"Hi,XXX"="Oi,XXX";
-"You have tried it for 6 days."="Você tentou por 6 dias.";
+"Hi,%@"="Oi,%@";
+"You have tried it for %d days."="Você tentou por %d dias.";
 "Purchase and unlock all features"="Compre e desbloqueie todos os recursos";
 "Win+Mac"="Win+Mac";
 "Win"="Win";

+ 2 - 2
PDF Office/PDF Master/Strings/ru.lproj/Localizable.strings

@@ -3160,8 +3160,8 @@
 "Unable to connect to server, please check your connection."="Невозможно подключиться к серверу, пожалуйста, проверьте соединение.";
 "The account doesn't exist."="Учетная запись не существует.";
 "Your password has been changed. Please login again."="Ваш пароль был изменен. Пожалуйста, войдите в систему снова.";
-"Hi,XXX"="Привет, ХХХ";
-"You have tried it for 6 days."="Вы пытались это сделать в течение 6 дней.";
+"Hi,%@"="Привет, %@";
+"You have tried it for %d days."="Вы пытались это сделать в течение %d дней.";
 "Purchase and unlock all features"="Приобретите и разблокируйте все функции";
 "Win+Mac"="Win+Mac";
 "Win"="Win";

+ 2 - 2
PDF Office/PDF Master/Strings/zh-Hans.lproj/Localizable.strings

@@ -4217,8 +4217,8 @@
 "Unable to connect to server, please check your connection."="无法连接到服务器,请检查您的连接。";
 "The account doesn't exist."="帐户不存在。";
 "Your password has been changed. Please login again."="您的密码已更改。请重新登录。";
-"Hi,XXX"="您好,XXX";
-"You have tried it for 6 days."="您已试用 6 天。";
+"Hi,%@"="您好,%@";
+"You have tried it for %d days."="您已试用 %d 天。";
 "Purchase and unlock all features"="购买并解锁全部功能";
 "Win+Mac"="Win+Mac";
 "Win"="Win";

+ 2 - 2
PDF Office/PDF Master/Strings/zh-Hant.lproj/Localizable.strings

@@ -4330,8 +4330,8 @@
 "Unable to connect to server, please check your connection."="無法連接到伺服器,請檢查您的連接。";
 "The account doesn't exist."="該帳戶不存在。";
 "Your password has been changed. Please login again."="您的密碼已更改。請重新登入。";
-"Hi,XXX"="您好,XXX";
-"You have tried it for 6 days."="您已經嘗試了 6 天。";
+"Hi,%@"="您好,%@";
+"You have tried it for %d days."="您已經嘗試了 %d 天。";
 "Purchase and unlock all features"="購買並解鎖所有功能";
 "Win+Mac"="Win+Mac";
 "Win"="Win";