From d7213a2599c0abcef0dc94db37c45da5dee497f2 Mon Sep 17 00:00:00 2001 From: 杨锴 <841720330@qq.com> Date: 星期二, 19 十一月 2024 09:28:39 +0800 Subject: [PATCH] fix bug --- XQMuse/Root/Login/VC/UpdatePhoneVC.swift | 38 ++++++++++++++++++++++++++++++-------- 1 files changed, 30 insertions(+), 8 deletions(-) diff --git a/XQMuse/Root/Login/VC/UpdatePhoneVC.swift b/XQMuse/Root/Login/VC/UpdatePhoneVC.swift index ec92c2d..6ab3a5c 100644 --- a/XQMuse/Root/Login/VC/UpdatePhoneVC.swift +++ b/XQMuse/Root/Login/VC/UpdatePhoneVC.swift @@ -12,6 +12,7 @@ class UpdatePhoneVC: BaseVC { private var credential:ASAuthorizationAppleIDCredential? + private var wechatInfoModel:WechatUserInfoModel? private var firstAccessToken:String? //后端问题,要把上次的token带过来 @IBOutlet weak var tf_phone: QMUITextField! @IBOutlet weak var tf_code: QMUITextField! @@ -19,9 +20,10 @@ @IBOutlet weak var btn_isRead: UIButton! - init(credential:ASAuthorizationAppleIDCredential? = nil,firstAccessToken:String?) { + init(credential:ASAuthorizationAppleIDCredential? = nil,wechatInfoModel:WechatUserInfoModel? = nil,firstAccessToken:String?) { super.init(nibName: nil, bundle: nil) self.credential = credential + self.wechatInfoModel = wechatInfoModel self.firstAccessToken = firstAccessToken } @@ -91,24 +93,44 @@ guard tf_code.text!.count == 6 else { alertError(msg: "请输入6位验证码");return } - guard let credentialUser = credential?.user else { - alertError(msg: "Apple登录授权异常");return + + var threePlantformLoginType:ThreePlantformLoginType! + var formatName:String! + var unionId:String! + + if credential != nil{ + threePlantformLoginType = .apple + guard let credentialUser = credential?.user else { + alertError(msg: "Apple登录授权异常");return + } + + formatName = String(format: "%@%@%@", credential?.fullName?.familyName ?? "",credential?.fullName?.middleName ?? "", credential?.fullName?.middleName ?? "") + + unionId = credential!.user } - let formatName = String(format: "%@%@%@", credential?.fullName?.familyName ?? "",credential?.fullName?.middleName ?? "", credential?.fullName?.middleName ?? "") + if wechatInfoModel != nil{ + threePlantformLoginType = .wechat + guard !(wechatInfoModel?.openid.isEmpty ?? true) else { + alertError(msg: "Apple登录授权异常");return + } + formatName = wechatInfoModel?.nickname ?? "" + unionId = wechatInfoModel!.openid + } - Services.confirmByApple(cellPhone: tf_phone.text!, captcha: tf_code.text!, loginType: .apple, wxOrAppleId: credentialUser,name: formatName, mail: credential!.email).subscribe(onNext: {data in + + Services.confirmByApple(cellPhone: tf_phone.text!, captcha: tf_code.text!, loginType: threePlantformLoginType, wxOrAppleId: unionId,name: formatName, mail: credential!.email).subscribe(onNext: {data in if var model = data.data{ model.loginByAppleToken = String(data: self.credential!.identityToken!, encoding: .utf8) - model.accessToken = self.firstAccessToken ?? "" + model.accessToken = model.accessToken model.appleId = self.credential!.user - sceneDelegate?.loginSuccess() - NotificationCenter.default.post(name: LoginDismiss_Noti, object: nil, userInfo: nil) UserViewModel.saveLoginInfo(model) Services.getUserInfo().subscribe(onNext: {data in if let model = data.data{ UserViewModel.saveAvatarInfo(model) + sceneDelegate?.loginSuccess() + NotificationCenter.default.post(name: LoginDismiss_Noti, object: nil, userInfo: nil) } }).disposed(by: self.disposeBag) } -- Gitblit v1.7.1