修复bug

This commit is contained in:
liyuhua
2024-03-04 14:14:33 +08:00
parent 268a80f27b
commit 5eddd09197
25 changed files with 5991 additions and 4825 deletions

View File

@@ -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()
}