PQSingletoMemoryUtil.swift 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. //
  2. // PQSingletoMemoryUtil.swift
  3. // PQSpeed
  4. //
  5. // Created by SanW on 2020/6/9.
  6. // Copyright © 2020 BytesFlow. All rights reserved.
  7. //
  8. import UIKit
  9. import Photos
  10. import BFCommonKit
  11. // MARK: - 内存缓存数据
  12. /// 内存缓存数据r
  13. public class PQSingletoMemoryUtil: NSObject {
  14. public static let shared = PQSingletoMemoryUtil()
  15. public var isShowAttendPoint: Bool = false // 是否有关注更新
  16. public var attendIdosUpdateCount: Int = 0 // 关注更新条数
  17. public var isLeftSlipRemind: Bool = false
  18. public var needLogin: Bool = false // 是否需要显示手机登录
  19. public var isFinishedCoging: Bool = false // 是否已完成配置请求
  20. public var isFinishedAlias: Bool = false // 是否完成绑定别名
  21. public var selectedTabIndex: String?
  22. public var commandVideoItem: BFVideoItemProtocol? // 口令内容
  23. public var commandLaunchParams: String = "" // 口令启动时的值
  24. public var commandReportParams: [String: Any]? // 口令启动时解析的其他值
  25. public var h5MsgVid: String? // 剪切板id
  26. public var isShowNoWiFiRemind: Bool = false // 是否提示过非WiFi提示
  27. public var isNeedRefreshAttend: Bool = false // 是否需要刷新关注
  28. public var isNeedRefreshJoinTopic: Bool = false // 是否需要刷新加入的话题
  29. // 剪切板content是否为空,如果为空走承接逻辑,冷启动不再加载缓存
  30. public var isEmptyPasteContent: Bool = false {
  31. didSet {
  32. BFLog(message: "isEmptyPasteContent = \(isEmptyPasteContent)")
  33. }
  34. }
  35. // 展示无服务提示视图(剪切板 data.reportData.downloadButtonType为 weapp_share_noServiceDownloadApp/weapp_categoryTab_noServiceDownloadApp
  36. public var isShowPasteNoServeView: Bool = false {
  37. didSet {
  38. BFLog(message: "isShowPasteNoServeView = \(isShowPasteNoServeView)")
  39. }
  40. }
  41. /// 是否正在展示广告view
  42. public var isLoadingSplashAdView: Bool = false {
  43. didSet {
  44. BFLog(message: "isLoadingSplashAdView = \(isLoadingSplashAdView)")
  45. }
  46. }
  47. public var cutBoardInfo: String? // 剪切板信息
  48. public var cutBoard: String? // 剪切板来源cutBoardInfo
  49. public var isPushLoading: Bool = false // 是否正在加载推送数据
  50. public var coldLaunchType: coldLaunchType?
  51. public var isColdLaunch: Bool = false // 冷启动
  52. public var coldLaunchStatus: Int = 0 // 1-请求中 2-请求成功 3-请求失败
  53. public var deviceToken: String = "" // 推送deviceToken
  54. public var activityData: Dictionary<String,Any>? // 活动数据信息
  55. public var isShowTodaySuccess: Bool = false // 是否已经展示过今日已完成
  56. public var sessionId: String = getUniqueId(desc: "sessionId")
  57. public var subSessionid: String?
  58. public var isDefaultAtten: Bool = false // 是否默认进入关注
  59. public var isDefaultMineSingleVideoDetail: Bool = false // 是否默认进入我的单个视频详情
  60. public var playCount: Int = 0 // 播放次数
  61. public var uploadDatas: [BFVideoItemProtocol] = Array<BFVideoItemProtocol>.init() // 正在上传的视频集合
  62. public var isShowUpSlideGuide: Bool = false // 是否展示了滑动向上的提示
  63. public var showUpSlideData: PQVideoListModel? // 是否展示了滑动向上的提示
  64. public var makeVideoProjectId: String? // 制作视频项目Id
  65. public var draftboxId: String? // 草稿箱ID
  66. // add by ak 结构化数据 saveDraft api 要 用到的参数
  67. public var sdata: String?
  68. // add by ak 结构化数据 saveDraft api 要 用到的参数
  69. public var title: String?
  70. // add by ak 结构化数据 saveDraft api 要 用到的参数
  71. public var coverUrl: String?
  72. // 未读数字
  73. public var unReadInfo: Dictionary<String,Any>?
  74. public var abInfoData: [String: Any] = Dictionary<String, Any>.init() // 实验数据
  75. public var allExportSession: [PHAsset:AVAssetExportSession] = [PHAsset:AVAssetExportSession].init()
  76. public func updateTabPoint() {
  77. // let tabBar =
  78. // rootViewController()?.tabBar
  79. // if isShowAttendPoint {
  80. // tabBar?.showPoint(index: 1)
  81. // } else {
  82. //// tabBar.removePoint(index: 1)
  83. // }
  84. }
  85. /// 创建sessionId
  86. /// - Returns: <#description#>
  87. public func createSesstionId() {
  88. sessionId = getUniqueId(desc: "sessionId")
  89. subSessionid = sessionId
  90. BFLog(message: "生成的sessionId = \(sessionId)")
  91. }
  92. /// 创建subSessionid
  93. /// - Returns: <#description#>
  94. public func createSubSesstionId() {
  95. subSessionid = getUniqueId(desc: "subSessionid")
  96. BFLog(message: "生成的subSessionid = \(String(describing: subSessionid))")
  97. }
  98. /// 制作视频项目Id
  99. /// - Returns: <#description#>
  100. public func createMakeVideoProjectId() {
  101. makeVideoProjectId = cProjectIdPrefix + getUniqueId(desc: "makeVideoProjectId")
  102. BFLog(message: "生成的projectId = \(String(describing: makeVideoProjectId))")
  103. }
  104. /// 解析abInfoData
  105. /// - Parameter abInfo: <#abInfo description#>
  106. /// - Returns: description
  107. public func parasABinfoData(abInfo: String?) {
  108. if abInfo != nil, (abInfo?.count ?? 0) > 0, abInfo != "{}" {
  109. guard let infoDic = jsonStringToDictionary(abInfo!) else { return }
  110. abInfoData.merge(infoDic, uniquingKeysWith: { (key, _) -> Any in
  111. key
  112. })
  113. BFLog(message: "=====abInfoData = \(abInfoData)")
  114. }
  115. }
  116. override private init() {
  117. super.init()
  118. selectedTabIndex = getUserDefaults(key: cSelectedTabIndex) as? String
  119. if selectedTabIndex == nil {
  120. saveUserDefaults(key: cSelectedTabIndex, value: "categoryTab")
  121. selectedTabIndex = "categoryTab"
  122. }
  123. }
  124. public override func copy() -> Any {
  125. return self
  126. }
  127. public override func mutableCopy() -> Any {
  128. return self
  129. }
  130. }