Kaynağa Gözat

Merge branch 'develop' into feature/jeremy

南鑫林 5 yıl önce
ebeveyn
işleme
f47235608c
15 değiştirilmiş dosya ile 254 ekleme ve 50 silme
  1. 4 0
      RainbowPlanet/RainbowPlanet.xcodeproj/project.pbxproj
  2. 1 1
      RainbowPlanet/RainbowPlanet/Macro/RainbowPlanet-Bridging-Header.h
  3. 1 1
      RainbowPlanet/RainbowPlanet/Model/CommunityModel/CommunityPublishModel.swift
  4. 35 0
      RainbowPlanet/RainbowPlanet/Model/CommunityModel/CommunityVideoAuthModel.swift
  5. 7 0
      RainbowPlanet/RainbowPlanet/Modules/PublishModule/AliyunVideo/AlivcShortVideo/ShortVideoFile/Common/Model/AlivcShortVideoUploadManager.h
  6. 6 21
      RainbowPlanet/RainbowPlanet/Modules/PublishModule/AliyunVideo/AlivcShortVideo/ShortVideoFile/Common/Model/AlivcShortVideoUploadManager.m
  7. 1 1
      RainbowPlanet/RainbowPlanet/Modules/PublishModule/AliyunVideo/AlivcShortVideo/ShortVideoFile/VideoCoverPick/Controller/AliyunCoverPickViewController.h
  8. 12 4
      RainbowPlanet/RainbowPlanet/Modules/PublishModule/AliyunVideo/AlivcShortVideo/ShortVideoFile/VideoCoverPick/Controller/AliyunCoverPickViewController.m
  9. 1 7
      RainbowPlanet/RainbowPlanet/Modules/PublishModule/AliyunVideo/AlivcShortVideo/ShortVideoFile/VideoEdit/Controller/AliyunEditViewController.m
  10. 122 13
      RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishEditController/Controller/PublishEditController.swift
  11. 1 1
      RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishEditController/View/PublishEditAddPicCell.swift
  12. 20 0
      RainbowPlanet/RainbowPlanet/Service/SwiftMoyaService/SwiftMoyaServiceApi/SwiftMoyaServiceCommunity/SwiftMoyaNetWorkServiceCommunity.swift
  13. 12 0
      RainbowPlanet/RainbowPlanet/Service/SwiftMoyaService/SwiftMoyaServiceApi/SwiftMoyaServiceCommunity/SwiftMoyaServiceCommunityApi.swift
  14. 23 0
      RainbowPlanet/RainbowPlanet/Service/SwiftMoyaService/SwiftMoyaServiceApi/SwiftMoyaServiceConfig/SwiftMoyaNetWorkServiceConfig.swift
  15. 8 1
      RainbowPlanet/RainbowPlanet/Service/SwiftMoyaService/SwiftMoyaServiceApi/SwiftMoyaServiceConfig/SwiftMoyaServiceConfigApi.swift

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

@@ -419,6 +419,7 @@
 		BD0808EC22C5BA3100D12E6A /* AliyunCompositionInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = BD0808EA22C5BA3000D12E6A /* AliyunCompositionInfo.m */; };
 		BD09C84122955B480080D5A4 /* PopTopTriangleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD09C84022955B480080D5A4 /* PopTopTriangleView.swift */; };
 		BD0E678522A4C23B00B980BA /* ShoppingCartOrderPayFreightCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD0E678422A4C23B00B980BA /* ShoppingCartOrderPayFreightCell.swift */; };
+		BD0F61F822CAFC8B004650FB /* CommunityVideoAuthModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD0F61F722CAFC8B004650FB /* CommunityVideoAuthModel.swift */; };
 		BD0FAA3722C465B900DDFB37 /* AliyunEditViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = BD0FAA3522C465B900DDFB37 /* AliyunEditViewController.m */; };
 		BD0FAA4122C465F500DDFB37 /* AliyunEditButtonsView.m in Sources */ = {isa = PBXBuildFile; fileRef = BD0FAA3A22C465F500DDFB37 /* AliyunEditButtonsView.m */; };
 		BD0FAA4222C465F500DDFB37 /* AliyunEffectTimeFilterView.m in Sources */ = {isa = PBXBuildFile; fileRef = BD0FAA3C22C465F500DDFB37 /* AliyunEffectTimeFilterView.m */; };
