fix
无故事王国
2024-02-28 4468d9f9b3b8c70597f04e5f1ecb61118c404d2c
WanPai/AppDelegate.swift
@@ -14,114 +14,109 @@
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
    var window: UIWindow?
    var orientation:UIInterfaceOrientationMask = .portrait
            var window: UIWindow?
            var orientation:UIInterfaceOrientationMask = .portrait
            func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
                        sleep(2)
                        Services.startNetworkMonitor()
                        YYPaymentManager.shared.configuredWeChat(appID: WeChatAPPID, universalLink: WechatUniversalLinks)
                        YYPaymentManager.shared.configuredAlipay(appScheme: APPScheme)
                        AMapServices.shared().enableHTTPS = true
                        AMapServices.shared().apiKey = AMapKey
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
      sleep(2)
        Services.startNetworkMonitor()
        YYPaymentManager.shared.configuredWeChat(appID: WeChatAPPID, universalLink: WechatUniversalLinks)
        YYPaymentManager.shared.configuredAlipay(appScheme: APPScheme)
        AMapServices.shared().enableHTTPS = true
        AMapServices.shared().apiKey = AMapKey
      Services.querySystemImg(type: .launch).subscribe(onNext: {data in
         if let img = data.data{
            SDWebImageDownloader.shared.downloadImage(with: URL(string: img)) { image, _, _, _ in
               if let img = image{
                  LaunchImageHelper.changeAllLaunchImageToLandscape(img)
               }
                        Services.querySystemImg(type: .launch).subscribe(onNext: {data in
                                    if let img = data.data{
                                                SDWebImageDownloader.shared.downloadImage(with: URL(string: img)) { image, _, _, _ in
                                                            if let img = image{
                                                                        LaunchImageHelper.changeAllLaunchImageToLandscape(img)
                                                            }
                                                }
                                    }
                        }).disposed(by: JQ_disposeBag)
                        return true
            }
         }
      }).disposed(by: JQ_disposeBag)
        return true
    }
    // MARK: UISceneSession Lifecycle
            // MARK: UISceneSession Lifecycle
    func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
        // Called when a new scene session is being created.
        // Use this method to select a configuration to create the new scene with.
        return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
    }
            func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
                        return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
            }
    func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
        // Called when the user discards a scene session.
        // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
        // Use this method to release any resources that were specific to the discarded scenes, as they will not return.
    }
            func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
    func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
        if UIDevice.current.userInterfaceIdiom == .pad{
            return .all
        }else{
            return orientation
        }
    }
            }
    func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
      print("---->")
        return YYPaymentManager.shared.handleApplication(application, open: url, sourceApplication: sourceApplication, annotation: annotation)
    }
            func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
                        if UIDevice.current.userInterfaceIdiom == .pad{
                                    return .all
                        }else{
                                    return orientation
                        }
            }
    func application(_ application: UIApplication, handleOpen url: URL) -> Bool {
      print("---->1")
        return YYPaymentManager.shared.handleApplication(application, handleOpen: url)
    }
            func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
                        print("---->")
                        return YYPaymentManager.shared.handleApplication(application, open: url, sourceApplication: sourceApplication, annotation: annotation)
            }
    // NOTE: 9.0以后使用新API接口
    func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
      print("---->2")
        return YYPaymentManager.shared.handleApplication(app, open: url, options: options)
    }
            func application(_ application: UIApplication, handleOpen url: URL) -> Bool {
                        print("---->1")
                        return YYPaymentManager.shared.handleApplication(application, handleOpen: url)
            }
   func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
      print("---->3")
      return YYPaymentManager.shared.handleApplication(userActivity)
   }
            // NOTE: 9.0以后使用新API接口
            func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
                        print("---->2")
                        return YYPaymentManager.shared.handleApplication(app, open: url, options: options)
            }
            func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
                        print("---->3")
                        return YYPaymentManager.shared.handleApplication(userActivity)
            }
}
extension AppDelegate{
    func registerAndLoginSuccess(){
        let snapView = sceneDelegate?.window?.snapshotView(afterScreenUpdates: true)
            func registerAndLoginSuccess(){
                        let snapView = sceneDelegate?.window?.snapshotView(afterScreenUpdates: true)
        let tabBar = BaseTabBarVC()
        let homeNav = BaseNav(rootViewController: HomeVC())
      homeNav.tabBarItem = UITabBarItem(title: "加入玩湃", image: UIImage(named: "tabbar_home"), selectedImage: UIImage(named: "tabbar_home_s")!.withRenderingMode(.alwaysOriginal))
                        let tabBar = BaseTabBarVC()
                        let homeNav = BaseNav(rootViewController: HomeVC())
                        homeNav.tabBarItem = UITabBarItem(title: "加入玩湃", image: UIImage(named: "tabbar_home"), selectedImage: UIImage(named: "tabbar_home_s")!.withRenderingMode(.alwaysOriginal))
        let clouseNav = BaseNav(rootViewController: CourseVC())
        clouseNav.tabBarItem = UITabBarItem(title: "玩湃运动营", image: UIImage(named: "tabbar_course"), selectedImage: UIImage(named: "tabbar_course_s")!.withRenderingMode(.alwaysOriginal))
                        let clouseNav = BaseNav(rootViewController: CourseVC())
                        clouseNav.tabBarItem = UITabBarItem(title: "玩湃运动营", image: UIImage(named: "tabbar_course"), selectedImage: UIImage(named: "tabbar_course_s")!.withRenderingMode(.alwaysOriginal))
        let welfareVCNav = BaseNav(rootViewController: WelfareVC())
        welfareVCNav.tabBarItem = UITabBarItem(title: "使用福利", image: UIImage(named: "tabbar_welfare"), selectedImage: UIImage(named: "tabbar_welfare_s")!.withRenderingMode(.alwaysOriginal))
                        let welfareVCNav = BaseNav(rootViewController: WelfareVC())
                        welfareVCNav.tabBarItem = UITabBarItem(title: "使用福利", image: UIImage(named: "tabbar_welfare"), selectedImage: UIImage(named: "tabbar_welfare_s")!.withRenderingMode(.alwaysOriginal))
        let searchVCNav = BaseNav(rootViewController: SearchVC())
        searchVCNav.tabBarItem = UITabBarItem(title: "搜索玩湃", image: UIImage(named: "tabbar_search"), selectedImage: UIImage(named: "tabbar_search_s")!.withRenderingMode(.alwaysOriginal))
        tabBar.viewControllers = [homeNav,clouseNav,welfareVCNav,searchVCNav]
      sceneDelegate?.window?.rootViewController = tabBar
      sceneDelegate?.window?.rootViewController?.view.addSubview(snapView!)
      sceneDelegate?.window?.makeKeyAndVisible()
                        let searchVCNav = BaseNav(rootViewController: SearchVC())
                        searchVCNav.tabBarItem = UITabBarItem(title: "搜索玩湃", image: UIImage(named: "tabbar_search"), selectedImage: UIImage(named: "tabbar_search_s")!.withRenderingMode(.alwaysOriginal))
                        tabBar.viewControllers = [homeNav,clouseNav,welfareVCNav,searchVCNav]
                        sceneDelegate?.window?.rootViewController = tabBar
                        sceneDelegate?.window?.rootViewController?.view.addSubview(snapView!)
                        sceneDelegate?.window?.makeKeyAndVisible()
        UIView.animate(withDuration: 1.5) {
            snapView?.alpha = 0
            snapView?.transform3D = CATransform3DMakeScale(1.5, 1.5, 1.5)
        } completion: { _ in
            snapView?.removeFromSuperview()
        }
                        UIView.animate(withDuration: 1.5) {
                                    snapView?.alpha = 0
                                    snapView?.transform3D = CATransform3DMakeScale(1.5, 1.5, 1.5)
                        } completion: { _ in
                                    snapView?.removeFromSuperview()
                        }
//      YYSocketManager.instance.startSocket(host: Socket_Url, port: 8888)
    }
                        //      YYSocketManager.instance.startSocket(host: Socket_Url, port: 8888)
            }
    func needLogin(){
      UserViewModel.clearToken()
      UserDefaults.standard.setValue(nil, forKey: "currentStuId")
      if JQ_currentViewController() is LoginVC{return}
      let loginNav = LoginNav(rootViewController: LoginVC())
      loginNav.modalPresentationStyle = .fullScreen
      JQ_currentViewController().present(loginNav, animated: true)
    }
            func needLogin(){
                        UserViewModel.clearToken()
                        UserDefaults.standard.setValue(nil, forKey: "currentStuId")
                        if JQ_currentViewController() is LoginVC{return}
                        let loginNav = LoginNav(rootViewController: LoginVC())
                        loginNav.modalPresentationStyle = .fullScreen
                        JQ_currentViewController().present(loginNav, animated: true)
            }
}