ソースを参照

Merge branch 'feature/dev_Chris' into develop

Chris 5 年 前
コミット
b8e4ea8d41

+ 4 - 0
RainbowPlanet/RainbowPlanet.xcodeproj/project.pbxproj

@@ -630,6 +630,7 @@
 		BD929CCE22B904A30098C139 /* PublishViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD929CCD22B904A30098C139 /* PublishViewController.swift */; };
 		BD981A8F22C9FEEF0043D951 /* CommunityPublishModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD981A8E22C9FEEF0043D951 /* CommunityPublishModel.swift */; };
 		BDA45BFF22E45EBC009DE548 /* PublishUploadProgressView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDA45BFE22E45EBC009DE548 /* PublishUploadProgressView.swift */; };
+		BDA45C0122E47283009DE548 /* PublishUploadManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDA45C0022E47283009DE548 /* PublishUploadManager.swift */; };
 		BDAA40F7228E947500CF841D /* OrderApplyRefundAccountCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDAA40F6228E947500CF841D /* OrderApplyRefundAccountCell.swift */; };
 		BDAA40F9228E9ADA00CF841D /* OrderApplyRefundReasonCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDAA40F8228E9ADA00CF841D /* OrderApplyRefundReasonCell.swift */; };
 		BDAA40FB228E9CC300CF841D /* OrderApplyRefundNoteInfoCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDAA40FA228E9CC300CF841D /* OrderApplyRefundNoteInfoCell.swift */; };
@@ -1412,6 +1413,7 @@
 		BD929CCD22B904A30098C139 /* PublishViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PublishViewController.swift; sourceTree = "<group>"; };
 		BD981A8E22C9FEEF0043D951 /* CommunityPublishModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommunityPublishModel.swift; sourceTree = "<group>"; };
 		BDA45BFE22E45EBC009DE548 /* PublishUploadProgressView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PublishUploadProgressView.swift; sourceTree = "<group>"; };
+		BDA45C0022E47283009DE548 /* PublishUploadManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PublishUploadManager.swift; sourceTree = "<group>"; };
 		BDAA40F6228E947500CF841D /* OrderApplyRefundAccountCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderApplyRefundAccountCell.swift; sourceTree = "<group>"; };
 		BDAA40F8228E9ADA00CF841D /* OrderApplyRefundReasonCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderApplyRefundReasonCell.swift; sourceTree = "<group>"; };
 		BDAA40FA228E9CC300CF841D /* OrderApplyRefundNoteInfoCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderApplyRefundNoteInfoCell.swift; sourceTree = "<group>"; };
@@ -5473,6 +5475,7 @@
 			isa = PBXGroup;
 			children = (
 				BDA45BFE22E45EBC009DE548 /* PublishUploadProgressView.swift */,
+				BDA45C0022E47283009DE548 /* PublishUploadManager.swift */,
 			);
 			path = PublishManager;
 			sourceTree = "<group>";
@@ -6414,6 +6417,7 @@
 				A7CC7516227161D5003C4F38 /* SetViewController.swift in Sources */,
 				A7D07CD422B789DE00186014 /* PersonViewUserAndOtherListView.swift in Sources */,
 				A7778CBA2244F14B00C7C47A /* Extension+UIViewController.swift in Sources */,
+				BDA45C0122E47283009DE548 /* PublishUploadManager.swift in Sources */,
 				BD13B6C322BA034D008BB323 /* PublishEditDescribeCell.swift in Sources */,
 				A7CC752C2271A1AE003C4F38 /* SetPasswordViewController.swift in Sources */,
 				BD10FBFE22C6F7D90096A34E /* AliyunPublishService.m in Sources */,

+ 0 - 10
RainbowPlanet/RainbowPlanet/Modules/PublishModule/AliyunVideo/AlivcShortVideo/ShortVideoFile/Common/Model/AlivcShortVideoUploadManager.h

@@ -106,14 +106,4 @@ typedef NS_ENUM(NSInteger,AlivcUploadStatus){
 - (NSString *)coverImagePath;
 
 
-
-
-
-
-
-
-
-
-
-
 @end

+ 22 - 229
RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishEditController/Controller/PublishEditController.swift

@@ -29,14 +29,9 @@ class PublishEditController: BaseViewController {
         }
     }
     
-    var imgCount: Int = 0
     var majorImageUrl: String?
     var imageUrlArray: Array<String> = []
