Browse Source

1.拆上传库BFUploadKit 2.取消全局引用、

wenweiwei 3 years ago
parent
commit
e336a23c40

+ 11 - 0
BFCommonKit/Classes/BFEnums/Enums.swift

@@ -970,3 +970,14 @@ public enum createStickersModel: Int {
     case createStickersModelSpeed = 2 // 快慢速
     case createStickersModelOnlyMusic = 3 // 仅配乐
 }
+
+// MARK: - 下载状态
+
+/// 下载状态
+public enum downloadState: Int {
+    case downloading = 0 // 下载中
+    case compelte = 1 // 下载完成
+    case error = 2 // 下载失败
+    case pause = 3 // 暂停下载
+    case cancel = 4 // 取消下载
+}

+ 182 - 0
BFCommonKit/Classes/BFModels/PQLoginUserInfo.swift

@@ -0,0 +1,182 @@
+//
+//  BFLoginUserInfo.swift
+//  PQSpeed
+//
+//  Created by SanW on 2020/5/27.
+//  Copyright © 2020 BytesFlow. All rights reserved.
+//
+
+import UIKit
+import BFCommonKit
+
+// MARK: - 登录用户信息
+
+/// 登录用户信息s
+public class BFLoginUserInfo: NSObject {
+    static public let shared = BFLoginUserInfo()
+    public var uid: String = "" // 账号
+    public  var userCode: String = "" // 账号
+    public var accessToken: String = "" // token
+    public var avatarUrl: String = "" // 头像
+    public var city: String = "" // 城市
+    public var province: String = "" // 省市
+    public  var country: String = "" // 国家
+    public  var phoneNumber: String = "" // 电话
+    public var openId: String = "" // 微信openId
+    public var nickName: String = "" // 昵称
+    public var gender: String = "" // 性别
+    public var expiredTime: String = "" // 过期时间
+    public var videos: String = "0" // 视频数
+    public  var idols: String = "0" // 关注数
+    public var fans: String = "0" // 粉丝数
+    public var otherSubscribes: String = "0" // 别人订阅我的数量
+    public  var userStatus: String = "1" // 1有效,2 已删除,3 已屏蔽,4 敏感
+    public var isVirtualUser: Bool = false // 是否是虚拟账号
+    public  var mid = getMachineCode() // 设备ID
+
+    @objc  public  func toString() -> String {
+        let json: [String: Any] = [
+            "accessToken": accessToken,
+            "avatarUrl": avatarUrl,
+            "city": city,
+            "country": country,
+            "gender": gender,
+            "nickName": nickName,
+            "openId": openId,
+            "phoneNumber": phoneNumber,
+            "province": province,
+            "uid": uid,
+            "userCode": userCode,
+            "expiredTime": expiredTime,
+            "videos": videos,
+            "idols": idols,
+            "fans": fans,
+            "userStatus": userStatus,
+            "isVirtualUser": isVirtualUser,
+            "mid": mid,
+        ]
+        return dictionaryToJsonString(json) ?? ""
+    }
+
+    override public init() {
+        super.init()
+        resetData(isClear: false)
+        if getUserDefaults(key: cMineVideos) != nil {
+            videos = getUserDefaults(key: cMineVideos) as! String
+        }
+        if getUserDefaults(key: cMineIdols) != nil {
+            idols = getUserDefaults(key: cMineIdols) as! String
+        }
+        if getUserDefaults(key: cMineFans) != nil {
+            fans = getUserDefaults(key: cMineFans) as! String
+        }
+        if getUserDefaults(key: cOtherSubscribes) != nil {
+            otherSubscribes = getUserDefaults(key: cOtherSubscribes) as! String
+        }
+        if getUserDefaults(key: cAvatarUrl) != nil {
+            avatarUrl = getUserDefaults(key: cAvatarUrl) as! String
+        }
+        if getUserDefaults(key: cUpdatePhone) != nil {
+            phoneNumber = getUserDefaults(key: cUpdatePhone) as! String
+        }
+    }
+
+    @objc  public  func resetData(isClear: Bool) {
+        if isClear {
+            UserDefaults.standard.removeObject(forKey: cUserInfoStorageKey)
+            UserDefaults.standard.removeObject(forKey: cMineVideos)
+            UserDefaults.standard.removeObject(forKey: cMineFans)
+            UserDefaults.standard.removeObject(forKey: cOtherSubscribes)
+            UserDefaults.standard.removeObject(forKey: cMineIdols)
+            UserDefaults.standard.removeObject(forKey: cAvatarUrl)
+            UserDefaults.standard.removeObject(forKey: cUpdatePhone)
+            UserDefaults.standard.synchronize()
+
+            accessToken = ""
+            avatarUrl = ""
+            city = ""
+            country = ""
+            gender = ""
+            nickName = ""
+            openId = ""
+            phoneNumber = ""
+            province = ""
+            uid = ""
+            userCode = ""
+            expiredTime = ""
+            videos = "0"
+            idols = "0"
+            fans = "0"
+            userStatus = "1"
+            isVirtualUser = false
+            mid = ""
+            return
+        }
+        let userInfo: [String: Any] = jsonStringToDictionary(UserDefaults.standard.string(forKey: cUserInfoStorageKey) ?? "") ?? [:]
+        updateData(userInfo: userInfo)
+    }
+
+    public  func updateData(userInfo: [String: Any]?) {
+        if userInfo != nil, userInfo?.count ?? 0 > 0 {
+            accessToken = "\(userInfo?["accessToken"] ?? "")"
+            if userInfo?.keys.contains("token") ?? false {
+                accessToken = "\(userInfo?["token"] ?? "")"
+            }
+            avatarUrl = "\(userInfo?["avatarUrl"] ?? "")"
+            city = "\(userInfo?["city"] ?? "")"
+            country = "\(userInfo?["country"] ?? "")"
+            gender = "\(userInfo?["gender"] ?? "")"
+            nickName = "\(userInfo?["nickName"] ?? "")"
+            openId = "\(userInfo?["openId"] ?? "")"
+            if userInfo?.keys.contains("phoneNumber") ?? false, !(userInfo?["phoneNumber"] is NSNull) {
+                phoneNumber = "\(userInfo?["phoneNumber"] ?? "")"
+            }
+            if userInfo?.keys.contains("userStatus") ?? false, !(userInfo?["userStatus"] is NSNull) {
+                userStatus = "\(userInfo?["userStatus"] ?? "")"
+            }
+            if userInfo?.keys.contains("mid") ?? false, !(userInfo?["mid"] is NSNull) {
+                mid = "\(userInfo?["mid"] ?? "")"
+            }
+            if userInfo?.keys.contains("isVirtualUser") ?? false, !(userInfo?["isVirtualUser"] is NSNull) {
+                isVirtualUser = (userInfo?["isVirtualUser"] as? Bool) ?? false
+            }
+            province = "\(userInfo?["province"] ?? "")"
+            uid = "\(userInfo?["uid"] ?? "")"
+            userCode = "\(userInfo?["userCode"] ?? "")"
+            expiredTime = "\(userInfo?["expiredTime"] ?? "")"
+            if getUserDefaults(key: cMineVideos) != nil {
+                videos = getUserDefaults(key: cMineVideos) as! String
+            }
+            if getUserDefaults(key: cAvatarUrl) != nil {
+                avatarUrl = getUserDefaults(key: cAvatarUrl) as! String
+            }
+            if getUserDefaults(key: cUpdatePhone) != nil {
+                phoneNumber = getUserDefaults(key: cUpdatePhone) as! String
+            }
+            if getUserDefaults(key: cMineIdols) != nil {
+                idols = getUserDefaults(key: cMineIdols) as! String
+            }
+            if getUserDefaults(key: cMineFans) != nil {
+                fans = getUserDefaults(key: cMineFans) as! String
+            }
+            if getUserDefaults(key: cOtherSubscribes) != nil {
+                otherSubscribes = getUserDefaults(key: cOtherSubscribes) as! String
+            }
+            BFConfig.shared.token = accessToken
+            BFConfig.shared.loginUid = uid
+            BFConfig.shared.uid = uid
+        }
+    }
+
+    public  func isLogin() -> Bool {
+        return accessToken.count > 0
+    }
+
+    public override func copy() -> Any {
+        return self
+    }
+
+    public override func mutableCopy() -> Any {
+        return self
+    }
+}

