LocalManager.swift 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. //
  2. // LocalManager.swift
  3. // SwiftBilibili
  4. //
  5. // Created by 罗文 on 2021/3/23.
  6. // Copyright © 2021年 罗文. All rights reserved.
  7. //
  8. import UIKit
  9. import SwiftyUserDefaults
  10. import RxSwift
  11. class LocalManager {
  12. static var disposeBag = DisposeBag()
  13. static let loginService: LoginServiceType = LoginService(networking: LoginNetworking())
  14. //本地用户信息
  15. static var userInfo: UserInfo = UserInfo()
  16. //清理
  17. class func clearUserInfo() {
  18. }
  19. //自动登录
  20. static func autoLogin(){
  21. if LocalManager.userInfo.isLogin {
  22. let account = LocalManager.userInfo.userAccount!
  23. let password = LocalManager.userInfo.password!
  24. let city = LocalManager.userInfo.city!
  25. LocalManager.loginService.loginRequest(user_name: account, user_password: password,city: city)
  26. .subscribe(onSuccess: { userinfo in
  27. NYTips.hide()
  28. LocalManager.userInfo = userinfo
  29. }, onError: { error in
  30. })
  31. .disposed(by: LocalManager.disposeBag)
  32. }
  33. }
  34. }