Browse Source

1.我的页空白适配

wenweiwei 3 years ago
parent
commit
d3ed74e4cb

+ 4 - 0
MusicVideoPlus.xcodeproj/project.pbxproj

@@ -18,6 +18,7 @@
 		2D9630E12682096900AE6FFE /* PQCollectionViewFlowlayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D9630E02682096900AE6FFE /* PQCollectionViewFlowlayout.swift */; };
 		2D9630E326820B1900AE6FFE /* MVMineProductCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D9630E226820B1900AE6FFE /* MVMineProductCell.swift */; };
 		2D9630E52682D14500AE6FFE /* MVMineHeadInfoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D9630E42682D14500AE6FFE /* MVMineHeadInfoView.swift */; };
+		2D9630E72683534B00AE6FFE /* MVProductEmptyView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D9630E62683534B00AE6FFE /* MVProductEmptyView.swift */; };
 		4112DD832669BFA600A5AFD9 /* MVBanner.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4112DD822669BFA600A5AFD9 /* MVBanner.swift */; };
 		4112DD862669BFFA00A5AFD9 /* MVBannerFlowLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4112DD852669BFFA00A5AFD9 /* MVBannerFlowLayout.swift */; };
 		4112DD912669C11C00A5AFD9 /* MVBannerCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4112DD902669C11C00A5AFD9 /* MVBannerCell.swift */; };
@@ -49,6 +50,7 @@
 		2D9630E02682096900AE6FFE /* PQCollectionViewFlowlayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PQCollectionViewFlowlayout.swift; sourceTree = "<group>"; };
 		2D9630E226820B1900AE6FFE /* MVMineProductCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MVMineProductCell.swift; sourceTree = "<group>"; };
 		2D9630E42682D14500AE6FFE /* MVMineHeadInfoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MVMineHeadInfoView.swift; sourceTree = "<group>"; };
+		2D9630E62683534B00AE6FFE /* MVProductEmptyView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MVProductEmptyView.swift; sourceTree = "<group>"; };
 		3FA19A38D145C54301B3CD85 /* Pods_MusicVideoPlus.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_MusicVideoPlus.framework; sourceTree = BUILT_PRODUCTS_DIR; };
 		4112DCF02668C45B00A5AFD9 /* MusicVideoPlus.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = MusicVideoPlus.entitlements; sourceTree = "<group>"; };
 		4112DD492668D6A600A5AFD9 /* MusicVideoPlus-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "MusicVideoPlus-Bridging-Header.h"; sourceTree = "<group>"; };
@@ -117,6 +119,7 @@
 			children = (
 				2D9630E226820B1900AE6FFE /* MVMineProductCell.swift */,
 				2D9630E42682D14500AE6FFE /* MVMineHeadInfoView.swift */,
+				2D9630E62683534B00AE6FFE /* MVProductEmptyView.swift */,
 			);
 			path = Views;
 			sourceTree = "<group>";
@@ -597,6 +600,7 @@
 				2D9630D92681947300AE6FFE /* MVRequestURLUtil.swift in Sources */,
 				2D9630E326820B1900AE6FFE /* MVMineProductCell.swift in Sources */,
 				417D86A7266A3CC900DA2444 /* MVHotVideoModel.swift in Sources */,
+				2D9630E72683534B00AE6FFE /* MVProductEmptyView.swift in Sources */,
 				2D9630D52681874D00AE6FFE /* MVPlayControlViewCell.swift in Sources */,
 				2D9630DE268206F300AE6FFE /* MVMineProductController.swift in Sources */,
 				4149C8932669FE6F0055CAA2 /* MVTagsCell.swift in Sources */,

+ 22 - 0
MusicVideoPlus/Assets.xcassets/Home/empty_mine_product.imageset/Contents.json

