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. static var userInfo: UserInfo = UserInfo()
  15. class func clearUserInfo() {
  16. }
  17. //自动登录
  18. static func autoLogin(){
  19. if LocalManager.userInfo.isLogin {
  20. var account = LocalManager.userInfo.userAccount!
  21. var password = LocalManager.userInfo.password!
  22. var city = "3501"
  23. LocalManager.loginService.loginRequest(user_name: account, user_password: password,city: city)
  24. .subscribe(onSuccess: { userinfo in
  25. NYTips.hide()
  26. LocalManager.userInfo = userinfo
  27. }, onError: { error in
  28. })
  29. .disposed(by: LocalManager.disposeBag)
  30. }
  31. }
  32. }