| | |
| | | import JQTools |
| | | |
| | | class SceneDelegate: UIResponder, UIWindowSceneDelegate,WXApiDelegate { |
| | | |
| | | var window: UIWindow? |
| | | |
| | | func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { |
| | | guard let windowScene = (scene as? UIWindowScene) else { return } |
| | | window = UIWindow(windowScene: windowScene) |
| | | window?.frame = windowScene.coordinateSpace.bounds |
| | | |
| | | var window: UIWindow? |
| | | |
| | | func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { |
| | | guard let windowScene = (scene as? UIWindowScene) else { return } |
| | | window = UIWindow(windowScene: windowScene) |
| | | window?.frame = windowScene.coordinateSpace.bounds |
| | | |
| | | |
| | | if UserViewModel.getToken() != nil{ |
| | | app.registerAndLoginSuccess() |
| | | }else{ |
| | | let loginNav = LoginNav(rootViewController: LoginVC()) |
| | | window?.rootViewController = loginNav |
| | | window?.makeKeyAndVisible() |
| | | } |
| | | if UserViewModel.getToken() != nil{ |
| | | app.registerAndLoginSuccess() |
| | | }else{ |
| | | let loginNav = LoginNav(rootViewController: LoginVC()) |
| | | window?.rootViewController = loginNav |
| | | window?.makeKeyAndVisible() |
| | | } |
| | | |
| | | SVProgressHUD.setContainerView(window) |
| | | SVProgressHUD.setDefaultStyle(.dark) |
| | | SVProgressHUD.setDefaultMaskType(.custom) //禁止交互 |
| | | SVProgressHUD.setMinimumDismissTimeInterval(1.5) |
| | | SVProgressHUD.setMaximumDismissTimeInterval(30.0) |
| | | |
| | | if #available(iOS 13.0, *) { |
| | | window?.overrideUserInterfaceStyle = .light |
| | | } |
| | | |
| | | } |
| | | SVProgressHUD.setContainerView(window) |
| | | SVProgressHUD.setDefaultStyle(.dark) |
| | | SVProgressHUD.setDefaultMaskType(.custom) //禁止交互 |
| | | SVProgressHUD.setMinimumDismissTimeInterval(1.5) |
| | | SVProgressHUD.setMaximumDismissTimeInterval(30.0) |
| | | |
| | | func scene(_ scene: UIScene, continue userActivity: NSUserActivity) { |
| | | print("---->4") |
| | | YYPaymentManager.shared.handleApplication(userActivity) |
| | | } |
| | | if #available(iOS 13.0, *) { |
| | | window?.overrideUserInterfaceStyle = .light |
| | | } |
| | | |
| | | func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) { |
| | | if let code = URLContexts.first?.url.jq_params?["code"]{ |
| | | DispatchQueue.main.async { |
| | | hiddenHUD() |
| | | let resp = SendAuthResp() |
| | | resp.code = code |
| | | WeChatTools.getAccessToken(resp) { model in |
| | | if let m = model{ |
| | | WeChatTools.getUserInfo(access_token: m.access_token, openId: m.openid) { userInfoModel in |
| | | if let u = userInfoModel{ |
| | | Services.wxLogin(openId: u.openid, nickname: u.nickname, headimgurl: u.headimgurl, sex: u.sex).subscribe(onNext: { data in |
| | | if let m = data.data{ |
| | | if m.isBind == 0{ |
| | | let vc = BindPhoneVC(wxUserInfoModel: u,token: m.token) |
| | | JQ_currentViewController().jq_push(vc: vc) |
| | | }else{ |
| | | UserViewModel.saveToken(m.token) |
| | | app.registerAndLoginSuccess() |
| | | } |
| | | } |
| | | }) { error in |
| | | alertError(msg: error.localizedDescription) |
| | | }.disposed(by: JQ_disposeBag) |
| | | }else{ |
| | | alertError(msg: "获取信息失败") |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | if ((URLContexts.first?.url.absoluteString.contains("weparklife://safepay")) != nil){ |
| | | let url = URLContexts.first!.url |
| | | YYPaymentManager.shared.handleApplication(UIApplication.shared, open: url, options: [:]) |
| | | } |
| | | func scene(_ scene: UIScene, continue userActivity: NSUserActivity) { |
| | | print("---->4") |
| | | YYPaymentManager.shared.handleApplication(userActivity) |
| | | } |
| | | |
| | | if URLContexts.first!.url.host == "resendContextReqByScheme"{ |
| | | WXApi.handleOpen(URLContexts.first!.url, delegate: YYPaymentManager.shared) |
| | | } |
| | | } |
| | | func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) { |
| | | if let code = URLContexts.first?.url.jq_params?["code"]{ |
| | | DispatchQueue.main.async { |
| | | hiddenHUD() |
| | | let resp = SendAuthResp() |
| | | resp.code = code |
| | | WeChatTools.getAccessToken(resp) { model in |
| | | if let m = model{ |
| | | WeChatTools.getUserInfo(access_token: m.access_token, openId: m.openid) { userInfoModel in |
| | | if let u = userInfoModel{ |
| | | Services.wxLogin(openId: u.openid, nickname: u.nickname, headimgurl: u.headimgurl, sex: u.sex).subscribe(onNext: { data in |
| | | if let m = data.data{ |
| | | if m.isBind == 0{ |
| | | let vc = BindPhoneVC(wxUserInfoModel: u,token: m.token) |
| | | JQ_currentViewController().jq_push(vc: vc) |
| | | }else{ |
| | | UserViewModel.saveToken(m.token) |
| | | app.registerAndLoginSuccess() |
| | | } |
| | | } |
| | | }) { error in |
| | | alertError(msg: error.localizedDescription) |
| | | }.disposed(by: JQ_disposeBag) |
| | | }else{ |
| | | alertError(msg: "获取信息失败") |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | func sceneDidDisconnect(_ scene: UIScene) { |
| | | |
| | | } |
| | | |
| | | func sceneDidBecomeActive(_ scene: UIScene) { |
| | | if ((URLContexts.first?.url.absoluteString.contains("weparklife://safepay")) != nil){ |
| | | let url = URLContexts.first!.url |
| | | YYPaymentManager.shared.handleApplication(UIApplication.shared, open: url, options: [:]) |
| | | } |
| | | |
| | | } |
| | | |
| | | func sceneWillResignActive(_ scene: UIScene) { |
| | | |
| | | } |
| | | |
| | | func sceneWillEnterForeground(_ scene: UIScene) { |
| | | |
| | | } |
| | | |
| | | func sceneDidEnterBackground(_ scene: UIScene) { |
| | | |
| | | } |
| | | if URLContexts.first!.url.host == "resendContextReqByScheme"{ |
| | | WXApi.handleOpen(URLContexts.first!.url, delegate: YYPaymentManager.shared) |
| | | } |
| | | } |
| | | |
| | | func sceneDidDisconnect(_ scene: UIScene) { |
| | | |
| | | } |
| | | |
| | | func sceneDidBecomeActive(_ scene: UIScene) { |
| | | |
| | | } |
| | | |
| | | func sceneWillResignActive(_ scene: UIScene) { |
| | | |
| | | } |
| | | |
| | | func sceneWillEnterForeground(_ scene: UIScene) { |
| | | |
| | | } |
| | | |
| | | func sceneDidEnterBackground(_ scene: UIScene) { |
| | | |
| | | } |
| | | } |
| | | |