Parcourir la source

Merge branch 'develop' into feature/jeremy

南鑫林 il y a 5 ans
Parent
commit
7531a9c30a

+ 8 - 3
RainbowPlanet/RainbowPlanet/Base/BaseTabbarViewController/BaseTabbarViewController.swift

@@ -126,9 +126,14 @@ class BaseTabbarViewController: ESTabBarController {
 
         tabBarViewController.didHijackHandler = {
             tabbarController, viewController, index in
-            let pickVc = PublishViewController()
-            let nav = BaseNavigationViewController.init(rootViewController: pickVc)
-            tabbarController.present(nav, animated: true, completion: nil)
+            let isUploadFinish: Bool = PublishUploadManager.shared().isPublishFinished
+            if isUploadFinish {
+                let pickVc = PublishViewController()
+                let nav = BaseNavigationViewController.init(rootViewController: pickVc)
+                tabbarController.present(nav, animated: true, completion: nil)
+            } else {
+                SwiftProgressHUD.shared().showText("内容上传中,请稍等", textAlignment: .center)
+            }
         }
         
         v1.tabBarItem = ESTabBarItem.init(lottieAnimateContentView1, title: "社区", image: UIImage(named: "tabbar_home")?.withRenderingMode(UIImage.RenderingMode.alwaysOriginal), selectedImage: nil)

+ 17 - 1
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/Community/ViewController/Main/CommunityViewController.swift

@@ -231,7 +231,23 @@ class CommunityViewController: BaseViewController {
             WebViewJavascriptBridgeManager.shared.notification(notification: notification,viewController: self)
         }
         
-        PublishUploadProgressView.publishUploadProgressView(attachedView: navigationBarbgView)
+        // 待发布
+        observe = NotificationCenter.default.addObserver(forName: NSNotification.Name("DismissFromPublishEditVc"), object: nil, queue: OperationQueue.main) {[weak self] (notification) in
+            self?.reloadSegmentedFollowView()
+            
+            let progressView = PublishUploadProgressView.publishUploadProgressView(attachedView: (self?.navigationBarbgView)!)
+            
+            let mediaType = notification.object as? PublishMediaType
+            if mediaType == PublishMediaType.video {
+               PublishUploadManager.shared().progressView = progressView
+                PublishUploadManager.shared().communityVideoUploadAuthApi()
+            } else {
+               PublishUploadManager.shared().progressView = progressView
+                PublishUploadManager.shared().uploadAllImages(totalTimes: 0)
+            }
+            
+        }
+        
     }
     
     // 分享

+ 2 - 7
RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishEditController/Controller/PublishEditController.swift

@@ -277,20 +277,15 @@ extension PublishEditController {
         PublishUploadManager.shared().setPublishParas(self.selTopicIdArr, self.pubTitle, self.pubContent, self.locationStr)
         
         if self.mediaType == .video {
-            
             PublishUploadManager.shared().setVideoPath(self.mediaType, self.videoPath, self.coverImagePath, self.videoImage!)
-//            PublishUploadManager.shared().communityVideoUploadAuthApi()
-            
-            print("----上传视频")
         }
         if self.mediaType == .image {
             PublishUploadManager.shared().setImagesPath(self.imageArr!)
-//            PublishUploadManager.shared().uploadAllImages(totalTimes: 0)
-            
         }
         
         self.navigationController?.dismiss(animated: true, completion: {
-            NotificationCenter.default.post(name: NSNotification.Name(rawValue: "DismissFromPublishEditVc"), object: nil)
+            let mediaType = self.mediaType
+            NotificationCenter.default.post(name: NSNotification.Name(rawValue: "DismissFromPublishEditVc"), object: mediaType)
         })
     }
     

+ 18 - 2
RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishManager/PublishUploadManager.swift

@@ -46,6 +46,11 @@ class PublishUploadManager: NSObject {
     var imageUrlArray: Array<String> = []
     
     var uploadManager: AlivcShortVideoUploadManager?
+    
+    
+    var progressView: PublishUploadProgressView?
+    // 记录当前是否发布完成
+    var isPublishFinished: Bool = true
 }
 
 // MARK: - 视频上传流程
