修复bug
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
import Foundation
|
||||
import RxSwift
|
||||
import NIMSDK
|
||||
import MBProgressHUD
|
||||
class AuthViewModel: NSObject {
|
||||
static let authVM = AuthViewModel.init()
|
||||
let data = PublishSubject<Bool>()
|
||||
@@ -56,8 +57,13 @@ class AuthViewModel: NSObject {
|
||||
///账号密码登录
|
||||
func authPhoneCode(phone:String, code:String) {
|
||||
if let phoneDes = phone.encrypt() {
|
||||
MBProgressHUD.showAdded(to: UIApplication.shared.keyWindow!, animated: true)
|
||||
let params = ["phone":phoneDes, "code":code, "client_secret":"uyzjdhds", "version":"1", "client_id":"erban-client", "grant_type":"password"]
|
||||
RequestPost(path: "oauth/token", parma: params) { data in
|
||||
if let window = UIApplication.shared.keyWindow{
|
||||
MBProgressHUD.hide(for: window, animated: true)
|
||||
}
|
||||
|
||||
if let account = Deserialized<UserTokenObject>.toModel(with: data) {
|
||||
LoginTokenConfig.config.saveTokenToLocaltion(token: account)
|
||||
self.token.onNext(account)
|
||||
@@ -68,6 +74,10 @@ class AuthViewModel: NSObject {
|
||||
}
|
||||
}
|
||||
} fail: { code, data in
|
||||
if let window = UIApplication.shared.keyWindow{
|
||||
MBProgressHUD.hide(for: window, animated: true)
|
||||
}
|
||||
HUDTool.show(with: data)
|
||||
self.token.onNext(nil)
|
||||
self.token.onCompleted()
|
||||
}
|
||||
@@ -78,8 +88,13 @@ class AuthViewModel: NSObject {
|
||||
///ID登录
|
||||
func authIDPassword(account:String, password: String) {
|
||||
if let phoneDes = account.encrypt(), let pwdDes = password.encrypt() {
|
||||
MBProgressHUD.showAdded(to: UIApplication.shared.keyWindow!, animated: true)
|
||||
let params = ["phone":phoneDes, "password":pwdDes, "client_secret":"uyzjdhds", "version":"1", "client_id":"erban-client", "grant_type":"password"]
|
||||
RequestPost(path: "oauth/token", parma: params) { data in
|
||||
if let window = UIApplication.shared.keyWindow{
|
||||
MBProgressHUD.hide(for: window, animated: true)
|
||||
}
|
||||
|
||||
if let account = Deserialized<UserTokenObject>.toModel(with: data) {
|
||||
LoginTokenConfig.config.saveTokenToLocaltion(token: account)
|
||||
self.token.onNext(account)
|
||||
@@ -90,6 +105,10 @@ class AuthViewModel: NSObject {
|
||||
}
|
||||
}
|
||||
} fail: { code, data in
|
||||
if let window = UIApplication.shared.keyWindow{
|
||||
MBProgressHUD.hide(for: window, animated: true)
|
||||
}
|
||||
HUDTool.show(with: data)
|
||||
self.token.onNext(nil)
|
||||
self.token.onCompleted()
|
||||
}
|
||||
|
Reference in New Issue
Block a user