jsdw_ios/QuickLocation/Section/Login/LoginViewModel.swift

66 lines
1.7 KiB
Swift

//
// LoginViewModel.swift
// QuickLocation
//
import Foundation
import RxSwift
import SwiftyUserDefaults
#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
GroupIMService.shared.logout()
DLToast.dismiss()
guard let model = response.model else { return }
Defaults[\.loginToken] = model.token
DLToast.showSuccess(text: "登录成功") {
NotificationCenter.default.post(name: .RefreshUserConfigNotification, object: nil)
AppRouter.shared.popOrDismiss()
}
}.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
}
}