Commit 5c18623b authored by pete谢兆麟's avatar pete谢兆麟

增加隐私协议弹窗前置

parent 7e714463
......@@ -326,76 +326,115 @@ class YHOtherLoginViewController: YHBaseViewController {
}
@objc func wechatLogin() {
let login = YHShareManager.shared
login.sendLogin()
login.success = { [weak self] unionId in
guard let self = self else { return }
self.viewModel.wxlogin(unionId: unionId, phone: "", code: "") {[weak self] success, error in
if privacyView.isAgree {
let login = YHShareManager.shared
login.sendLogin()
login.success = { [weak self] unionId in
guard let self = self else { return }
if success {
YHLoginManager.shared.loginSuccessActionBlock?()
YHHUD.flash(message: "登录成功")
self.dismiss(animated: true)
TXCommonHandler.sharedInstance().cancelLoginVC(animated: true)
self.navigationController?.popToRootViewController(animated: true)
} else {
if error?.errorCode == 30001 {
//第一次微信登录跳转逻辑
let vc = YHOtherLoginViewController()
vc.type = .wechat
vc.token = unionId
navigationController?.pushViewController(vc)
self.viewModel.wxlogin(unionId: unionId, phone: "", code: "") {[weak self] success, error in
guard let self = self else { return }
if success {
YHLoginManager.shared.loginSuccessActionBlock?()
YHHUD.flash(message: "登录成功")
self.dismiss(animated: true)
TXCommonHandler.sharedInstance().cancelLoginVC(animated: true)
self.navigationController?.popToRootViewController(animated: true)
} else {
YHHUD.flash(message: error?.errorMsg ?? "")
if error?.errorCode == 30001 {
//第一次微信登录跳转逻辑
let vc = YHOtherLoginViewController()
vc.type = .wechat
vc.token = unionId
navigationController?.pushViewController(vc)
} else {
YHHUD.flash(message: error?.errorMsg ?? "")
}
}
}
}
} else {
let view = YHPrivacyAlertView(frame: view.bounds)
view.urlBlock = { [weak self] (type,url) in
guard let self = self else { return }
let vc = YHWebViewViewController()
vc.url = url
if type == 0 {
vc.navTitle = "银河港生活隐私政策"
} else if type == 1 {
vc.navTitle = "银河港生活用户条款"
}
self.navigationController?.pushViewController(vc)
}
view.agreeBlock = { [weak self] in
guard let self = self else { return }
self.privacyView.isAgree = true
self.wechatLogin()
}
self.view.addSubview(view)
}
}
@objc func appleLogin() {
//第一次appid登录跳转逻辑
// let vc = YHOtherLoginViewController()
// vc.type = .apple
// navigationController?.pushViewController(vc)
YHAppleLoginManager.shared.success = {
dict in
YHHUD.flash(message: "登录中...")
self.appleLoginViewModel.appleLogin(params: dict) {
success, error in
if privacyView.isAgree {
YHAppleLoginManager.shared.success = {
dict in
YHHUD.hide()
if success {
YHLoginManager.shared.loginSuccessActionBlock?()
YHHUD.flash(message: "登录成功")
self.dismiss(animated: true)
TXCommonHandler.sharedInstance().cancelLoginVC(animated: true)
self.navigationController?.popToRootViewController(animated: true)
return
}
if let err = error {
var msg = err.errorMsg
if msg.isEmpty {
msg = "登录失败"
YHHUD.flash(message: "登录中...")
self.appleLoginViewModel.appleLogin(params: dict) {
success, error in
YHHUD.hide()
if success {
YHLoginManager.shared.loginSuccessActionBlock?()
YHHUD.flash(message: "登录成功")
self.dismiss(animated: true)
TXCommonHandler.sharedInstance().cancelLoginVC(animated: true)
self.navigationController?.popToRootViewController(animated: true)
return
}
YHHUD.flash(message: msg)
if err.errorCode == 30001 {
// 首次登录,没有传电话号码和验证码返回错误码:30001
// 进入手机绑定页面
let bindVC = YHOtherLoginViewController()
bindVC.type = .apple
bindVC.appleLoginParams = dict
UIViewController.current?.navigationController?.pushViewController(bindVC)
return
if let err = error {
var msg = err.errorMsg
if msg.isEmpty {
msg = "登录失败"
}
YHHUD.flash(message: msg)
if err.errorCode == 30001 {
// 首次登录,没有传电话号码和验证码返回错误码:30001
// 进入手机绑定页面
let bindVC = YHOtherLoginViewController()
bindVC.type = .apple
bindVC.appleLoginParams = dict
UIViewController.current?.navigationController?.pushViewController(bindVC)
return
}
}
}
}
YHAppleLoginManager.shared.appleLogin()
} else {
let view = YHPrivacyAlertView(frame: view.bounds)
view.urlBlock = { [weak self] (type,url) in
guard let self = self else { return }
let vc = YHWebViewViewController()
vc.url = url
if type == 0 {
vc.navTitle = "银河港生活隐私政策"
} else if type == 1 {
vc.navTitle = "银河港生活用户条款"
}
self.navigationController?.pushViewController(vc)
}
view.agreeBlock = { [weak self] in
guard let self = self else { return }
self.privacyView.isAgree = true
self.appleLogin()
}
self.view.addSubview(view)
}
YHAppleLoginManager.shared.appleLogin()
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment