Browse Source

【会员系统】用户中心补充load转圈

wangshuai 3 weeks ago
parent
commit
0ce54d8fc7

+ 8 - 21
PDF Office/PDF Master/Class/Purchase/DMG/Verification/KMVerificationMessageViewController.m

@@ -621,27 +621,14 @@ NSPopoverDelegate>
 }
 
 - (IBAction)personalCenterAction:(NSButton *)sender {
-    [KMUserInfoViewController refreshTokenUserInfoWithCallback:^(BOOL success,KMMemberCenterResult*resDic) {
-        if(success) {
-            if([KMMemberInfo shared].isLogin == YES) {
-                // 用户头像点击事件
-                self.userMenu = [[NSMenu alloc] init];
-                KMUserInfoViewController *userInfo = [[KMUserInfoViewController alloc] init];
-                NSMenuItem *item = [self.userMenu addItemWithTitle:@"" action:nil target:@""];
-                item.target = self;
-                item.representedObject = userInfo;
-                item.view = userInfo.view;
-                [self.userMenu popUpMenuPositioningItem:nil atLocation:NSMakePoint(-130, 30) inView:sender];
-            }
-        } else {
-            NSInteger code = resDic.code;
-            if(code == 304) {
-                [[KMLoginWindowsController shared] showWindow:nil];
-            }
-        }
-    }];
-  
-
+    // 用户头像点击事件
+    self.userMenu = [[NSMenu alloc] init];
+    KMUserInfoViewController *userInfo = [[KMUserInfoViewController alloc] init];
+    NSMenuItem *item = [self.userMenu addItemWithTitle:@"" action:nil target:@""];
+    item.target = self;
+    item.representedObject = userInfo;
+    item.view = userInfo.view;
+    [self.userMenu popUpMenuPositioningItem:nil atLocation:NSMakePoint(-130, 30) inView:sender];
 }
 
 - (IBAction)signUpAction:(NSButton *)sender {

+ 36 - 0
PDF Office/PDF Master/MemberCenter/ViewController/KMUserInfoViewController.swift

@@ -162,6 +162,25 @@ class KMUserInfoViewController: NSViewController {
             })
         }
         NotificationCenter.default.addObserver(self, selector: #selector(changeEffectiveAppearance), name: NSNotification.Name(rawValue: "kEffectiveAppearance"), object: nil)
+        
+        addWaitingView(to: self.view)
+        KMUserInfoViewController.refreshTokenUserInfo {[weak self] success, resDic in
+            DispatchQueue.main.async {
+                self?.removeWaitingView(from: self?.view ?? NSView())
+                if(success) {
+                    if KMMemberInfo.shared.isLogin {
+                    }
+                } else {
+                    NotificationCenter.default.post(name: NSNotification.Name("CloseMenuNotification"), object: nil)
+                    let code = resDic?.code
+                    if code == 304 {
+                        KMLoginWindowsController.shared.showWindow(nil)
+                    }
+                }
+            }
+        }
+        
+
     }
     
     @objc func changeEffectiveAppearance() {
@@ -478,6 +497,23 @@ class KMUserInfoViewController: NSViewController {
         }
     }
     
+    func addWaitingView(to view: NSView) {
+        removeWaitingView(from: view)
+        let waitingView = WaitingView(frame: view.bounds)
+        waitingView.autoresizingMask = [.width, .height]
+        view.addSubview(waitingView)
+        waitingView.startAnimation()
+    }
+
+    func removeWaitingView(from view: NSView) {
+        for subview in view.subviews {
+            if subview is WaitingView {
+                subview.removeFromSuperview()
+                break
+            }
+        }
+    }
+    
     private func initializeUI() -> Void {
         refreshEquity()