-    var imageArr: Array<UIImage>? {
-        didSet {
-            imgCount = self.imageArr?.count ?? 0
-        }
-    }
+    var imageArr: Array<UIImage>?
     
     // 选中的话题
     var selTopicModelArr: Array<CommunityTopicDataModel> = []
@@ -54,7 +49,6 @@ class PublishEditController: BaseViewController {
     var paraVideo: String = ""
     
     var uploadManager: AlivcShortVideoUploadManager?
-    var vUploadFinished: Bool?
     
     // MARK: 控制器生命周期
     override func viewDidLoad() {
@@ -64,32 +58,12 @@ class PublishEditController: BaseViewController {
         
         // imageUrlArray每次进入页面需置空
         imageUrlArray = []
-        rightButton.isEnabled = false
-        rightButton.backgroundColor = kd8d8d8Color
-        
-        if mediaType == .video {
-            subLabel.text = "视频正在上传中(0/1)..."
-            communityVideoUploadAuthApi()
-            print("----上传视频")
-        }
-        if mediaType == .image {
-            subLabel.text = "图片正在上传中(0/\(imageArr?.count ?? 0))..."
-            uploadAllImages(totalTimes: 0)
-        }
+//        rightButton.backgroundColor = kd8d8d8Color
+        rightButton.backgroundColor = k62CC74Color
     }
     
     override func viewWillAppear(_ animated: Bool) {
         
-//        let serialQueue = DispatchQueue(label: "serial_queue")
-//        serialQueue.async {
-//            print("----startUpLoad\n----\(Thread.current)")
-//            self.uploadAllImages(totalTimes: 0)
-//        }
-        
-//        DispatchQueue.main.async {
-//            print("----startUpLoad\n----\(Thread.current)")
-//            self.uploadAllImages(totalTimes: 0)
-//        }
     }
     
     override func setupViews() {
@@ -103,7 +77,7 @@ class PublishEditController: BaseViewController {
                 
             }, confirmBlock: {
                 (popupView, index, string) in
-                NotificationCenter.default.post(name: NSNotification.Name(rawValue: "DismissFromPublishEditVc"), object: nil)
+                self?.navigationController?.dismiss(animated: true, completion: nil)
             })
         }
         
@@ -115,28 +89,9 @@ class PublishEditController: BaseViewController {
             make.height.equalTo(26)
         }
         
-        view.addSubview(progressBackView)
-        progressBackView.addSubview(progressView)
-        progressBackView.addSubview(subLabel)
-        
-        progressBackView.snp.makeConstraints { (make) in
-            make.top.equalToSuperview().offset(kNavBarTotalHeight)
-            make.left.right.equalToSuperview()
-            make.height.equalTo(38)
-        }
-        progressView.snp.makeConstraints { (make) in
-            make.top.left.right.equalToSuperview()
-            make.height.equalTo(3)
-        }
-        subLabel.snp.makeConstraints { (make) in
-            make.left.equalTo(14)
-            make.centerY.equalToSuperview()
-            make.height.equalTo(20)
-        }
-        
         view.addSubview(tableView)
         tableView.snp.makeConstraints { (make) in
-            make.top.equalTo(progressBackView.snp_bottom)
+            make.top.equalTo(kNavBarTotalHeight)
             make.left.right.bottom.equalToSuperview()
         }
     }
@@ -162,36 +117,16 @@ class PublishEditController: BaseViewController {
         rightButton.setTitle("发布", for: UIControl.State.normal)
         rightButton.setTitleColor(kffffffColor, for: UIControl.State.normal)
         rightButton.titleLabel?.font = kMediumFont13
-        rightButton.cornerRadius = 16
+        rightButton.cornerRadius = 13
         rightButton.masksToBounds = true
         rightButton.rx.tap.subscribe(onNext: { [weak self] (data) in
-            self?.communityPublishApi()
+            
+            self?.checkPublishStatus()
+            
         }).disposed(by: disposeBag)
         return rightButton
     }()
     
-    private lazy var progressBackView: UIView = {
-        let progressBackView = UIView()
-        progressBackView.backgroundColor = kffffffColor
-        return progressBackView
-    }()
-    
-    private lazy var progressView: UIProgressView = {
-        let progressView = UIProgressView(progressViewStyle: .default)
-        progressView.setProgress(0, animated: false)
-        progressView.progressTintColor = k62CC74Color //进度颜色
-        progressView.trackTintColor = kd8d8d8Color //剩余进度颜色
-        return progressView
-    }()
-    
-    private lazy var subLabel: UILabel = {
-        let subLabel = UILabel()
-        subLabel.textColor = k333333Color
-        subLabel.font = kRegularFont14
-        subLabel.textAlignment = .left
-        return subLabel
-    }()
-    
 }
 
 // MARK: - tableView dataSource && delegate