@@ -0,0 +1,22 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "scale" : "1x"
+    },
+    {
+      "filename" : "empty_mine_product@2x.png",
+      "idiom" : "universal",
+      "scale" : "2x"
+    },
+    {
+      "filename" : "empty_mine_product@3x.png",
+      "idiom" : "universal",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  }
+}

BIN
MusicVideoPlus/Assets.xcassets/Home/empty_mine_product.imageset/empty_mine_product@2x.png


BIN
MusicVideoPlus/Assets.xcassets/Home/empty_mine_product.imageset/empty_mine_product@3x.png


+ 3 - 0
MusicVideoPlus/Classes/Modules/Home/Controllers/MVPlayViewController.swift

@@ -55,6 +55,9 @@ class MVPlayViewController: PQBaseViewController {
         }
         if currentIndex != nil, itemsList.count > (currentIndex?.item ?? 0) {
             collectionView.contentOffset = CGPoint(x: 0, y: CGFloat(currentIndex?.item ?? 0) * view.frame.size.height)
+            DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.2) { [weak self] in
+                self?.scrollViewDidEndDecelerating(self!.collectionView)
+            }
         }
 
         PQSingletoVideoPlayer.shared.playStatusBloc = { [weak self] status in

+ 44 - 9
MusicVideoPlus/Classes/Modules/Mine/Controllers/MVMineProductController.swift

@@ -43,13 +43,29 @@ class MVMineProductController: PQBaseViewController {
         return proCollectView
     }()
 
+    lazy var emptyView: MVProductEmptyView = {
+        let emptyView = MVProductEmptyView.init(frame: CGRect.init(x: 0, y: headH, width: collectionView.frame.width, height: collectionView.frame.height - headH))
+        emptyView.btnClickHandle = {[weak self] sender in
+            let vc = PQStuckPointMaterialController()
+            self?.navigationController?.pushViewController(vc, animated: true)
+        }
+        emptyView.isHidden = true
+        return emptyView
+    }()
     override func viewDidLoad() {
         super.viewDidLoad()
         view.addSubview(collectionView)
+        collectionView.addSubview(emptyView)
         collectionView.addSubview(headInfoView)
         leftBackButton()
         loadRequestData()
         setTitle(title: BFLoginUserInfo.shared.nickName, color: UIColor(white: 0, alpha: 0))
+        MVMineViewModel.userInfoData { [weak self] count, _ in
+            if count != nil {
+                BFLoginUserInfo.shared.videos = "\(count ?? 0)"
+                self?.headInfoView.updateProducts()
+            }
+        }
     }
 
     /// 请求网络数据
@@ -62,19 +78,32 @@ class MVMineProductController: PQBaseViewController {
             pageNum = pageNum + 1
         }
         MVMineViewModel.userVideoListData(pageNum: pageNum) { [weak self] videoList, _ in
-            if videoList != nil, (videoList?.count ?? 0) > 0 {
-                if isRefresh {
-                    self?.itemsList = videoList!
+            if videoList != nil {
+                if (videoList?.count ?? 0) > 0 {
+                    if isRefresh {
+                        self?.itemsList = videoList!
+                    } else {
+                        self?.itemsList = self!.itemsList + videoList!
+                    }
+                    self?.flowLayout.findList = self?.itemsList as! [PQVideoListModel]
+                    self?.collectionView.reloadData()
+                    self?.emptyView.isHidden = true
                 } else {
-                    self?.itemsList = self!.itemsList + videoList!
+                    self?.emptyView.isHidden = false
                 }
-                self?.flowLayout.findList = self?.itemsList as! [PQVideoListModel]
-                self?.collectionView.reloadData()
             } else {
+                cShowHUB(superView: nil, msg: "没有网络连接")
                 self?.pageNum = (self?.pageNum ?? 1) - 1
             }
-            self?.collectionView.mj_header?.endRefreshing()
-            self?.collectionView.mj_footer?.endRefreshing()
+            if isRefresh {
+                self?.collectionView.mj_header?.endRefreshing()
+                self?.collectionView.mj_footer?.resetNoMoreData()
+            } else {
+                self?.collectionView.mj_footer?.endRefreshing()
+            }
+            if (videoList?.count ?? 0) < 20 {
+                self?.collectionView.mj_footer?.endRefreshingWithNoMoreData()
+            }
         }
     }
 }
@@ -94,7 +123,7 @@ extension MVMineProductController: UICollectionViewDelegate, UICollectionViewDat
         return cell
     }
 
