| | |
| | | import JQTools |
| | | import AuthenticationServices |
| | | |
| | | class SceneDelegate: UIResponder, UIWindowSceneDelegate { |
| | | class SceneDelegate: UIResponder, UIWindowSceneDelegate, WXApiDelegate{ |
| | | |
| | | var window: UIWindow? |
| | | |
| | |
| | | |
| | | } |
| | | |
| | | func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) { |
| | | |
| | | if URLContexts.first?.url.scheme == WeChatAPPID,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.loginByWechat(headImgUrl: u.headimgurl, nickname: u.nickname, sex: u.sex, wxOpenId: u.openid).subscribe(onNext: {data in |
| | | if let model = data.data{ |
| | | sceneDelegate?.loginSuccess() |
| | | JQ_currentViewController().dismiss(animated:true) |
| | | UserViewModel.saveLoginInfo(model) |
| | | |
| | | Services.getUserInfo().subscribe(onNext: {data in |
| | | if let model = data.data{ |
| | | UserViewModel.saveAvatarInfo(model) |
| | | } |
| | | }).disposed(by: JQ_disposeBag) |
| | | } |
| | | }).disposed(by: JQ_disposeBag) |
| | | }else{ |
| | | alertError(msg: "获取信息失败") |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | func scene(_ scene: UIScene, continue userActivity: NSUserActivity) { |
| | | WXApi.handleOpenUniversalLink(userActivity, delegate: self) |
| | | } |
| | | |
| | | func sceneDidDisconnect(_ scene: UIScene) { |
| | | // Called as the scene is being released by the system. |
| | | // This occurs shortly after the scene enters the background, or when its session is discarded. |
| | |
| | | // to restore the scene back to its current state. |
| | | } |
| | | |
| | | func onReq(_ req: BaseReq) { |
| | | |
| | | } |
| | | |
| | | func onResp(_ resp: BaseResp) { |
| | | |
| | | } |
| | | |
| | | } |
| | | |