@@ -61,6 +66,7 @@ extension PublishUploadManager: AlivcShortVideoUploadManagerDelegate {
     
     // 获取上传地址和凭证
     func communityVideoUploadAuthApi() {
+        isPublishFinished = false
         
         var vTitle: String = ""
         if videoPath.count > 20 {
@@ -94,6 +100,8 @@ extension PublishUploadManager: AlivcShortVideoUploadManagerDelegate {
         DispatchQueue.main.async(execute: {
             print("\n--------uploadProgress == \(progress)")
 //            self.progressView.progress = Float(progress)
+            
+            self.progressView?.uploadProgress = Float(progress)
         })
     }
     
@@ -122,6 +130,7 @@ extension PublishUploadManager: AlivcShortVideoUploadManagerDelegate {
             self?.majorImageUrl = imgUrl as? String
             
             print("------视频上传成功,去发布")
+            self?.progressView?.curUploadStatus = .success
             self?.communityPublishApi()
         }
     }
@@ -138,6 +147,7 @@ extension PublishUploadManager {
     
     // 上传图片
     func uploadAllImages(totalTimes: Int) {
+        isPublishFinished = false
         
         var curTimes: Int = totalTimes
         
@@ -156,15 +166,17 @@ extension PublishUploadManager {
             // 更新进度
             DispatchQueue.main.async {
                 print("----\(Thread.current)")
-                print("----uploadImgProgress == \(curTimes/(self?.imageArr!.count)!)")
+                print("----uploadProgress == \(Float(curTimes)/Float((self?.imageArr!.count)!))")                                
+                
+                self?.progressView?.uploadProgress = Float(curTimes/(self?.imageArr!.count)!)
                 
             }
             
             if curTimes < self?.imageArr?.count ?? 0 {
                 self?.uploadAllImages(totalTimes: curTimes)
             } else {
-                // FIXME: 图片上传成功,去发布
                 print("------图片上传成功,去发布")
+                self?.progressView?.curUploadStatus = .success
                 self?.communityPublishApi()
             }
         }
@@ -215,5 +227,9 @@ extension PublishUploadManager {
         VirusViewModel.shared.publishVirueRecordAddApi(postId: pubModel.postId, postType: typeStr, title: pubTitle, content: pubContent, postCover: majorImageUrl)
         
         print("\n----------发布成功!!!!!")
+        isPublishFinished = true
+//        progressView?.hide()
+        
+        progressView?.curUploadStatus = UploadStatus.failure
     }
 }

+ 18 - 5
RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishManager/PublishUploadProgressView.swift

@@ -35,6 +35,9 @@ class PublishUploadProgressView: FWPopupView {
     var uploadProgress: Float? {
         didSet {
             progressView.setProgress(self.uploadProgress ?? 0, animated: true)
+            
+            let proValueStr: String = String(format: "%.0f", self.uploadProgress ?? 0*100)
+            progressLabel.text = "正在上传中(\(proValueStr)%)..."
         }
     }
     
@@ -44,6 +47,8 @@ class PublishUploadProgressView: FWPopupView {
         super.init(frame: frame)
         setupViews()
         setupLayouts()
+        
+        self.isUserInteractionEnabled = false
     }
     
     required init?(coder aDecoder: NSCoder) {
@@ -128,9 +133,10 @@ class PublishUploadProgressView: FWPopupView {
         let failedCloseButton = UIButton(type: UIButton.ButtonType.custom)
         failedCloseButton.setImage(kImage(name: "popup_btn_close_black"), for: .normal)
         failedCloseButton.rx.tap.subscribe(onNext: { [weak self] (data) in
-            if let closeViewClosure = self?.closeViewClosure {
-                closeViewClosure()
-            }
+//            if let closeViewClosure = self?.closeViewClosure {
+//                closeViewClosure()
+//            }
+            self?.hide()
         }).disposed(by: disposeBag)
         return failedCloseButton
     }()
@@ -138,6 +144,7 @@ class PublishUploadProgressView: FWPopupView {
     class func publishUploadProgressView(attachedView:UIView) -> PublishUploadProgressView {
         let view = PublishUploadProgressView(frame: CGRect(x: 0, y: kNavBarHeight, width: kScreenWidth, height: 62))
         view.attachedView = attachedView
+        view.curUploadStatus = .uploading
         let vProperty = FWPopupViewProperty()
         vProperty.popupCustomAlignment = .topCenter
         vProperty.popupViewEdgeInsets = UIEdgeInsets(top: kNavBarHeight  + 48, left: 0, bottom: 0, right: 0 )
@@ -157,12 +164,18 @@ extension PublishUploadProgressView {
     
     func judgeShowStatus() -> Void {
         switch curUploadStatus {
-        case .uploading?,
-             .success?:
+        case .uploading?:
+            progressLabel.isHidden = false
+            progressView.isHidden = false
+            failedLabel.isHidden = true
+            failedCloseButton.isHidden = true
+            progressLabel.text = "正在上传中..."
+        case .success?:
             progressLabel.isHidden = false
             progressView.isHidden = false
             failedLabel.isHidden = true
             failedCloseButton.isHidden = true
+            progressLabel.text = "上传成功!发布中..."
         case .failure?:
             progressLabel.isHidden = true
             progressView.isHidden = true