@@ -1092,6 +1093,7 @@
 		BD0808EB22C5BA3000D12E6A /* AliyunCompositionInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AliyunCompositionInfo.h; sourceTree = "<group>"; };
 		BD09C84022955B480080D5A4 /* PopTopTriangleView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PopTopTriangleView.swift; sourceTree = "<group>"; };
 		BD0E678422A4C23B00B980BA /* ShoppingCartOrderPayFreightCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShoppingCartOrderPayFreightCell.swift; sourceTree = "<group>"; };
+		BD0F61F722CAFC8B004650FB /* CommunityVideoAuthModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommunityVideoAuthModel.swift; sourceTree = "<group>"; };
 		BD0FAA3522C465B900DDFB37 /* AliyunEditViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AliyunEditViewController.m; sourceTree = "<group>"; };
 		BD0FAA3622C465B900DDFB37 /* AliyunEditViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AliyunEditViewController.h; sourceTree = "<group>"; };
 		BD0FAA3922C465F500DDFB37 /* AliyunEditButtonsView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AliyunEditButtonsView.h; sourceTree = "<group>"; };
@@ -3876,6 +3878,7 @@
 				A71CAB3822C9DF0600D908A8 /* CommunityTopicDetailModel.swift */,
 				A71CAB3A22C9F21100D908A8 /* CommunityMemberFollowTopicListModel.swift */,
 				BD981A8E22C9FEEF0043D951 /* CommunityPublishModel.swift */,
+				BD0F61F722CAFC8B004650FB /* CommunityVideoAuthModel.swift */,
 			);
 			path = CommunityModel;
 			sourceTree = "<group>";
@@ -5935,6 +5938,7 @@
 				A7274C5F228EE636000E3A07 /* LBXScanWrapper.swift in Sources */,
 				A7CC752F2271A1F2003C4F38 /* SetPasswordView.swift in Sources */,
 				A7A98E09227EB8DD005306E9 /* CategoryView.swift in Sources */,
+				BD0F61F822CAFC8B004650FB /* CommunityVideoAuthModel.swift in Sources */,
 				A7D07CC122B73F0200186014 /* OtherPersonalCenterViewController.swift in Sources */,
 				A7CC75362271AC14003C4F38 /* AddressManagerView.swift in Sources */,
 				A7146349228EFCE20066099B /* ORSKUDataFilter.m in Sources */,

+ 1 - 1
RainbowPlanet/RainbowPlanet/Macro/RainbowPlanet-Bridging-Header.h

@@ -67,7 +67,7 @@
 
 #import "AliyunPathManager.h"
 #import "QUProgressView.h"
-
+#import "AlivcShortVideoUploadManager.h"
 
 #import "AliyunMagicCameraViewController.h"
 #import "AliyunCropViewController.h"

+ 1 - 1
RainbowPlanet/RainbowPlanet/Model/CommunityModel/CommunityPublishModel.swift

@@ -4,7 +4,7 @@
 //
 //  Created by Christopher on 2019/7/1.
 //  Copyright © 2019 RainbowPlanet. All rights reserved.
-//
+//  发布动态のModel
 
 import Foundation
 import ObjectMapper

+ 35 - 0
RainbowPlanet/RainbowPlanet/Model/CommunityModel/CommunityVideoAuthModel.swift

