南鑫林 преди 5 години
родител
ревизия
29e3eaccfb

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

@@ -92,7 +92,12 @@ class CommunityViewController: BaseViewController {
             make.top.equalTo(segmentedView.snp.bottom)
             make.left.right.bottom.equalToSuperview()
         }
-        publishUploadProgressView.snp.makeConstraints { (make) in
+//        publishUploadProgressView.snp.makeConstraints { (make) in
+//            make.top.left.right.equalToSuperview()
+//             make.height.equalTo(62)
+//        }
+        
+        publishManagerUploadView.snp.makeConstraints { (make) in
             make.top.left.right.equalToSuperview()
              make.height.equalTo(62)
         }
@@ -210,6 +215,9 @@ class CommunityViewController: BaseViewController {
             self?.reloadSegmentedFollowView()
 //            let aliyunVodUpToYoPublishModel = notification.object as? AliyunVodUpToYoPublishModel
 //            self?.publishUploadProgressView.aliyunVodUpToYoPublishModel = aliyunVodUpToYoPublishModel
+            let publishManagerModel = notification.object as? PublishManagerModel
+            self?.publishManagerUploadView.publishManagerModel = publishManagerModel
+
         }
         
         // 滚动

+ 50 - 16
RainbowPlanet/RainbowPlanet/Modules/PublishNewModule/PublishEditVideo/ViewController/PublishEditVideoContentViewController.swift

@@ -10,6 +10,7 @@ import UIKit
 
 class PublishEditVideoContentViewController: BaseViewController {
 
+    var isRenewEdit : Bool = false
     /// 合成导出路径
     var outputPath : String?
     /// 封面路径
@@ -30,12 +31,13 @@ class PublishEditVideoContentViewController: BaseViewController {
         setVideoCoverImagePath()
         setupViews()
         setupLayouts()
+        setupData()
     }
     
     func setVideoCoverImagePath() {
-
-        // 视频路径
-        if publishManagerVideoModel == nil {
+        
+        if publishManagerModel == nil {
+            // 视频路径
             let asset = AVURLAsset.init(url: URL(fileURLWithPath: outputPath ?? ""))
             let gen = AVAssetImageGenerator.init(asset: asset)
             gen.appliesPreferredTrackTransform = true
@@ -66,23 +68,22 @@ class PublishEditVideoContentViewController: BaseViewController {
             publishManagerVideoModel?.outVideoPathURL = URL(fileURLWithPath: outputPath ?? "")
             publishManagerVideoModel?.outCoverImagePath = outCoverImagePath
             publishManagerVideoModel?.outCoverImagePathURL = URL(fileURLWithPath: outCoverImagePath ?? "")
-        }
-        
-        // 内容
-        if publishManagerContentModel == nil {
+            //发布内容
             publishManagerContentModel = PublishManagerContentModel()
-        }
-        
-        //话题
-        if publishManagerTopicModel == nil {
+            // 话题
             publishManagerTopicModel = PublishManagerTopicModel()
-        }
-        
-        //定位
-        if publishManagerLocationModel == nil {
+            // 定位
             publishManagerLocationModel = PublishManagerLocationModel()
+        }else {
+             // 视频路径
+             publishManagerVideoModel = publishManagerModel?.video
+             //发布内容
+             publishManagerContentModel = publishManagerModel?.content
+             // 话题
+             publishManagerTopicModel = publishManagerModel?.topic
+             // 定位
+             publishManagerLocationModel = publishManagerModel?.location
         }
-        
     }
     
     override func setupViews() {
@@ -107,6 +108,10 @@ class PublishEditVideoContentViewController: BaseViewController {
     
     override func setupData() {
         
+        publishButton.rx.tap.subscribe(onNext: { [weak self] (data) in
+            self?.publishAction()
+        }).disposed(by: disposeBag)
+        
     }
     
     lazy var publishButton: UIButton = {
@@ -140,7 +145,36 @@ class PublishEditVideoContentViewController: BaseViewController {
             }
         }
     }
+    
+    func publishAction() {
+        if publishManagerContentModel?.detailTitle?.count == 0 || publishManagerContentModel?.detailTitle == nil || publishManagerContentModel?.detailTitle == ""  {
+            SwiftProgressHUD.shared().showText("还没输入描述内容")
+            return
+        }
+        
+        if publishManagerTopicModel?.topics?.isEmpty ?? true {
+            SwiftProgressHUD.shared().showText("还没选择话题哟")
+            return
+        }
+        if publishManagerModel == nil {
+            publishManagerModel = PublishManagerModel()
+        }
+        publishManagerModel?.publishType = .video
+        publishManagerModel?.video = publishManagerVideoModel
+        publishManagerModel?.content = publishManagerContentModel
+        publishManagerModel?.topic = publishManagerTopicModel
+        publishManagerModel?.location = publishManagerLocationModel
+        
+        NotificationCenter.default.post(name: NSNotification.Name(rawValue: "DismissFromPublishEditVc"), object: publishManagerModel)
 
+        if isRenewEdit {
+            self.navigationController?.popViewController(animated: true)
+        }else {
+            self.dismissToRootViewController(animated: false) {
+                BaseTabbarViewController.shared.esTabBarController.selectedIndex = 0
+            }
+        }
+    }
 }
 
 // MARK: - tableView dataSource && delegate

Файловите разлики са ограничени, защото са твърде много
+ 14 - 14
RainbowPlanet/RainbowPlanet/Modules/PublishNewModule/PublishManager/PublishManager.swift


+ 4 - 2
RainbowPlanet/RainbowPlanet/Modules/PublishNewModule/PublishManager/PublishManagerUploadFailureView.swift

@@ -62,18 +62,20 @@ class PublishManagerUploadFailureView: BaseView {
         return uploadFailureErrorInfoLabel
     }()
     
-    private lazy var failedCloseButton: UIButton = {
+    lazy var failedCloseButton: UIButton = {
         let failedCloseButton = UIButton(type: UIButton.ButtonType.custom)
         failedCloseButton.setImage(kImage(name: "popup_btn_close_black"), for: .normal)
         return failedCloseButton
     }()
     
-    private lazy var editButton: UIButton = {
+    lazy var editButton: UIButton = {
         let editButton = UIButton(type: UIButton.ButtonType.custom)
         editButton.setTitle("重新编辑", for: UIControl.State.normal)
         editButton.setTitleColor(kffffffColor, for: UIControl.State.normal)
         editButton.titleLabel?.font = kMediumFont13
         editButton.backgroundColor = kThemeColor
+        editButton.cornerRadius = 13
+        editButton.masksToBounds = true
         return editButton
     }()
     

+ 24 - 7
RainbowPlanet/RainbowPlanet/Modules/PublishNewModule/PublishManager/PublishManagerUploadView.swift

@@ -41,7 +41,23 @@ class PublishManagerUploadView: BaseView {
     }
     
     override func setupData() {
-       
+        publishManagerUploadFailureView.failedCloseButton.rx.tap.subscribe(onNext: { (_) in
+            UIView.animate(withDuration: 0.5, delay: 0.5, options: UIView.AnimationOptions.allowUserInteraction, animations: {
+                [weak self] in
+                 self?.alpha = 0
+                 self?.publishManagerUploadProgressView.alpha = 0
+                 self?.publishManagerUploadFailureView.alpha = 0
+             }) { (finish) in
+                 PublishManager.shared.destroyAll()
+             }
+        }).disposed(by: disposeBag)
+        
+        publishManagerUploadFailureView.editButton.rx.tap.subscribe(onNext: { [weak self] (_) in
+           let vc = PublishEditVideoContentViewController()
+            vc.publishManagerModel = self?.publishManagerModel
+            vc.isRenewEdit = true
+            BaseTabbarViewController.shared.v1.navigationController?.pushViewController(vc, animated: true)
+        }).disposed(by: disposeBag)
     }
     
     lazy var imageView: UIImageView = {
@@ -67,10 +83,9 @@ class PublishManagerUploadView: BaseView {
     
     var publishManagerModel : PublishManagerModel? {
         didSet {
-            guard let publishManagerModel = publishManagerModel  else {
-                return
-            }
+            guard let publishManagerModel = publishManagerModel  else { return }
             alpha = 1
+            publishManagerUploadProgressView.progressView.progress = 0
             publishManagerUploadProgressView.alpha = 1
             publishManagerUploadFailureView.alpha = 0
             if publishManagerModel.publishType == .video {
@@ -83,7 +98,7 @@ class PublishManagerUploadView: BaseView {
         }
     }
     
-    
+//=============================================视频==========================================
     /// 视频
     /// - Parameter publishManagerModel: 发布管理器
     func publishVideo(publishManagerModel:PublishManagerModel)  {
@@ -95,7 +110,7 @@ class PublishManagerUploadView: BaseView {
         }, progressClosure: { (progress) in
             DispatchQueue.main.async {
                 [weak self] in
-                let progressValue =  ceil(progress) * 100
+                let progressValue =  progress * 100
                 let progressValueStr: String = String(format: "正在上传中(%.0f%%)...", progressValue)
                 self?.publishManagerUploadProgressView.progressView.setProgress(progress, animated: true)
                 self?.publishManagerUploadProgressView.progressValueLabel.text = progressValueStr
@@ -119,7 +134,9 @@ class PublishManagerUploadView: BaseView {
                 }
                 
             }
-        }) { (message) in
+        }) { [weak self] (message) in
+            self?.publishManagerUploadFailureView.uploadFailureLabel.text = "发布失败!"
+            self?.publishManagerUploadFailureView.uploadFailureErrorInfoLabel.text = message
             UIView.animate(withDuration: 0.5) {
                 [weak self] in
                 DispatchQueue.main.async {

+ 20 - 0
RainbowPlanet/RainbowPlanet/Service/SwiftMoyaService/SwiftMoyaServiceApi/SwiftMoyaServiceVirus/SwiftMoyaNetWorkServiceVirus.swift

@@ -40,4 +40,24 @@ class SwiftMoyaNetWorkServiceVirus: NSObject {
         }
         
     }
+    
+    /// 生成账本
+    ///
+    /// - Parameters:
+    ///   - virueRecordAddParameterModel: 生成账本摩西
+    ///   - completion: completion description
+    func virueRecordAddNewApi(virueRecordAddParameterModel:VirueRecordAddParameterModel,completion: @escaping successCallBack,fail:@escaping failCallback) {
+        
+        if !UserModel.isTokenNil() {
+            var parameters = Dictionary<String,Any>()
+            parameters = virueRecordAddParameterModel.toJSON()
+            SwiftMoyaNetWorkManager.shared.requestRootModel(target: MultiTarget(SwiftMoyaServiceVirusApi.virueRecordAdd(parameters: parameters)), completion: {(data) in
+                completion(data)
+            }) {
+                (loadingStatus) in
+                fail(loadingStatus)
+            }
+        }
+        
+    }
 }

+ 3 - 0
RainbowPlanet/RainbowPlanet/Service/SwiftMoyaService/SwiftMoyaServiceManger/SwiftMoyaNetWorkManager/SwiftMoyaNetWorkManager.swift

@@ -30,6 +30,9 @@ enum SwiftMoyaNetWorkManagerLoadingStatus {
 typealias successCallBack = (Any?) -> (Void)
 /// 失败回调
 typealias failCallback = (_ loadingStatus:SwiftMoyaNetWorkManagerLoadingStatus) -> Void
+
+/// 失败回调
+typealias errorCallback = (String?) -> Void
 /// 进度
 typealias loadProgressClosure = (ProgressResponse) -> Void
 

+ 25 - 0
RainbowPlanet/RainbowPlanet/ViewModel/Virus/VirusViewModel.swift

@@ -1049,6 +1049,31 @@ extension VirusViewModel {
             fail()
         }
     }
+    
+    func publishVirueRecordAddNewApi(postId:Int?,postType:String?,title:String?,content:String?,postCover:String?,completion:@escaping (RootModel)->Void,fail:@escaping ()->Void) {
+        
+        let virueRecordAddParameterModel = VirueRecordAddParameterModel()
+        virueRecordAddParameterModel.behaviorId = (ConfigModel.shared.object()?.virus?.publish ?? "")
+        virueRecordAddParameterModel.behaviorFlag =
+            BehaviorFlagType.publish.rawValue
+        virueRecordAddParameterModel.targetId = "\((UserModel.shared().getModel()?.uid)!)"
+        
+        virueRecordAddParameterModel.postId = postId
+        virueRecordAddParameterModel.actionId = "\(postId ?? 0)"
+        if title == "" {
+            virueRecordAddParameterModel.postDesc = "\(content?.prefix(20) ?? "")"
+        }else {
+            virueRecordAddParameterModel.postDesc = title
+        }
+        virueRecordAddParameterModel.postType = postType
+        virueRecordAddParameterModel.postCover = postCover
+        
+        SwiftMoyaNetWorkServiceVirus.shared().virueRecordAddNewApi(virueRecordAddParameterModel: virueRecordAddParameterModel, completion: {(data) -> (Void) in
+            completion(data as! RootModel)
+        }){ _ in
+            fail()
+        }
+    }
 }
 
 // MARK: - 注册