// // LocalManager.swift // SwiftBilibili // // Created by 罗文 on 2021/3/23. // Copyright © 2021年 罗文. All rights reserved. // import UIKit import SwiftyUserDefaults import RxSwift class LocalManager { static var disposeBag = DisposeBag() static let loginService: LoginServiceType = LoginService(networking: LoginNetworking()) //本地用户信息 static var userInfo: UserInfo = UserInfo() //下载地址 static var qr_dwanload_url = "" //清理 class func clearUserInfo() { } //审核account static func isCheckAccount()->Bool{ if LocalManager.userInfo.userAccount == "350211196508204525" { return true } return false } //判断是否登录了 static func isOpenLogin()->Bool{ if !LocalManager.userInfo.isLogin { NYSwRouter.open(NYSwOpenType.login.rawValue) return false } return true } //自动登录 static func autoLogin(){ if LocalManager.userInfo.isLogin { let account = LocalManager.userInfo.userAccount! let password = LocalManager.userInfo.password! let city = LocalManager.userInfo.city! LocalManager.loginService.loginRequest(user_name: account, user_password: password,city: city) .subscribe(onSuccess: { userinfo in NYTips.hide() LocalManager.userInfo = userinfo }, onError: { error in }) .disposed(by: LocalManager.disposeBag) } } //部署信息 static func getDeploydo(){ LocalManager.loginService.dictRequest(dictType: "coach_version").subscribe(onSuccess: { cityItems in for cityItem in cityItems { if cityItem.dictLabel == "ios_version" { LocalManager.userInfo.server_version = cityItem.dictValue.replacingOccurrences(of: ".", with: "") }else if cityItem.dictLabel == "ios_login_open" { LocalManager.userInfo.ios_login_open = Int(cityItem.dictValue) }else if cityItem.dictLabel == "qr_app_download" { LocalManager.qr_dwanload_url = cityItem.dictValue } } },onError: { Error in }).disposed(by: disposeBag) } //验证版本 static func verifyVersiondo(){ LocalManager.loginService.dictRequest(dictType: "coach_version").subscribe(onSuccess: { cityItems in var server_version = "" //服务端版本 var message = "有新版本,请到appstore更新" //提示内容 var isSup = 0 //是否强制更新 for cityItem in cityItems { if cityItem.dictLabel == "ios_version" { server_version = cityItem.dictValue.replacingOccurrences(of: ".", with: "") let array = cityItem.remark.components(separatedBy: ":") if array.count>1 { isSup = Int(array[0])! message = array[1] } break } } //当前版本<服务器ios版本提示更新 let appVersion:String = (NYMacros.appVersion as! String).replacingOccurrences(of: ".", with: "") if Int(appVersion)!