Browse Source

【订阅】restore提示补充

lizhe 1 year ago
parent
commit
063dd3657b

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

@@ -120,7 +120,11 @@ class AppDelegate: NSObject, NSApplicationDelegate {
                         KMLoginWindowController.show(window: NSApp.mainWindow!)
                     } else {
                         KMPurchaseManager.manager.restorePurchases { isSuccess in
-                            
+                            if isSuccess {
+                                
+                            } else {
+                                KMComparativeTableViewController.purchasefailed()
+                            }
                         }
                     }
                     
@@ -136,7 +140,11 @@ class AppDelegate: NSObject, NSApplicationDelegate {
                 // 执行相应的操作
                 if url.scheme == "subscriptionSchemes" {
                     KMPurchaseManager.manager.restorePurchases { isSuccess in
-                        
+                        if isSuccess {
+                            
+                        } else {
+                            KMComparativeTableViewController.purchasefailed()
+                        }
                     }
                     if url.path == "/open" {
                         // 执行打开操作
@@ -382,7 +390,11 @@ class AppDelegate: NSObject, NSApplicationDelegate {
     
     @IBAction func restoreMenuItemAction(_ sender: Any) {
         KMPurchaseManager.manager.restorePurchases { isSuccess in
-            
+            if isSuccess {
+                
+            } else {
+                KMComparativeTableViewController.purchasefailed()
+            }
         }
     }
     

+ 26 - 4
PDF Office/PDF Master/Class/KMLightMember/Controller/ComparativeTable/KMComparativeTableViewController.swift

@@ -227,7 +227,7 @@ class KMComparativeTableViewController: NSWindowController {
                         comparativeMainWindow = nil
                         controller.close()
                     } else {
-                        controller.purchasefailed()
+                        KMComparativeTableViewController.purchasefailed()
                     }
                     controller.comparativeView.endLoading()
                 }
@@ -246,7 +246,7 @@ class KMComparativeTableViewController: NSWindowController {
                             }
                         }
                     } else {
-                        controller.purchasefailed()
+                        KMComparativeTableViewController.purchasefailed()
                     }
                     //loading
                     controller.comparativeView.endLoading()
@@ -267,8 +267,7 @@ class KMComparativeTableViewController: NSWindowController {
         }
     }
     
-    func purchasefailed() {
-        
+    static func purchasefailed() {
         DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.1, execute: {
             let alert = NSAlert()
             alert.messageText = NSLocalizedString("restore failed", comment: "")
@@ -290,4 +289,27 @@ class KMComparativeTableViewController: NSWindowController {
             }
         })
     }
+    
+    static func purchaseSuccess() {
+        DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.1, execute: {
+            let alert = NSAlert()
+            alert.messageText = NSLocalizedString("restore success", comment: "")
+            alert.informativeText = NSLocalizedString("", comment: "")
+//            alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
+            alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
+            var window = NSApp.mainWindow
+            if NSApp.mainWindow?.sheets.first != nil {
+                window = NSApp.mainWindow?.sheets.first
+            }
+            if window != nil {
+                alert.beginSheetModal(for: window!) { result in
+                    if (result == .alertFirstButtonReturn) {
+
+                    } else if result == .alertSecondButtonReturn {
+                        return
+                    }
+                }
+            }
+        })
+    }
 }

+ 2 - 25
PDF Office/PDF Master/Class/KMLightMember/Controller/SubscriptionView/WaterMark/KMSubscribeWaterMarkWindowController.swift

@@ -108,7 +108,7 @@ class KMSubscribeWaterMarkWindowController: NSWindowController {
                     }
                 } else {
                     KMPrint("购买失败")
-                    controller.purchasefailed()
+                    KMComparativeTableViewController.purchasefailed()
                     completion(false, false, false)
                 }
                 
@@ -136,7 +136,7 @@ class KMSubscribeWaterMarkWindowController: NSWindowController {
                     }
                 } else {
                     KMPrint("restore失败")
-                    controller.purchasefailed()
+                    KMComparativeTableViewController.purchasefailed()
                     completion(false, false, false)
                 }
                 controller.waterMarkView.endLoading()
@@ -207,27 +207,4 @@ class KMSubscribeWaterMarkWindowController: NSWindowController {
         }
         return KMSubscribeWaterMarkWindowController()
     }
-    
-    func purchasefailed() {
-        DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.1, execute: {
-            let alert = NSAlert()
-            alert.messageText = NSLocalizedString("购买失败", comment: "")
-            alert.informativeText = NSLocalizedString("", comment: "")
-//            alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
-            alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
-            var window = NSApp.mainWindow
-            if NSApp.mainWindow?.sheets.first != nil {
-                window = NSApp.mainWindow?.sheets.first
-            }
-            if window != nil {
-                alert.beginSheetModal(for: window!) { result in
-                    if (result == .alertFirstButtonReturn) {
-
-                    } else if result == .alertSecondButtonReturn {
-                        return
-                    }
-                }
-            }
-        })
-    }
 }