-    private func collectionView(collectionView _: UICollectionView, didSelectItemAt indexPath: IndexPath) {
+    func collectionView(_: UICollectionView, didSelectItemAt indexPath: IndexPath) {
         if itemsList[indexPath.item].auditStatus != 5 || itemsList[indexPath.item].transcodeStatus != 3 {
             return
         }
@@ -137,6 +166,10 @@ extension MVMineProductController: UICollectionViewDelegate, UICollectionViewDat
                         })
                         self?.flowLayout.findList = self?.itemsList as! [PQVideoListModel]
                         self?.collectionView.reloadData()
+                        cShowHUB(superView: nil, msg: "删除成功")
+                        if (self?.itemsList.count ?? 0) <= 0 {
+                            self?.loadRequestData()
+                        }
                     }
                 }
             }
@@ -151,4 +184,6 @@ extension MVMineProductController: UICollectionViewDelegate, UICollectionViewDat
         firstBtn?.titleLabel?.font = UIFont.systemFont(ofSize: 18, weight: .semibold)
         seleView.contentView.subviews[2].backgroundColor = UIColor.hexColor(hexadecimal: "#F2F2F2")
     }
+
+    @objc func btnClick(sender _: UIButton) {}
 }

+ 15 - 3
MusicVideoPlus/Classes/Modules/Mine/ViewModel/MVMineViewModel.swift