+ 0 - 31
BFCommonKit/Classes/BFModels/PQUploadModel.swift

@@ -1,31 +0,0 @@
-
-//
-//  PQUploadModel.swift
-//  PQSpeed
-//
-//  Created by SanW on 2020/8/1.
-//  Copyright © 2020 BytesFlow. All rights reserved.
-//
-
-import Photos
-import UIKit
-
-open class PQUploadModel: BFBaseModel {
-   public var image: UIImage? // 图片
-   public var localPath: String? // 地址
-   public var duration: TimeInterval = 0 // 时间
-   public var asset: PHAsset? // 视频资源
-   public var videoBucketKey: String? // 上传视频功能
-   public var imageBucketKey: String? // 上传图片地址
-   public var assetCollection: PHAssetCollection? // 相簿
-   public var categoryList: PHFetchResult<PHAsset> = PHFetchResult<PHAsset>.init() // 子相册集合
-   public var assetList: [PHAsset] = Array<PHAsset>.init() // 子相册集合
-   public var uploadID: String? // 上传ID
-   public var videoWidth: CGFloat = 0 // 视频宽
-   public var videoHeight: CGFloat = 0 // 视频高
-   public var contentMode: UIView.ContentMode = .scaleAspectFill
-   public var stsToken: [String: Any]? // 上传信息
-
-    // add by ak 上传来源类型
-   public var videoFromScene: videoFromScene = .UploadNormal
-}

