younger_times
2023-07-31 9add6fe63070124dea74f596e646eaae2f52ef17
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
//
//  AppDelegate.swift
//  WanPai
//
//  Created by 杨锴 on 2023/6/6.
//
 
import UIKit
import JQTools
import Alamofire
import AMapFoundationKit
 
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
 
    var window: UIWindow?
    var orientation:UIInterfaceOrientationMask = .portrait
 
 
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        Services.startNetworkMonitor()
        YYPaymentManager.shared.configuredWeChat(appID: WeChatAPPID, universalLink: WechatUniversalLinks)
        YYPaymentManager.shared.configuredAlipay(appScheme: APPScheme)
        AMapServices.shared().enableHTTPS = true
        AMapServices.shared().apiKey = AMapKey
        return true
    }
 
    // 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, 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, 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 {
        return YYPaymentManager.shared.handleApplication(application, open: url, sourceApplication: sourceApplication, annotation: annotation)
    }
    func application(_ application: UIApplication, handleOpen url: URL) -> Bool {
        return YYPaymentManager.shared.handleApplication(application, handleOpen: url)
    }
    // NOTE: 9.0以后使用新API接口
    func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
        return YYPaymentManager.shared.handleApplication(app, open: url, options: options)
    }
}
 
extension AppDelegate{
    func registerAndLoginSuccess(){
        let snapView = screnDelegate?.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 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 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]
        screnDelegate?.window?.rootViewController = tabBar
        screnDelegate?.window?.rootViewController?.view.addSubview(snapView!)
        screnDelegate?.window?.makeKeyAndVisible()
 
        UIView.animate(withDuration: 1.5) {
            snapView?.alpha = 0
            snapView?.transform3D = CATransform3DMakeScale(1.5, 1.5, 1.5)
        } completion: { _ in
            snapView?.removeFromSuperview()
        }
    }
 
    func needLogin(){
        UserViewModel.clearToken()
        let loginVC = LoginVC()
        loginVC.modalPresentationStyle = .fullScreen
        JQ_currentViewController().present(loginVC, animated: true)
    }
}