@@ -0,0 +1,35 @@
+//
+//  CommunityVideoAuthModel.swift
+//  RainbowPlanet
+//
+//  Created by Christopher on 2019/7/2.
+//  Copyright © 2019 RainbowPlanet. All rights reserved.
+//  获取视频上传地址和凭证のModel
+
+import Foundation
+import ObjectMapper
+
+
+class CommunityVideoAuthModel : NSObject, Mappable{
+    
+    var requestId : String?
+    var uploadAddress : String?
+    var uploadAuth : String?
+    var videoId : String?
+    
+    
+    class func newInstance(map: Map) -> Mappable?{
+        return CommunityVideoAuthModel()
+    }
+    required init?(map: Map){}
+    private override init(){}
+    
+    func mapping(map: Map)
+    {
+        requestId <- map["RequestId"]
+        uploadAddress <- map["UploadAddress"]
+        uploadAuth <- map["UploadAuth"]
+        videoId <- map["VideoId"]
+        
+    }    
+}

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

@@ -65,6 +65,13 @@ typedef NS_ENUM(NSInteger,AlivcUploadStatus){
  */
 @property (nonatomic, weak) id<AlivcShortVideoUploadManagerDelegate> managerDelegate;
 
+//
+@property (nonatomic, strong) NSString *uploadAddress;
+//
+@property (nonatomic, strong) NSString *videoId;
+//
+@property (nonatomic, strong) NSString *uploadAuth;
+
 /**
  设置上传信息
  

+ 6 - 21
RainbowPlanet/RainbowPlanet/Modules/PublishModule/AliyunVideo/AlivcShortVideo/ShortVideoFile/Common/Model/AlivcShortVideoUploadManager.m

@@ -10,7 +10,6 @@
 #import "AliyunMediaConfig.h"
 #import "AliyunPublishService.h"
 #import "AliyunSVideoApi.h"
-//#import "AliVideoClientUser.h"
 #import <sys/utsname.h>
 
 @interface AlivcShortVideoUploadManager () <AliyunIVodUploadCallback>
@@ -21,7 +20,6 @@
 @property(nonatomic, assign) AlivcUploadStatus newStatus; //上传状态
 
 @property(nonatomic, copy) NSString *coverImageUrl;  //封面图的URL
-@property(nonatomic, copy) NSString *videoId; //视频上传成功之后得到视频id
 
 @end
 
@@ -109,7 +107,7 @@ static AliyunVodPublishManager *_uploadManager = nil;
     _newStatus = AlivcUploadStatusUploading;
     if (_managerDelegate &&
         [_managerDelegate respondsToSelector:@selector(uploadManager:
-                                                       uploadStatusChangedTo:)]) {
+                                                         uploadStatusChangedTo:)]) {
         [_managerDelegate uploadManager:self
                   uploadStatusChangedTo:AlivcUploadStatusUploading];
     }
@@ -148,34 +146,21 @@ static AliyunVodPublishManager *_uploadManager = nil;
  上传封面图
  */
 - (void)startUploadImage{
-//    [AliyunSVideoApi getImageUploadAuthWithToken:[AliVideoClientUser shared].token title:@"DefaultTitle" filePath:self.coverImagePath tags:@"DefaultTags" handler:^(NSString * _Nullable uploadAddress, NSString * _Nullable uploadAuth, NSString * _Nullable imageURL, NSString * _Nullable imageId, NSError * _Nullable error) {
-//        if (error) {
-//            NSLog(@"error获取封面凭证:%@", error.description);
-//            [self handleUploadFailed];
-//            return;
-//        }
-//        self.coverImageUrl = imageURL;
-//        [_uploadManager uploadImageWithPath:self.coverImagePath uploadAddress:uploadAddress uploadAuth:uploadAuth];
-//    }];
+    [_uploadManager uploadImageWithPath:self.coverImagePath uploadAddress:self.uploadAddress uploadAuth:self.uploadAuth];
 }
 
 /**
  上传视频
  */
 - (void)startUploadVideo{
-//    [AliyunSVideoApi getVideoUploadAuthWithWithToken:[AliVideoClientUser shared].token title:_videoInfo.title filePath:self.videoPath coverURL:self.coverImageUrl desc:_videoInfo.desc tags:_videoInfo.tags handler:^(NSString * _Nullable uploadAddress, NSString * _Nullable uploadAuth, NSString * _Nullable videoId, NSError * _Nullable error) {
-//        if (error) {
-//            NSLog(@"error:获取视频凭证%@", error.description);
-//            [self handleUploadFailed];
-//            return;
-//        }
-//        self.videoId = videoId;
-//        [_uploadManager uploadVideoWithPath:self.videoPath uploadAddress:uploadAddress uploadAuth:uploadAuth];
-//    }];
+    [_uploadManager uploadVideoWithPath:self.videoPath uploadAddress:self.uploadAddress uploadAuth:self.uploadAuth];
 }
 
 
 - (void)refreshVideo{
+    
+    [_uploadManager refreshWithUploadAuth:self.uploadAuth];
+    
 //    [AliyunSVideoApi refreshVideoUploadAuthWithToken:[AliVideoClientUser shared].token videoId:self.videoId handler:^(NSString * _Nullable uploadAddress, NSString * _Nullable uploadAuth, NSError * _Nullable error) {
 //        if (error) {
 //            NSLog(@"error:%@", error.description);

+ 1 - 1
RainbowPlanet/RainbowPlanet/Modules/PublishModule/AliyunVideo/AlivcShortVideo/ShortVideoFile/VideoCoverPick/Controller/AliyunCoverPickViewController.h

@@ -11,5 +11,5 @@
 @interface AliyunCoverPickViewController : UIViewController
 @property (nonatomic, assign) CGSize outputSize;
 @property (nonatomic, strong) NSString *videoPath;
-@property (nonatomic, strong) void(^finishHandler)(UIImage *image);
+@property (nonatomic, strong) NSString *taskPath;
 @end

+ 12 - 4
RainbowPlanet/RainbowPlanet/Modules/PublishModule/AliyunVideo/AlivcShortVideo/ShortVideoFile/VideoCoverPick/Controller/AliyunCoverPickViewController.m

@@ -11,6 +11,7 @@
 #import "AliyunCoverPickView.h"
 #import "AliyunPublishTopView.h"
 #import "AlivcMacro.h"
+#import "RainbowPlanet-Swift.h"
 
 @interface AliyunCoverPickViewController () <AliyunPublishTopViewDelegate,
                                              AliyunCoverPickViewDelegate>
@@ -81,11 +82,18 @@
 }
 
 - (void)finishButtonClicked {
-    // FIXME: 完成封面选择,去发布
-    NSLog(@"完成封面选择,去发布");
+    // 完成封面选择,去发布
+    NSString *coverPath = [_taskPath stringByAppendingPathComponent:@"cover.png"];
+    NSData *data = UIImagePNGRepresentation(_coverView.image);
+    [data writeToFile:coverPath atomically:YES];
     
-//    _finishHandler(_coverView.image);
-//    [self.navigationController popViewControllerAnimated:YES];
+    PublishEditController *pubVc = [[PublishEditController alloc] init];
+    pubVc.mediaType = PublishMediaTypeVideo;
+    pubVc.videoPath = _videoPath;
+    pubVc.coverImagePath = coverPath;
+    pubVc.videoSize = _outputSize;
+    pubVc.videoImage = _coverView.image;
+    [self.navigationController pushViewController:pubVc animated:YES];
 }
 
 #pragma mark - pick view delegate

+ 1 - 7
RainbowPlanet/RainbowPlanet/Modules/PublishModule/AliyunVideo/AlivcShortVideo/ShortVideoFile/VideoEdit/Controller/AliyunEditViewController.m

@@ -1264,13 +1264,7 @@ AliyunIExporterCallback, AliyunIPlayerCallback, AliyunMusicPickViewControllerDel
     AliyunCoverPickViewController *vc = [AliyunCoverPickViewController new];
     vc.outputSize = _outputSize;
     vc.videoPath = _config.outputPath;
-    vc.finishHandler = ^(UIImage *image) {
-        //        _image = image;
-        //        _coverImageView.image = image;
-        //        _backgroundView.image = image;
-        
-        NSLog(@"----coverImage == %@", image);
-    };
+    vc.taskPath = _taskPath;
     [self.navigationController pushViewController:vc animated:YES];
 }
 