+ 175 - 0
BFCommonKit/Classes/BFModels/PQUserInfoModel.swift

@@ -0,0 +1,175 @@
+//
+//  PQUserInfoModel.swift
+//  PQSpeed
+//
+//  Created by SanW on 2020/5/27.
+//  Copyright © 2020 BytesFlow. All rights reserved.
+//
+
+import UIKit
+import BFCommonKit
+
+open class PQUserInfoModel: BFBaseModel {
+    public  var avatarUrl: String? // 头像地址
+    public var backgroundImage: String? // 背景图
+
+    public var bothFollow: Bool = false // 是否相互关注
+    public var fans: Int = 0 // 粉丝数
+    public var followed: Int = 0 // 是否关注
+    public var idols: Int = 0 // 关注的人数
+    public var introduction: String?
+    public var nickName: String? // 昵称
+
+    public var otherVideoShowCount: Int = 0
+    public var playCountTotal: Int = 0 // 用户视频总播放数,按人去重 ,
+    public var playCountFormatStr: String? // 用户视频总播放数,格式化后的值,前端直接显示 ,
+    public var positionType: Int = 0
+    public var sensitiveStatus: Int = 0
+    public var subscribeStatus: Int = 0 // 0:未订阅,1:已订阅
+    public var mySubscribes: Int = 0 // 我的订阅数
+    public var otherSubscribes: Int = 0 // 别人订阅我的数量
+    public var uid: Int = 0
+    public var uploadDate: String?
+    public var userType: Int = 0
+    public var videos: Int = 0 // 视频数
+    public var videosDescr: String = "0" // 视频数
+    public var vipStatus: Int = 0 // vip状态,0:不是vip,1:是vip
+    public var vipDesc: String? // vip身份描述
+    public var tagList: [String]? // 标签
+    public var picPathList: [[String: Any]]? // 推荐列表
+    public var isLoginUser: Bool = false // 是否是登录用户
+    public var gmtCreateTimestamp: Int = 0
+    public var intimacy: Int = 0
+    public var isBothFollow: Int = 0 // 是否相互关注 ,
+    public var isFollowed: Bool = false // 是否关注
+    public var lastTimestamp: Int = 0
+    public var latestSendvideoId: Int = 0
+    public var updated: Int = 0
+    public var favoriteCount: Int = 0 // 喜欢的视频数
+    public var shareCount: Int = 0 // 分享的视频数
+    public var isBanned: Bool = false // 是否被拉黑
+    public var tab_pageType: TAB_PAGETYPE = .TAB_PAGETYPE_NORMAL // 0-推荐 1-关注
+
+    required public init() {
+        super.init()
+    }
+
+    public override init(jsonDict: [String: Any]) {
+        super.init()
+        if jsonDict.keys.contains("avatarUrl") {
+            avatarUrl = "\(jsonDict["avatarUrl"] ?? "")"
+        }
+        if jsonDict.keys.contains("bothFollow") {
+            bothFollow = Bool("\(jsonDict["bothFollow"] ?? "")") ?? false
+        }
+        if jsonDict.keys.contains("fans") {
+            fans = Int("\(jsonDict["fans"] ?? "0")") ?? 0
+        }
+        if jsonDict.keys.contains("followed") {
+            followed = Int("\(jsonDict["followed"] ?? "0")") ?? 0
+        }
+        if jsonDict.keys.contains("idols") {
+            idols = Int("\(jsonDict["idols"] ?? "0")") ?? 0
+        }
+        if jsonDict.keys.contains("introduction") {
+            introduction = "\(jsonDict["introduction"] ?? "0")"
+        }
+        if jsonDict.keys.contains("nickName") {
+            nickName = "\(jsonDict["nickName"] ?? "0")"
+        }
+        if jsonDict.keys.contains("otherVideoShowCount") {
+            otherVideoShowCount = Int("\(jsonDict["otherVideoShowCount"] ?? "0")") ?? 0
+        }
+        if jsonDict.keys.contains("playCountTotal") {
+            playCountTotal = Int("\(jsonDict["playCountTotal"] ?? "0")") ?? 0
+        }
+        if jsonDict.keys.contains("playCountFormatStr") {
+            playCountFormatStr = "\(jsonDict["playCountFormatStr"] ?? "0")"
+        }
+        if jsonDict.keys.contains("positionType") {
+            positionType = Int("\(jsonDict["positionType"] ?? "0")") ?? 0
+        }
+        if jsonDict.keys.contains("favoriteCount") {
+            favoriteCount = Int("\(jsonDict["favoriteCount"] ?? "0")") ?? 0
+        }
+        if jsonDict.keys.contains("shareCount") {
+            shareCount = Int("\(jsonDict["shareCount"] ?? "0")") ?? 0
+        }
+        if jsonDict.keys.contains("sensitiveStatus") {
+            sensitiveStatus = Int("\(jsonDict["sensitiveStatus"] ?? "0")") ?? 0
+        }
+        if jsonDict.keys.contains("subscribeStatus") {
+            subscribeStatus = Int("\(jsonDict["subscribeStatus"] ?? "0")") ?? 0
+        }
+        if jsonDict.keys.contains("mySubscribes") {
+            mySubscribes = Int("\(jsonDict["mySubscribes"] ?? "0")") ?? 0
+        }
+        if jsonDict.keys.contains("otherSubscribes") {
+            otherSubscribes = Int("\(jsonDict["otherSubscribes"] ?? "0")") ?? 0
+        }
+        if jsonDict.keys.contains("uid") {
+            uid = Int("\(jsonDict["uid"] ?? "0")") ?? 0
+        }
+        if jsonDict.keys.contains("uploadDate") {
+            uploadDate = "\(jsonDict["uploadDate"] ?? "0")"
+        }
+        if jsonDict.keys.contains("userType") {
+            userType = Int("\(jsonDict["userType"] ?? "0")") ?? 0
+        }
+        if jsonDict.keys.contains("videos") {
+            videos = Int("\(jsonDict["videos"] ?? "0")") ?? 0
+        }
+        if jsonDict.keys.contains("videosDescr") {
+            videosDescr = "\(jsonDict["videosDescr"] ?? "")"
+        }
+        if jsonDict.keys.contains("vipStatus") {
+            vipStatus = Int("\(jsonDict["vipStatus"] ?? "0")") ?? 0
+        }
+        if jsonDict.keys.contains("tagList") {
+            tagList = jsonDict["tagList"] as? [String]
+        }
+        if jsonDict.keys.contains("picPathList") {
+            picPathList = jsonDict["picPathList"] as? [[String: Any]]
+        }
+        if jsonDict.keys.contains("vipDesc") {
+            vipDesc = "\(jsonDict["vipDesc"] ?? "")"
+        }
+        if jsonDict.keys.contains("isLoginUser") {
+            isLoginUser = Bool("\(jsonDict["isLoginUser"] ?? "")") ?? false
+        }
+        if jsonDict.keys.contains("gmtCreateTimestamp") {
+            gmtCreateTimestamp = Int("\(jsonDict["gmtCreateTimestamp"] ?? "0")") ?? 0
+        }
+        if jsonDict.keys.contains("intimacy") {
+            intimacy = Int("\(jsonDict["intimacy"] ?? "0")") ?? 0
+        }
+        if jsonDict.keys.contains("isBothFollow") {
+            isBothFollow = Int("\(jsonDict["isBothFollow"] ?? "0")") ?? 0
+        }
+        if jsonDict.keys.contains("isFollowed") {
+            isFollowed = jsonDict["isFollowed"] as! Bool
+        }
+        if jsonDict.keys.contains("lastTimestamp") {
+            lastTimestamp = Int("\(jsonDict["lastTimestamp"] ?? "0")") ?? 0
+        }
+        if jsonDict.keys.contains("latestSendvideoId") {
+            latestSendvideoId = Int("\(jsonDict["latestSendvideoId"] ?? "0")") ?? 0
+        }
+        if jsonDict.keys.contains("updated") {
+            updated = Int("\(jsonDict["updated"] ?? "0")") ?? 0
+        }
+    }
+
+    /// 创建虚拟用户数据
+    /// - Parameter virtual: <#virtual description#>
+   public init(avatarIcon: String?, userName: String?) {
+        super.init()
+        avatarUrl = avatarIcon
+        nickName = userName
+        fans = Int(arc4random() % 10)
+        followed = Int(arc4random() % 10)
+        idols = Int(arc4random() % 10)
+        mySubscribes = Int(arc4random() % 10)
+        otherSubscribes = Int(arc4random() % 10)
+    }
+}