66 lines
1.6 KiB
Swift
66 lines
1.6 KiB
Swift
//
|
|
// LoginViewModel.swift
|
|
// QuickLocation
|
|
//
|
|
|
|
import Foundation
|
|
import RxSwift
|
|
#if !targetEnvironment(simulator)
|
|
import GeYanSdk
|
|
#endif
|
|
|
|
final class LoginViewModel: BaseViewModel {
|
|
|
|
/// 验证码接口返回值
|
|
var timestamp: String = ""
|
|
|
|
let oneClickLoginResult = PublishSubject<Bool>()
|
|
let loginSuccess = PublishSubject<Void>()
|
|
|
|
var gyAuthVM: GyAuthViewModel {
|
|
let viewModel = GyAuthViewModel()
|
|
viewModel.statusBarStyle = .default
|
|
viewModel.userInterfaceStyle = 0
|
|
viewModel.pullAuthVCStyle = .push
|
|
viewModel.viewLifeCycleBlock = { (str, bool) in
|
|
|
|
}
|
|
viewModel.clickAuthButtonBlock = {
|
|
return true
|
|
}
|
|
return viewModel
|
|
}
|
|
|
|
/// 登录
|
|
func loginAction(type: String, data: [String : Any]) {
|
|
DLToast.showLoading()
|
|
UserService.login(type: type, data: data).subscribe { response in
|
|
guard let model = response.model else { return }
|
|
if AppContextManager.shared.saveAccount(model) {
|
|
DLToast.showSuccess(text: "登录成功") {
|
|
AppRouter.shared.popToRoot()
|
|
}
|
|
}
|
|
else {
|
|
DLToast.show(text: "登录失败,请重新尝试")
|
|
}
|
|
}.disposed(by: disposeBag)
|
|
}
|
|
|
|
func performGuestLogin() {
|
|
loginSuccess.onNext(())
|
|
}
|
|
|
|
func performWechatLogin() {
|
|
// TODO: Integrate WeChat SDK
|
|
}
|
|
|
|
func performAppleLogin() {
|
|
// TODO: Integrate Sign in with Apple
|
|
}
|
|
|
|
func performQQLogin() {
|
|
// TODO: Integrate QQ SDK
|
|
}
|
|
}
|