//
|
// 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)
|
}
|
}
|