@@ -323,45 +258,7 @@ extension PublishEditController : UITableViewDelegate, UITableViewDataSource {
 // MARK: - 逻辑处理
 extension PublishEditController {
     
-    func uploadAllImages(totalTimes: Int) {
-        
-        var curTimes: Int = totalTimes
-        
-        print("-----StartUpload,totalTimes == \(totalTimes)")
-        SwiftMoyaNetWorkServiceConfig.shared().configUploadSingleImgWithoutHudApi(imageArray: [self.imageArr![totalTimes]]) {
-            [weak self] (imgUrl) -> (Void) in
-            let urlStr: String = imgUrl as! String
-            self?.imageUrlArray.append(urlStr)
-            if curTimes == 0 {
-                // 设置主图
-                self?.majorImageUrl = urlStr
-            }
-            
-            print("-----FinishUpload,Times == \(curTimes)")
-            curTimes += 1
-            // 更新进度
-            DispatchQueue.main.async {
-                print("----\(Thread.current)")
-                self?.progressView.setProgress(Float(curTimes/(self?.imageArr!.count)!), animated: true)
-            }
-            if curTimes == self?.imageArr!.count {
-                self?.subLabel.text = "图片上传成功!"
-            } else {
-                self?.subLabel.text = "图片正在上传中(\(curTimes)/\(self?.imageArr?.count ?? 0))..."
-            }
-            
-            if curTimes < self?.imageArr?.count ?? 0 {
-                self?.uploadAllImages(totalTimes: curTimes)
-            } else {
-                self?.rightButton.isEnabled = true
-                self?.rightButton.backgroundColor = k62CC74Color
-            }
-        }
-    }
-    
-    // 发布Api
-    func communityPublishApi() {
-        
+    func checkPublishStatus() {
         if pubTitle.count > 20 {
             SwiftProgressHUD.shared().showText("标题最多输入20个字符")
             return
@@ -377,128 +274,24 @@ extension PublishEditController {
             return
         }
         
-        var typeStr: String = ""
-        if mediaType == .image {
-            typeStr = "image"
-        } else {
-            typeStr = "video"
-        }
-        
-        let topicJsonStr = JSON(selTopicIdArr).description
-        let imgsJsonStr = JSON(imageUrlArray).description
+        PublishUploadManager.shared().setPublishParas(self.selTopicIdArr, self.pubTitle, self.pubContent, self.locationStr)
         
-        print("----mediaType == \(typeStr)\n----pubTitle = \(pubTitle)\n----topicJsonStr == \(topicJsonStr)\n----imgsJsonStr == \(imgsJsonStr)")
-        
-        SwiftMoyaNetWorkServiceCommunity.shared().communityPublishApi(type: typeStr, img: majorImageUrl ?? "", topic_ids: topicJsonStr, video: paraVideo, title: pubTitle, content: pubContent, location: locationStr, imgs: imgsJsonStr) {
-            [weak self] (communityPublishModel) -> (Void) in
-            let communityPublishModel = communityPublishModel as? CommunityPublishModel
-            self?.publishSuccessAction(communityPublishModel!)
-        }
-    }
-    
-    func publishSuccessAction(_ pubModel: CommunityPublishModel) {
-        var typeStr: String = ""
-        if mediaType == .image {
-            typeStr = "image"
-        } else {
-            typeStr = "video"
-        }
-        
-        
-        VirusViewModel.shared.publishVirueRecordAddApi(postId: pubModel.postId, postType: typeStr, title: pubTitle, content: pubContent, postCover: majorImageUrl)
-        
-        
-        let sucVc = PublishSuccessController()
-        sucVc.postId   = pubModel.postId
-        sucVc.bean     = pubModel.bean
-        sucVc.H5UrlStr = pubModel.h5url
-        sucVc.imgUrl   = majorImageUrl
-        sucVc.titleStr = pubTitle
-        sucVc.contentStr = pubContent
-        // 暂给已选首个
-        sucVc.topicStr = selTopicModelArr[0].name ?? ""
-        
-        let userMdl = UserModel.shared().getModel()
-        sucVc.nameStr = userMdl?.username
-        sucVc.avatarStr = userMdl?.avatarurl
-        sucVc.uid = userMdl?.uid
-        sucVc.type = typeStr
-        
-        self.navigationController?.pushViewController(sucVc, animated: true)
-    }
-    
-}
-
-// MARK: - 视频相关处理
-extension PublishEditController: AlivcShortVideoUploadManagerDelegate {
-    
-    // 获取上传地址和凭证
-    func communityVideoUploadAuthApi() {
-        
-        var vTitle: String = ""
-        if videoPath.count > 20 {
-            vTitle = String(videoPath.suffix(20))
-        } else {
-            vTitle = videoPath
-        }
-        SwiftMoyaNetWorkServiceCommunity.shared().communityVideoUploadAuthApi(title: vTitle, filename: vTitle, cover_url: coverImagePath) {
-            [weak self] (communityVideoAuthModel) -> (Void) in
-            let communityVideoAuthModel = communityVideoAuthModel as? CommunityVideoAuthModel
-            self?.paraVideo = communityVideoAuthModel?.videoId ?? ""
-            self?.startUploadVideo(communityVideoAuthModel!)
-        }
-        
-    }
-    
-    // 上传视频
-    func startUploadVideo(_ authModel: CommunityVideoAuthModel) {
-        let info = AliyunUploadSVideoInfo()
-        uploadManager = AlivcShortVideoUploadManager.shared()
-        uploadManager?.setCoverImagePath(coverImagePath, videoInfo: info, videoPath: videoPath)
-        uploadManager?.managerDelegate = self
-        uploadManager?.uploadAddress = authModel.uploadAddress
-        uploadManager?.videoId = authModel.videoId
-        uploadManager?.uploadAuth = authModel.uploadAuth
-        uploadManager?.startUpload()
-    }
-    
-    // 上传进度回调
-    func uploadManager(_ manager: AlivcShortVideoUploadManager!, updateProgress progress: CGFloat) {
-        DispatchQueue.main.async(execute: {
-            self.progressView.progress = Float(progress)
-        })
-    }
-    
-    // 上传状态回调
-    func uploadManager(_ manager: AlivcShortVideoUploadManager!, uploadStatusChangedTo newStatus: AlivcUploadStatus) {
-        switch newStatus {
-        case AlivcUploadStatus.failure:
-            DispatchQueue.main.async(execute: {
-                self.subLabel.text = "上传失败!"
-                SwiftProgressHUD.shared().showText("上传失败!")
-            })
+        if self.mediaType == .video {
             
-        case AlivcUploadStatus.success:
-            // 上传封面图
-            self.uploadVideoCoverImage()
+            PublishUploadManager.shared().setVideoPath(self.mediaType, self.videoPath, self.coverImagePath, self.videoImage!)
+//            PublishUploadManager.shared().communityVideoUploadAuthApi()
             
-        default:
-            break
+            print("----上传视频")
         }
-    }
-    
-    // 上传视频封面图
-    func uploadVideoCoverImage() {
-        SwiftMoyaNetWorkServiceConfig.shared().configUploadSingleImgWithoutHudApi(imageArray: [videoImage!]) {
-            [weak self] (imgUrl) -> (Void) in
-            // 设置主图
-            self?.majorImageUrl = imgUrl as? String
+        if self.mediaType == .image {
+            PublishUploadManager.shared().setImagesPath(self.imageArr!)
+//            PublishUploadManager.shared().uploadAllImages(totalTimes: 0)
             
-            self?.vUploadFinished = true
-            self?.subLabel.text = "上传成功!"
-            self?.rightButton.isEnabled = true
-            self?.rightButton.backgroundColor = k62CC74Color
         }
+        
+        self.navigationController?.dismiss(animated: true, completion: {
+            NotificationCenter.default.post(name: NSNotification.Name(rawValue: "DismissFromPublishEditVc"), object: nil)
+        })
     }
     
 }

+ 219 - 0
RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishManager/PublishUploadManager.swift

@@ -0,0 +1,219 @@
+//
+//  PublishUploadManager.swift
+//  RainbowPlanet
+//
+//  Created by Christopher on 2019/7/21.
+//  Copyright © 2019 RainbowPlanet. All rights reserved.
+//
+
+import UIKit
+import SwiftyJSON
+
+class PublishUploadManager: NSObject {
+    
+    private static let _sharedInstance = PublishUploadManager()
+    
+    private override init() {} // 私有化init方法
+    
+    class func shared() -> PublishUploadManager {
+        return _sharedInstance
+    }
+    
+    // 视频上传参数
+    var mediaType: PublishMediaType = .image
+    var videoPath: String = ""
+    var coverImagePath: String = ""
+    var videoImage: UIImage?  {
+        didSet {
+            imageArr = [videoImage] as? Array<UIImage>
+        }
+    }
+    
+    // 图片上传参数
+    var imageArr: Array<UIImage>?
+    
+    // 发布参数
+    var selTopicIdArr: Array<String> = []
+    var pubTitle: String = ""
+    var pubContent: String = ""
+    var locationStr: String = ""
+    
+    // 视频id,当type为video时必填
+    var paraVideo: String = ""
+    // 主图Url
+    var majorImageUrl: String?
+    // 发布图片のUrlArray
+    var imageUrlArray: Array<String> = []
+    
+    var uploadManager: AlivcShortVideoUploadManager?
+}
+
+// MARK: - 视频上传流程
+extension PublishUploadManager: AlivcShortVideoUploadManagerDelegate {
+    
+    // 设置视频上传参数
+    func setVideoPath(_ mediaType: PublishMediaType, _ videoPath: String, _ coverImagePath: String, _ videoImage: UIImage) {
+        self.mediaType = mediaType
+        self.videoPath = videoPath
+        self.coverImagePath = coverImagePath
+        self.videoImage = videoImage
+    }
+    
+    // 获取上传地址和凭证
+    func communityVideoUploadAuthApi() {
+        
+        var vTitle: String = ""
+        if videoPath.count > 20 {
+            vTitle = String(videoPath.suffix(20))
+        } else {
+            vTitle = videoPath
+        }
+        SwiftMoyaNetWorkServiceCommunity.shared().communityVideoUploadAuthApi(title: vTitle, filename: vTitle, cover_url: coverImagePath) {
+            [weak self] (communityVideoAuthModel) -> (Void) in
+            let communityVideoAuthModel = communityVideoAuthModel as? CommunityVideoAuthModel
+            self?.paraVideo = communityVideoAuthModel?.videoId ?? ""
+            self?.startUploadVideo(communityVideoAuthModel!)
+        }
+        
+    }
+    
+    // 上传视频
+    func startUploadVideo(_ authModel: CommunityVideoAuthModel) {
+        let info = AliyunUploadSVideoInfo()
+        uploadManager = AlivcShortVideoUploadManager.shared()
+        uploadManager?.setCoverImagePath(coverImagePath, videoInfo: info, videoPath: videoPath)
+        uploadManager?.managerDelegate = self
+        uploadManager?.uploadAddress = authModel.uploadAddress
+        uploadManager?.videoId = authModel.videoId
+        uploadManager?.uploadAuth = authModel.uploadAuth
+        uploadManager?.startUpload()
+    }
+    
+    // 上传进度回调
+    func uploadManager(_ manager: AlivcShortVideoUploadManager!, updateProgress progress: CGFloat) {
+        DispatchQueue.main.async(execute: {
+            print("\n--------uploadProgress == \(progress)")
+//            self.progressView.progress = Float(progress)
+        })
+    }
+    
+    // 上传状态回调
+    func uploadManager(_ manager: AlivcShortVideoUploadManager!, uploadStatusChangedTo newStatus: AlivcUploadStatus) {
+        switch newStatus {
+        case AlivcUploadStatus.failure:
+            DispatchQueue.main.async(execute: {
+                SwiftProgressHUD.shared().showText("上传失败!")
+            })
+            
+        case AlivcUploadStatus.success:
+            // 上传封面图
+            self.uploadVideoCoverImage()
+            
+        default:
+            break
+        }
+    }
+    
+    // 上传视频封面图
+    func uploadVideoCoverImage() {
+        SwiftMoyaNetWorkServiceConfig.shared().configUploadSingleImgWithoutHudApi(imageArray: [videoImage!]) {
+            [weak self] (imgUrl) -> (Void) in
+            // 设置主图
+            self?.majorImageUrl = imgUrl as? String
+            
+            print("------视频上传成功,去发布")
+            self?.communityPublishApi()
+        }
+    }
+    
+}
+
+// MARK: - 图片上传流程
+extension PublishUploadManager {
+    
+    // 设置图片上传参数
+    func setImagesPath(_ imageArr: Array<UIImage>) {
+        self.imageArr = imageArr
+    }
+    
+    // 上传图片
+    func uploadAllImages(totalTimes: Int) {
+        
+        var curTimes: Int = totalTimes
+        
+        print("-----StartUpload,totalTimes == \(totalTimes)")
+        SwiftMoyaNetWorkServiceConfig.shared().configUploadSingleImgWithoutHudApi(imageArray: [self.imageArr![totalTimes]]) {
+            [weak self] (imgUrl) -> (Void) in
+            let urlStr: String = imgUrl as! String
+            self?.imageUrlArray.append(urlStr)
+            if curTimes == 0 {
+                // 设置主图
+                self?.majorImageUrl = urlStr
+            }
+            
+            print("-----FinishUpload,Times == \(curTimes)")
+            curTimes += 1
+            // 更新进度
+            DispatchQueue.main.async {
+                print("----\(Thread.current)")
+                print("----uploadImgProgress == \(curTimes/(self?.imageArr!.count)!)")
+                
+            }
+            
+            if curTimes < self?.imageArr?.count ?? 0 {
+                self?.uploadAllImages(totalTimes: curTimes)
+            } else {
+                // FIXME: 图片上传成功,去发布
+                print("------图片上传成功,去发布")
+                self?.communityPublishApi()
+            }
+        }
+    }
+}
+
+// MARK: - 发布流程
+extension PublishUploadManager {
+    
+    // 设置发布上传参数
+    func setPublishParas(_ selTopicIdArr: Array<String>, _ pubTitle: String, _ pubContent: String, _ locationStr: String) {
+        self.selTopicIdArr = selTopicIdArr
+        self.pubTitle = pubTitle
+        self.pubContent = pubContent
+        self.locationStr = locationStr
+    }
+    
+    // 发布Api
+    private func communityPublishApi() {
+        
+        var typeStr: String = ""
+        if mediaType == .image {
+            typeStr = "image"
+        } else {
+            typeStr = "video"
+        }
+        
+        let topicJsonStr = JSON(selTopicIdArr).description
+        let imgsJsonStr = JSON(imageUrlArray).description
+        
+        print("----mediaType == \(typeStr)\n----pubTitle = \(pubTitle)\n----topicJsonStr == \(topicJsonStr)\n----imgsJsonStr == \(imgsJsonStr)")
+        
+        SwiftMoyaNetWorkServiceCommunity.shared().communityPublishApi(type: typeStr, img: majorImageUrl ?? "", topic_ids: topicJsonStr, video: paraVideo, title: pubTitle, content: pubContent, location: locationStr, imgs: imgsJsonStr) {
+            [weak self] (communityPublishModel) -> (Void) in
+            let communityPublishModel = communityPublishModel as? CommunityPublishModel
+            self?.publishSuccessAction(communityPublishModel!)
+        }
+    }
+    
+    private func publishSuccessAction(_ pubModel: CommunityPublishModel) {
+        var typeStr: String = ""
+        if mediaType == .image {
+            typeStr = "image"
+        } else {
+            typeStr = "video"
+        }
+        
+        VirusViewModel.shared.publishVirueRecordAddApi(postId: pubModel.postId, postType: typeStr, title: pubTitle, content: pubContent, postCover: majorImageUrl)
+        
+        print("\n----------发布成功!!!!!")
+    }
+}

+ 1 - 1
RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishSuccess/PublishSuccessController.swift

@@ -41,7 +41,7 @@ class PublishSuccessController: BaseViewController {
         navigationBar.titleLabelColor = kffffffColor
         navigationBar.wr_setLeftButton(image: kImage(name: "navbar_back_white")!)
         navigationBar.onClickLeftButton = {
-           NotificationCenter.default.post(name: NSNotification.Name(rawValue: "DismissFromPublishEditVc"), object: nil)
+            self.navigationController?.dismiss(animated: true, completion: nil)
         }
         
         view.addSubview(shareCommunityContentView)

+ 0 - 11
RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishViewController.swift

@@ -11,13 +11,6 @@ import JXSegmentedView
 
 class PublishViewController: BaseViewController {
     
-    deinit {
-        if observe != nil {
-            NotificationCenter.default.removeObserver(observe!)
-        }
-    }
-    weak var observe : NSObjectProtocol?
-    
     // 视频选择页参数配置类
     var mediaConfig: AliyunMediaConfig {
         //默认配置
@@ -50,10 +43,6 @@ class PublishViewController: BaseViewController {
         setupViews()
         setupLayouts()
         setupData()
-                
-        observe = NotificationCenter.default.addObserver(forName: NSNotification.Name("DismissFromPublishEditVc"), object: nil, queue: OperationQueue.main) {[weak self] (notification) in
-            self?.dismiss(animated: true, completion: nil)
-        }
     }
     
     override func setupViews() {