fix
无故事王国
2 天以前 2aac1ba6449741aedbf97d75c340719a7b67d7db
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
//
//  AppDelegate.swift
//  WanPai
//
//  Created by 杨锴 on 2023/6/6.
//
 
import UIKit
import JQTools
import Alamofire
//import AMapFoundationKit
import SDWebImage
 
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
 
    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
 
        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
    }
 
    // MARK: UISceneSession Lifecycle
 
    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>) {
 
    }
 
    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, handleOpen url: URL) -> Bool {
        print("---->1")
        return YYPaymentManager.shared.handleApplication(application, handleOpen: url)
    }
 
    // 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)
 
        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 carderCenterVCNav = BaseNav(rootViewController: CardCenterVC())
        carderCenterVCNav.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,carderCenterVCNav,clouseNav,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()
        }
 
        //        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)
    }
}