Browse Source

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

wanjun 1 week ago
parent
commit
b340073fa1

+ 5 - 44
PDF Office/PDF Master/MemberCenter/ViewModel/KMUserInfoVCModel.swift

@@ -252,7 +252,7 @@ class KMUserInfoVCModel: ObservableObject {
     /**
      @abstract 注销账户申请 弹窗;
      */
-    func closeAccountApplyWC(code: String) -> Void {
+    func closeAccountApplyWC(code: String,callback: ((Bool?, KMMemberCenterResult?)->Void)?) -> Void {
         if KMMemberCenterManager.manager.isConnectionAvailable() == false {
             let alert = NSAlert()
             alert.alertStyle = .critical
@@ -260,53 +260,14 @@ class KMUserInfoVCModel: ObservableObject {
             alert.informativeText = NSLocalizedString("Please make sure your internet connection is available.", comment: "")
             alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
             alert.runModal()
+            
+            callback?(false,nil)
             return
         }
         KMMemberCenterManager.manager.userLogOffForUser(code: code) { success, result in
             guard let result = result else { return }
-            let resultDict = result as KMMemberCenterResult
-            let msg = resultDict.msg
-            if success {
-                let logOff: KMMemberLogOff = resultDict.logOff!
-                var currentTime = "0"
-                var logOffTime = "0"
-
-                let currentDate = Date()
-                let calendar = Calendar.current
-
-                if let token = logOff.currentTime {
-                    let dateFormatter = DateFormatter()
-                    dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
-                    // 将字符串转换为日期对象
-                    if let date = dateFormatter.date(from: token) {
-                        // 创建一个新的日期格式化器,用于只显示天
-                        let components = calendar.dateComponents([.day], from: currentDate, to: date)
-                        
-                        if let daysDifference = components.day {
-                            currentTime = String(daysDifference)
-                        }
-                    }
-                }
-                if let token = logOff.logOffTime {
-                    let dateFormatter = DateFormatter()
-                    dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
-                    
-                    // 将字符串转换为日期对象
-                    if let date = dateFormatter.date(from: token) {
-                        let components = calendar.dateComponents([.day], from: currentDate, to: date)
-                        
-                        if let daysDifference = components.day {
-                            logOffTime = String(daysDifference)
-                        }
-                    }
-                }
-//                KMCloseApplyWC.shared.logOffTime = logOffTime
-//                KMCloseApplyWC.shared.currentTime = currentTime
-
-                KMCloseApplyWC.shared.showWindow(nil)
-            } else {
-                print(msg as Any)
-            }
+            let resultDict = result as KMMemberCenterResult            
+            callback?(success,resultDict)
         }
     }
     

+ 20 - 2
PDF Office/PDF Master/MemberCenter/WindowsController/KMCloseVerificationWC.swift

@@ -171,8 +171,26 @@ class KMCloseVerificationWC: NSWindowController {
     // MARK: Button Action
     
     @IBAction func yesButtonAction(_ sender: NSButton) {
-        self.window?.close()
-        userInfoModel.closeAccountApplyWC(code: signUpModel.verificationCode)
+        window?.showWaitingView()
+        userInfoModel.closeAccountApplyWC(code: signUpModel.verificationCode) { [weak self] result, resultDict in
+            DispatchQueue.main.async {
+                if(result == true) {
+                    KMCloseApplyWC.shared.showWindow(nil)
+                    self?.window?.close()
+                } else {
+                    if(resultDict != nil) {
+                        let msg = resultDict?.msg ?? NSLocalizedString("Unknown error", comment: "")
+                        let alert = NSAlert()
+                        alert.alertStyle = .critical
+                        alert.messageText = NSLocalizedString("Error Information", comment: "")
+                        alert.informativeText = NSLocalizedString("Please make sure your internet connection is available.", comment: "")
+                        alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
+                        alert.runModal()
+                    }
+                }
+                self?.window?.hideWaitingView()
+            }
+        }
     }
 }