@@ -9,7 +9,6 @@ import BFFramework
 import UIKit
 
 class MVMineViewModel: NSObject {
-    
     /// 分页获取我的视频
     /// - Parameters:
     ///   - pageNum: 第几页
@@ -21,11 +20,11 @@ class MVMineViewModel: NSObject {
                 completeHander(nil, error?.msg)
             } else {
                 let temResponseArr: [[String: Any]]? = response as? [[String: Any]]
-                if temResponseArr != nil, (temResponseArr?.count ?? 0) > 0 {
+                if temResponseArr != nil {
                     var videoLists = Array<PQVideoListModel>.init()
                     temResponseArr?.forEach { dic in
                         let tempModel = PQVideoListModel(jsonDict: dic)
-                        let userInfo = PQUserInfoModel.init()
+                        let userInfo = PQUserInfoModel()
                         userInfo.nickName = BFLoginUserInfo.shared.nickName
                         tempModel.userInfo = userInfo
                         videoLists.append(tempModel)
@@ -37,4 +36,17 @@ class MVMineViewModel: NSObject {
             }
         }
     }
+
+    /// 获取用户信息
+    /// - Parameter completeHander: <#completeHander description#>
+    class func userInfoData(completeHander: @escaping (_ videoCount: Int?, _ msg: String?) -> Void) {
+        SWNetRequest.postRequestData(url: PQENVUtil.shared.clipapiapi + userInfoUrl, parames: nil) { response, _, error, _ in
+            if response is NSNull || response == nil {
+                completeHander(nil, error?.msg)
+            } else {
+                let videoCount: Int? = Int("\((response as? [String: Any])?["videoCount"] ?? "0")")
+                completeHander(videoCount, error?.msg)
+            }
+        }
+    }
 }

+ 5 - 1
MusicVideoPlus/Classes/Modules/Mine/Views/MVMineHeadInfoView.swift

@@ -57,9 +57,13 @@ class MVMineHeadInfoView: UIView {
     func addData() {
         iconImageView.setNetImage(url: BFLoginUserInfo.shared.avatarUrl, placeholder: UIImage(named: "wode")!)
         nickNameLab.text = BFLoginUserInfo.shared.nickName
-        productsLabel.text = "\(Int(BFLoginUserInfo.shared.videos)?.changeUnit() ?? "0") 作品"
+        updateProducts()
     }
 
+    func updateProducts() -> Void {
+        productsLabel.text = "\(Int(BFLoginUserInfo.shared.videos)?.changeUnit() ?? "0") 作品"
+    }
+    
     func addLayout() {
         let iconH: CGFloat = cDefaultMargin * 7
         let margin: CGFloat = 12

+ 78 - 0
MusicVideoPlus/Classes/Modules/Mine/Views/MVProductEmptyView.swift

@@ -0,0 +1,78 @@
+//
+//  MVProductEmptyView.swift
+//  MusicVideoPlus
+//
+//  Created by SanW on 2021/6/23.
+//
+
+import BFFramework
+import UIKit
+
+class MVProductEmptyView: UIView {
+    var btnClickHandle: ((_ sender: UIButton) -> Void)?
+    lazy var reCreateBtn: UIButton = {
+        let reCreateBtn = UIButton(type: .custom)
+        reCreateBtn.setTitle("制作卡点视频", for: .normal)
+        reCreateBtn.titleLabel?.font = UIFont.systemFont(ofSize: 18, weight: .semibold)
+        reCreateBtn.setTitleColor(UIColor.white, for: .normal)
+        reCreateBtn.addCorner(corner: 8)
+        reCreateBtn.tag = 1
+        reCreateBtn.addTarget(self, action: #selector(btnClick(sender:)), for: .touchUpInside)
+        reCreateBtn.backgroundColor = UIColor(red: 61.0 / 255.0, green: 193.0 / 255.0, blue: 193.0 / 255.0, alpha: 0.8)
+        return reCreateBtn
+    }()
+
+    let emptyImageView: UIImageView = {
+        let emptyImageView = UIImageView(image: UIImage(named: "empty_mine_product"))
+        return emptyImageView
+    }()
+
+    lazy var titleLabel: UILabel = {
+        let titleLabel = UILabel()
+        titleLabel.textColor = UIColor.hexColor(hexadecimal: "#E0E0E0")
+        titleLabel.text = "暂无作品"
+        titleLabel.numberOfLines = 1
+        titleLabel.textAlignment = .center
+        titleLabel.font = UIFont.systemFont(ofSize: 18, weight: .semibold)
+        return titleLabel
+    }()
+
+    override init(frame: CGRect) {
+        super.init(frame: frame)
+        addSubview(emptyImageView)
+        addSubview(titleLabel)
+        addSubview(reCreateBtn)
+    }
+
+    required init?(coder _: NSCoder) {
+        fatalError("init(coder:) has not been implemented")
+    }
+
+    override func layoutSubviews() {
+        super.layoutSubviews()
+        let margin: CGFloat = cDefaultMargin * 2
+        let btnH: CGFloat = cDefaultMargin * 5
+        reCreateBtn.snp.makeConstraints { make in
+            make.left.equalToSuperview().offset(margin)
+            make.right.equalToSuperview().offset(-margin)
+            make.bottom.equalToSuperview().offset(-(btnH + cSafeAreaHeight))
+            make.height.equalTo(btnH)
+        }
+        emptyImageView.snp.makeConstraints { make in
+            make.centerX.equalToSuperview()
+            make.centerY.equalToSuperview().offset(-btnH * 2)
+            make.width.equalTo(margin * 5)
+            make.height.equalTo(margin * 3)
+        }
+        titleLabel.snp.makeConstraints { make in
+            make.left.right.equalToSuperview()
+            make.top.equalTo(emptyImageView.snp_bottom).offset(cDefaultMargin)
+        }
+    }
+
+    @objc func btnClick(sender: UIButton) {
+        if btnClickHandle != nil {
+            btnClickHandle!(sender)
+        }
+    }
+}