+ 122 - 13
RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishEditController/Controller/PublishEditController.swift

@@ -11,14 +11,23 @@ import RxSwift
 import SwiftyJSON
 import Photos
 
-enum PublishMediaType {
-    case image
-    case video
+@objc(PublishMediaType)
+enum PublishMediaType: Int {
+    case image = 0
+    case video = 1
 }
 
 class PublishEditController: BaseViewController {
     
-    var mediaType: PublishMediaType = .image
+    @objc var mediaType: PublishMediaType = .image
+    @objc var videoPath: String = ""
+    @objc var coverImagePath: String = ""
+    @objc var videoSize: CGSize = CGSize()
+    @objc var videoImage: UIImage?  {
+        didSet {
+            imageArr = [videoImage] as? Array<UIImage>
+        }
+    }
     
     var imgCount: Int = 0
     var majorImageUrl: String?
@@ -37,6 +46,11 @@ class PublishEditController: BaseViewController {
     var pubContent: String = ""
     // 位置
     var location: String = ""
+    // 视频id,当type为video时必填
+    var paraVideo: String = ""
+    
+    var uploadManager: AlivcShortVideoUploadManager?
+    var vUploadFinished: Bool?
     
     // MARK: 控制器生命周期
     override func viewDidLoad() {
@@ -50,7 +64,27 @@ class PublishEditController: BaseViewController {
         imageUrlArray = []
         rightButton.isEnabled = false
         rightButton.backgroundColor = kd8d8d8Color
-        uploadAllImages(totalTimes: 0)
+        
+        if mediaType == .image {
+            subLabel.text = "图片正在上传中(0/\(imageArr?.count ?? 0))..."
+            uploadAllImages(totalTimes: 0)
+        } else {
+            subLabel.text = "视频正在上传中(0/1)..."
+            communityVideoUploadAuthApi()
+            print("----上传视频")
+        }
+        
+        
+//        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() {
@@ -139,19 +173,14 @@ class PublishEditController: BaseViewController {
     
     private lazy var progressView: UIProgressView = {
         let progressView = UIProgressView(progressViewStyle: .default)
-//        progressView.frame = CGRect(x: 0, y: 0, width: 200, height: 10)
-//        progressView.layer.position = CGPoint(x: self.view.frame.width/2, y: 90)
         progressView.setProgress(0, animated: false)
         progressView.progressTintColor = k62CC74Color //进度颜色
         progressView.trackTintColor = kd8d8d8Color //剩余进度颜色
-        //通过改变进度条高度(宽度不变,高度变为默认的2倍)
-//        progressView.transform = CGAffineTransform(scaleX: 1.0, y: 2.0)
         return progressView
     }()
     
     private lazy var subLabel: UILabel = {
         let subLabel = UILabel()
-        subLabel.text = "图片正在上传中(0/\(imageArr?.count ?? 0))..."
         subLabel.textColor = k333333Color
         subLabel.font = kRegularFont14
         subLabel.textAlignment = .left
@@ -176,6 +205,9 @@ extension PublishEditController : UITableViewDelegate, UITableViewDataSource {
         case 0:
             let picCell = PublishEditAddPicCell.cellWith(tableView: tableView, indexPath: indexPath)
             picCell.pubImageArr = imageArr
+            if mediaType == .video {
+                picCell.maxImageCount = 1
+            }
             picCell.reloadData()
             picCell.choosePicBlock = {
                 [weak self] in
@@ -264,7 +296,7 @@ extension PublishEditController {
         var curTimes: Int = totalTimes
         
         print("-----StartUpload,totalTimes == \(totalTimes)")
-        SwiftMoyaNetWorkServiceConfig.shared().configUploadSingleImgApi(imageArray: [imageArr![totalTimes]]) {
+        SwiftMoyaNetWorkServiceConfig.shared().configUploadSingleImgWithoutHudApi(imageArray: [self.imageArr![totalTimes]]) {
             [weak self] (imgUrl) -> (Void) in
             let urlStr: String = imgUrl as! String
             self?.imageUrlArray.append(urlStr)
@@ -276,7 +308,10 @@ extension PublishEditController {
             print("-----FinishUpload,Times == \(curTimes)")
             curTimes += 1
             // 更新进度
-            self?.progressView.setProgress(Float(curTimes/(self?.imageArr!.count)!), animated: true)
+            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 {
@@ -320,7 +355,7 @@ extension PublishEditController {
         
         print("----mediaType == \(typeStr)\n----pubTitle = \(pubTitle)\n----simuTopicJsonStr == \(simuTopicJsonStr)\n----imgsJsonStr == \(imgsJsonStr)")
         
-        SwiftMoyaNetWorkServiceCommunity.shared().communityPublishApi(type: typeStr, img: majorImageUrl ?? "", topic_ids: simuTopicJsonStr, video: "", title: pubTitle, content: pubContent, location: "", imgs: imgsJsonStr) {
+        SwiftMoyaNetWorkServiceCommunity.shared().communityPublishApi(type: typeStr, img: majorImageUrl ?? "", topic_ids: simuTopicJsonStr, video: paraVideo, title: pubTitle, content: pubContent, location: "", imgs: imgsJsonStr) {
             [weak self] (communityPublishModel) -> (Void) in
             let communityPublishModel = communityPublishModel as? CommunityPublishModel
             print("----发布成功")
@@ -328,3 +363,77 @@ extension PublishEditController {
     }
     
 }
+
+// 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("上传失败!")
+            })
+            
+        case AlivcUploadStatus.success:
+            // 上传封面图
+            self.uploadVideoCoverImage()
+            
+        default:
+            break
+        }
+    }
+    
+    // 上传视频封面图
+    func uploadVideoCoverImage() {
+        SwiftMoyaNetWorkServiceConfig.shared().configUploadSingleImgWithoutHudApi(imageArray: [videoImage!]) {
+            [weak self] (imgUrl) -> (Void) in
+            // 设置主图
+            self?.majorImageUrl = imgUrl as? String
+            
+            self?.vUploadFinished = true
+            self?.subLabel.text = "上传成功!"
+            self?.rightButton.isEnabled = true
+            self?.rightButton.backgroundColor = k62CC74Color
+        }
+    }
+    
+}

+ 1 - 1
RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishEditController/View/PublishEditAddPicCell.swift

@@ -10,7 +10,7 @@ import UIKit
 
 class PublishEditAddPicCell: UITableViewCell {
     
-    private let maxImageCount: Int = 9
+    var maxImageCount: Int = 9
     
     typealias ChoosePicBlock = () -> Void
     var choosePicBlock : ChoosePicBlock?

+ 20 - 0
RainbowPlanet/RainbowPlanet/Service/SwiftMoyaService/SwiftMoyaServiceApi/SwiftMoyaServiceCommunity/SwiftMoyaNetWorkServiceCommunity.swift

@@ -147,6 +147,26 @@ public class SwiftMoyaNetWorkServiceCommunity: NSObject {
         }
     }
     
+    // MARK: - 获取上传地址和凭证
+    /// 获取上传地址和凭证
+    ///
+    /// - Parameters:
+    ///   - title: 视频标题
+    ///   - filename: 视频名称(必须带扩展名)
+    ///   - cover_url: 封面图,自定义视频封面URL地址
+    ///   - completion: 回调
+    func communityVideoUploadAuthApi(title:String = "", filename:String = "", cover_url:String = "", completion: @escaping apiCallBack) {
+        var parameters = Dictionary<String,Any>()
+        parameters.updateValue(title, forKey: "title")
+        parameters.updateValue(filename, forKey: "filename")
+        parameters.updateValue(cover_url, forKey: "cover_url")
+        SwiftProgressHUD.shared().showWait()
+        SwiftMoyaNetWorkManager.shared.requestObject(CommunityVideoAuthModel.self, target: MultiTarget(SwiftMoyaServiceCommunityApi.communityVideoUploadAuth(parameters: parameters))) { (communityVideoAuthModel) in
+            SwiftProgressHUD.shared().hide()
+            completion(communityVideoAuthModel)
+        }
+    }
+    
     // MARK: - 多关注页面feed流
     /// 多关注页面feed流
     ///

+ 12 - 0
RainbowPlanet/RainbowPlanet/Service/SwiftMoyaService/SwiftMoyaServiceApi/SwiftMoyaServiceCommunity/SwiftMoyaServiceCommunityApi.swift

@@ -33,6 +33,10 @@ public let kCommunityPostsApi = "/community/post"
 /// 发布内容(Post)
 public let kCommunityPublishApi = "/community/post"
 
+// MARK: - 获取上传地址和凭证
+/// 获取上传地址和凭证
+public let kCommunityVideoUploadAuthApi = "/community/getVodUploadAuth"
+
 // MARK: - 关注页面feed流
 /// 关注页面feed流
 public let kCommunityFollowFeedApi = "/community/feed"
@@ -69,6 +73,7 @@ public let kCommunityMemberFollowTopicCancelFollowApi = "/community/memberFollow
 /// - communityTopics: 话题列表
 /// - communityPosts: 内容列表
 /// - communityPublish: 发布内容
+/// - communityVideoUploadAuth: 视频上传凭证
 /// - communityFeed: 关注页面feed流
 /// - communityPostSuggest: 关注页面feed流
 /// - communityTopicDetail: 话题详情
@@ -84,6 +89,7 @@ public enum SwiftMoyaServiceCommunityApi {
     case communityTopics(parameters:Dictionary<String, Any>)
     case communityPosts(parameters:Dictionary<String, Any>)
     case communityPublish(parameters:Dictionary<String, Any>)
+    case communityVideoUploadAuth(parameters:Dictionary<String, Any>)
     case communityFollowFeed(parameters:Dictionary<String, Any>)
     case communityPostSuggest(parameters:Dictionary<String, Any>)
     case communityTopicDetail(parameters:Dictionary<String, Any>)
@@ -103,6 +109,7 @@ extension SwiftMoyaServiceCommunityApi: TargetType {
              .communityTopics,
              .communityPosts,
              .communityPublish,
+             .communityVideoUploadAuth,
              .communityFollowFeed,
              .communityPostSuggest,
              .communityTopicDetail,
@@ -129,6 +136,8 @@ extension SwiftMoyaServiceCommunityApi: TargetType {
             return kCommunityPostsApi
         case .communityPublish:
             return kCommunityPublishApi
+        case .communityVideoUploadAuth:
+            return kCommunityVideoUploadAuthApi
         case .communityFollowFeed:
             return kCommunityFollowFeedApi
         case .communityPostSuggest:
@@ -157,6 +166,7 @@ extension SwiftMoyaServiceCommunityApi: TargetType {
              .communityPostMy,
              .communityTopics,
              .communityPosts,
+             .communityVideoUploadAuth,
              .communityFollowFeed,
              .communityPostSuggest,
              .communityTopicDetail,
@@ -180,6 +190,7 @@ extension SwiftMoyaServiceCommunityApi: TargetType {
              .communityTopics(var parameters),
              .communityPosts(var parameters),
              .communityPublish(var parameters),
+             .communityVideoUploadAuth(var parameters),
              .communityFollowFeed(var parameters),
              .communityPostSuggest(var parameters),
              .communityTopicDetail(var parameters),
@@ -215,6 +226,7 @@ extension SwiftMoyaServiceCommunityApi: TargetType {
              .communityTopics,
              .communityPosts,
              .communityPublish,
+             .communityVideoUploadAuth,
              .communityFollowFeed,
              .communityPostSuggest,
              .communityTopicDetail,

+ 23 - 0
RainbowPlanet/RainbowPlanet/Service/SwiftMoyaService/SwiftMoyaServiceApi/SwiftMoyaServiceConfig/SwiftMoyaNetWorkServiceConfig.swift

@@ -104,6 +104,29 @@ class SwiftMoyaNetWorkServiceConfig: NSObject {
         }
     }
     
+    // MARK: 单图上传(无提示框)
+    /// 单图上传
+    ///
+    /// - Parameters:
+    ///   - imageArray: 图片数据
+    ///   - completion: null
+    func configUploadSingleImgWithoutHudApi(imageArray:Array<UIImage>, completion: @escaping apiCallBack) {
+        
+        var  multipartData = Array<Any>()
+        let  parameters = Dictionary<String,Any>()
+        for (_,image) in imageArray.enumerated() {
+            let data = image.jpegData(compressionQuality: 1)
+            let today = Date()
+            let formData = MultipartFormData(provider: .data(data!), name: "image",fileName: "\(today).png", mimeType: "image/png")
+            
+            multipartData.append(formData)
+        }
+        SwiftMoyaNetWorkManager.shared.requestObject(ImageUrlModel.self, target: MultiTarget(SwiftMoyaServiceConfigApi.configUploadSingleImg(parameters: parameters, dataArray: multipartData))) { (imageUrlModel) in
+            let imageUrlModel = imageUrlModel as! ImageUrlModel
+            completion(imageUrlModel.url as Any)
+        }
+    }
+    
     // MARK: 多图上传
     /// 多图上传
     ///

+ 8 - 1
RainbowPlanet/RainbowPlanet/Service/SwiftMoyaService/SwiftMoyaServiceApi/SwiftMoyaServiceConfig/SwiftMoyaServiceConfigApi.swift

@@ -35,12 +35,14 @@ public let kConfigConfigApi = "/config/config"
 /// - configPickupNodeIndex: 自提点列表
 /// - configCityManagementIndex: 已开通城市列表
 /// - configUploadSingleImg: 单图上传
+/// - configUploadSingleImgWithoutHud: 单图上传
 /// - configUploadMultiImg: 单图上传
 public enum SwiftMoyaServiceConfigApi {
     case configConfig(parameters:Dictionary<String,Any>)
     case configPickupNodeIndex(parameters:Dictionary<String, Any>)
     case configCityManagementIndex(parameters:Dictionary<String, Any>)
     case configUploadSingleImg(parameters:Dictionary<String, Any>,dataArray:Array<Any>)
+    case configUploadSingleImgWithoutHud(parameters:Dictionary<String, Any>,dataArray:Array<Any>)
     case configUploadMultiImg(parameters:Dictionary<String, Any>,dataArray:Array<Any>)
 }
 
@@ -52,6 +54,7 @@ extension SwiftMoyaServiceConfigApi: TargetType {
              .configPickupNodeIndex,
              .configCityManagementIndex,
              .configUploadSingleImg,
+             .configUploadSingleImgWithoutHud,
              .configUploadMultiImg
             :
             return URL(string: kApiDataPrefix())!
@@ -66,7 +69,8 @@ extension SwiftMoyaServiceConfigApi: TargetType {
             return kConfigPickupNodeIndexApi
         case .configCityManagementIndex:
             return kConfigCityManagementIndexApi
-        case .configUploadSingleImg:
+        case .configUploadSingleImg,
+             .configUploadSingleImgWithoutHud:
             return kConfigUploadSingleImgApi
         case .configUploadMultiImg:
             return kConfigUploadMultiImgApi
@@ -81,6 +85,7 @@ extension SwiftMoyaServiceConfigApi: TargetType {
             :
             return .get
         case .configUploadSingleImg,
+             .configUploadSingleImgWithoutHud,
              .configUploadMultiImg
             :
             return .post
@@ -99,6 +104,7 @@ extension SwiftMoyaServiceConfigApi: TargetType {
             return .requestParameters(parameters: parameters, encoding: URLEncoding.default)
             
         case .configUploadSingleImg(_,let dataArray),
+             .configUploadSingleImgWithoutHud(_,let dataArray),
              .configUploadMultiImg(_,let dataArray)
             :
             return .uploadMultipart(dataArray as! [MultipartFormData])
@@ -127,6 +133,7 @@ extension SwiftMoyaServiceConfigApi: TargetType {
         case .configPickupNodeIndex,
              .configCityManagementIndex,
              .configUploadSingleImg,
+             .configUploadSingleImgWithoutHud,
              .configUploadMultiImg
             :
             return (headerParameters(headerType: .tokenHeader) as! [String : String])