Prechádzať zdrojové kódy

个人风采上传视频

Steven 3 rokov pred
rodič
commit
727fb43f68
19 zmenil súbory, kde vykonal 482 pridanie a 33 odobranie
  1. 10 0
      KulexiuForTeacher/KulexiuForTeacher.xcodeproj/project.pbxproj
  2. BIN
      KulexiuForTeacher/KulexiuForTeacher.xcworkspace/xcuserdata/wangzhi.xcuserdatad/UserInterfaceState.xcuserstate
  3. 66 2
      KulexiuForTeacher/KulexiuForTeacher.xcworkspace/xcuserdata/wangzhi.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
  4. BIN
      KulexiuForTeacher/KulexiuForTeacher/Assets.xcassets/Mine/Style/image_upload.imageset/image_upload@2x.png
  5. BIN
      KulexiuForTeacher/KulexiuForTeacher/Assets.xcassets/Mine/Style/image_upload.imageset/image_upload@3x.png
  6. 22 0
      KulexiuForTeacher/KulexiuForTeacher/Assets.xcassets/Mine/Style/video_upload.imageset/Contents.json
  7. BIN
      KulexiuForTeacher/KulexiuForTeacher/Assets.xcassets/Mine/Style/video_upload.imageset/video_upload@2x.png
  8. BIN
      KulexiuForTeacher/KulexiuForTeacher/Assets.xcassets/Mine/Style/video_upload.imageset/video_upload@3x.png
  9. 69 5
      KulexiuForTeacher/KulexiuForTeacher/Module/Mine/CreateStyle/Controller/MyStyleViewController.m
  10. 29 0
      KulexiuForTeacher/KulexiuForTeacher/Module/Mine/CreateStyle/View/MyStyleImageView.h
  11. 79 0
      KulexiuForTeacher/KulexiuForTeacher/Module/Mine/CreateStyle/View/MyStyleImageView.m
  12. 131 0
      KulexiuForTeacher/KulexiuForTeacher/Module/Mine/CreateStyle/View/MyStyleImageView.xib
  13. 5 3
      KulexiuForTeacher/KulexiuForTeacher/Module/Mine/CreateStyle/View/MyStyleVideoCell.h
  14. 45 14
      KulexiuForTeacher/KulexiuForTeacher/Module/Mine/CreateStyle/View/MyStyleVideoCell.m
  15. 2 0
      KulexiuForTeacher/KulexiuForTeacher/Module/Mine/CreateStyle/View/MyStyleVideoChooseView.h
  16. 9 3
      KulexiuForTeacher/KulexiuForTeacher/Module/Mine/CreateStyle/View/MyStyleVideoChooseView.m
  17. 1 1
      KulexiuForTeacher/KulexiuForTeacher/Module/Mine/CreateStyle/View/MyStyleVideoView.h
  18. 13 4
      KulexiuForTeacher/KulexiuForTeacher/Module/Mine/CreateStyle/View/MyStyleVideoView.m
  19. 1 1
      KulexiuForTeacher/KulexiuForTeacher/Module/Mine/MinePage/View/MineVideoCell.m

+ 10 - 0
KulexiuForTeacher/KulexiuForTeacher.xcodeproj/project.pbxproj

@@ -959,6 +959,8 @@
 		BCE6A0A527F8517900C97704 /* MineVideoCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = BCE6A0A327F8517900C97704 /* MineVideoCell.xib */; };
 		BCE6A0A927F852CD00C97704 /* MineFansGroupCell.m in Sources */ = {isa = PBXBuildFile; fileRef = BCE6A0A727F852CD00C97704 /* MineFansGroupCell.m */; };
 		BCE6A0AA27F852CD00C97704 /* MineFansGroupCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = BCE6A0A827F852CD00C97704 /* MineFansGroupCell.xib */; };
+		BCE8621D28AC9CD300B30C1C /* MyStyleImageView.m in Sources */ = {isa = PBXBuildFile; fileRef = BCE8621C28AC9CD300B30C1C /* MyStyleImageView.m */; };
+		BCE8621F28AC9CDA00B30C1C /* MyStyleImageView.xib in Resources */ = {isa = PBXBuildFile; fileRef = BCE8621E28AC9CDA00B30C1C /* MyStyleImageView.xib */; };
 		BCEA751A2818D59300886A86 /* BankNameModel.m in Sources */ = {isa = PBXBuildFile; fileRef = BCEA75192818D59300886A86 /* BankNameModel.m */; };
 		BCEA751D2818F6C900886A86 /* MyCardModel.m in Sources */ = {isa = PBXBuildFile; fileRef = BCEA751C2818F6C900886A86 /* MyCardModel.m */; };
 		BCEA752028190CEB00886A86 /* CardBandResultViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = BCEA751F28190CEB00886A86 /* CardBandResultViewController.m */; };
@@ -2641,6 +2643,9 @@
 		BCE6A0A627F852CD00C97704 /* MineFansGroupCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MineFansGroupCell.h; sourceTree = "<group>"; };
 		BCE6A0A727F852CD00C97704 /* MineFansGroupCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MineFansGroupCell.m; sourceTree = "<group>"; };
 		BCE6A0A827F852CD00C97704 /* MineFansGroupCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MineFansGroupCell.xib; sourceTree = "<group>"; };
+		BCE8621B28AC9CD300B30C1C /* MyStyleImageView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MyStyleImageView.h; sourceTree = "<group>"; };
+		BCE8621C28AC9CD300B30C1C /* MyStyleImageView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MyStyleImageView.m; sourceTree = "<group>"; };
+		BCE8621E28AC9CDA00B30C1C /* MyStyleImageView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MyStyleImageView.xib; sourceTree = "<group>"; };
 		BCEA75182818D59300886A86 /* BankNameModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BankNameModel.h; sourceTree = "<group>"; };
 		BCEA75192818D59300886A86 /* BankNameModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BankNameModel.m; sourceTree = "<group>"; };
 		BCEA751B2818F6C900886A86 /* MyCardModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MyCardModel.h; sourceTree = "<group>"; };
@@ -5158,6 +5163,9 @@
 				BCF61BDA280417100000ACFE /* MyStyleVideoView.h */,
 				BCF61BDB280417100000ACFE /* MyStyleVideoView.m */,
 				BCF61BDD280417190000ACFE /* MyStyleVideoView.xib */,
+				BCE8621B28AC9CD300B30C1C /* MyStyleImageView.h */,
+				BCE8621C28AC9CD300B30C1C /* MyStyleImageView.m */,
+				BCE8621E28AC9CDA00B30C1C /* MyStyleImageView.xib */,
 				BCC03F8A280526B300461B7C /* MyStyleVideoChooseView.h */,
 				BCC03F8B280526B300461B7C /* MyStyleVideoChooseView.m */,
 				BCF61BE5280425DA0000ACFE /* InstrumentChooseCell.h */,
@@ -6874,6 +6882,7 @@
 				BCD6D16C28195FC5009A773E /* CashRecordHeadView.xib in Resources */,
 				BC5EB5AB2803D86500B4A3B0 /* AccompanyAlertView.xib in Resources */,
 				BCE6A08C27F823A300C97704 /* AccompanyCourseCell.xib in Resources */,
+				BCE8621F28AC9CDA00B30C1C /* MyStyleImageView.xib in Resources */,
 				BC7CFFBA2817E9FC00CAEB21 /* echarts.min.js in Resources */,
 				BC3673D528A606A500059721 /* live_animation_2.png in Resources */,
 				BC71D2012887FDD40010F14B /* img_18.png in Resources */,
@@ -7323,6 +7332,7 @@
 				BCC5841A28AA36CF00BAB4CF /* BadgeIntroduceView.m in Sources */,
 				27D83F5727F4224F00062476 /* LivePreviewBodyView.m in Sources */,
 				BC1191F6280EBC7D00A716F7 /* AccompanyDetailBottomView.m in Sources */,
+				BCE8621D28AC9CD300B30C1C /* MyStyleImageView.m in Sources */,
 				BCB909042851E25D00F5FF69 /* KSShareChooseViewController.m in Sources */,
 				277932B927E30FFE0010E277 /* TADotView.m in Sources */,
 				2773204D27EDB72B008FAECA /* LFPopupMenu.m in Sources */,

BIN
KulexiuForTeacher/KulexiuForTeacher.xcworkspace/xcuserdata/wangzhi.xcuserdatad/UserInterfaceState.xcuserstate


+ 66 - 2
KulexiuForTeacher/KulexiuForTeacher.xcworkspace/xcuserdata/wangzhi.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

@@ -857,8 +857,8 @@
             filePath = "KulexiuForTeacher/Module/Mine/CreateStyle/Controller/MyStyleViewController.m"
             startingColumnNumber = "9223372036854775807"
             endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "251"
-            endingLineNumber = "251"
+            startingLineNumber = "315"
+            endingLineNumber = "315"
             landmarkName = "-uploadUrlAndGetImagePath:"
             landmarkType = "7">
          </BreakpointContent>
@@ -1167,5 +1167,69 @@
             landmarkType = "7">
          </BreakpointContent>
       </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            uuid = "AA4FE077-6265-42C4-859C-9CC4192E0B7E"
+            shouldBeEnabled = "No"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "KulexiuForTeacher/Module/Mine/CreateStyle/View/MyStyleImageView.m"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "45"
+            endingLineNumber = "45"
+            landmarkName = "-configWithSource:"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            uuid = "91F24EC9-CAA1-4FB1-A2C8-AABB25D841E5"
+            shouldBeEnabled = "No"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "KulexiuForTeacher/Module/Mine/CreateStyle/View/MyStyleImageView.m"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "60"
+            endingLineNumber = "60"
+            landmarkName = "-chooseImageAction:"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            uuid = "E504AF2B-9461-43BA-9CD5-0FAA61805B6E"
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "KulexiuForTeacher/Module/Mine/CreateStyle/Controller/MyStyleViewController.m"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "307"
+            endingLineNumber = "307"
+            landmarkName = "-uploadImage:index:"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            uuid = "0953EE9C-B8F8-4FC3-8744-2B859693C9B9"
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "KulexiuForTeacher/Module/Mine/CreateStyle/Controller/MyStyleViewController.m"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "301"
+            endingLineNumber = "301"
+            landmarkName = "-uploadImage:index:"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
    </Breakpoints>
 </Bucket>

BIN
KulexiuForTeacher/KulexiuForTeacher/Assets.xcassets/Mine/Style/image_upload.imageset/image_upload@2x.png


BIN
KulexiuForTeacher/KulexiuForTeacher/Assets.xcassets/Mine/Style/image_upload.imageset/image_upload@3x.png


+ 22 - 0
KulexiuForTeacher/KulexiuForTeacher/Assets.xcassets/Mine/Style/video_upload.imageset/Contents.json

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

BIN
KulexiuForTeacher/KulexiuForTeacher/Assets.xcassets/Mine/Style/video_upload.imageset/video_upload@2x.png


BIN
KulexiuForTeacher/KulexiuForTeacher/Assets.xcassets/Mine/Style/video_upload.imageset/video_upload@3x.png


+ 69 - 5
KulexiuForTeacher/KulexiuForTeacher/Module/Mine/CreateStyle/Controller/MyStyleViewController.m

@@ -121,6 +121,22 @@
         [self MBPShow:@"至少选择一个可教授乐器"];
         return;
     }
+    if (self.videoArray.count <= 0) {
+        [self MBPShow:@"至少上传一个视频"];
+        return;
+    }
+    
+    BOOL hasEmptyCover = NO;
+    for (StyleVideoModel *model in self.videoArray) {
+        if ([NSString isEmptyString:model.cover]) {
+            hasEmptyCover = YES;
+            break;
+        }
+    }
+    if (hasEmptyCover) {
+        [self MBPShow:@"请上传视频封面图"];
+        return;
+    }
     NSMutableArray *subjectIdArray = [NSMutableArray array];
     NSMutableArray *subjectNameArray = [NSMutableArray array];
     
@@ -215,9 +231,8 @@
             [self.mediaManager noAlertCallback:^(NSString * _Nullable videoUrl, NSMutableArray * _Nullable imageArray, NSMutableArray * _Nullable imageAsset) {
                 NSLog(@"%@", videoUrl);
                 // 先选择首帧图
-                [weakSelf uploadUrlAndGetImagePath:videoUrl];
-//                // 上传视频
-//                [weakSelf uploadVideoWithUrl:videoUrl];
+//                [weakSelf uploadUrlAndGetImagePath:videoUrl];
+                [weakSelf uploadVideoWithUrl:videoUrl coverUrl:nil];
             }];
             [self.mediaManager pushImagePickerController];
         }
@@ -232,7 +247,7 @@
             
         }
             break;
-        case STYLEVIDEO_DELETE: // 删除
+        case STYLEVIDEO_DELETE_VIDEO: // 删除
         {
             NSInteger index = container.tag - 1000;
             if (self.videoArray.count > index) {
@@ -241,17 +256,66 @@
             [self.tableView reloadData];
         }
             break;
+        case STYLEVIDEO_CHOOSEIMAGR: // 选择图片
+        {
+            NSInteger index = container.tag - 2000;
+            // 调用相册
+            self.mediaManager = [[KSMediaManager alloc] init];
+            self.mediaManager.mediaType = MEDIATYPE_PHOTO;
+            self.mediaManager.maxPhotoNumber = 1;
+            self.mediaManager.baseCtrl = self;
+            self.mediaManager.needCropImage = NO;
+            MJWeakSelf;
+            [self.mediaManager noAlertCallback:^(NSString * _Nullable videoUrl, NSMutableArray * _Nullable imageArray, NSMutableArray * _Nullable imageAsset) {
+                // 上传图片
+                [weakSelf uploadImage:[imageArray lastObject] index:index];
+                // 先选择首帧图
+//                [weakSelf uploadUrlAndGetImagePath:videoUrl];
+                // get 图片
+            }];
+            [self.mediaManager pushImagePickerController];
+        }
+            break;
+        case STYLEVIDEO_DELETE_IMAGE: // 删除视频
+        {
+            NSInteger index = container.tag - 2000;
+            if (self.videoArray.count > index) {
+                StyleVideoModel *model = self.videoArray[index];
+                model.cover = nil;
+            }
+            [self.tableView reloadData];
+        }
+            break;
         default:
             break;
     }
 }
 
+- (void)uploadImage:(UIImage *)firstImage index:(NSInteger)index  {
+    // 上传图片
+    NSData *imgData = [UIImage compressImage:firstImage maxLength:5];
+    NSString *fileName = @"styleImage";
+    [[KSUploadManager shareInstance] configBucketName:@"daya"];
+    [[KSUploadManager shareInstance] uploadImage:imgData fileName:fileName successCallback:^(NSMutableArray * _Nonnull fileUrlArray) {
+        NSString *imageUrl = [fileUrlArray lastObject];
+        if (self.videoArray.count > index) {
+            StyleVideoModel *model = self.videoArray[index];
+            model.cover = imageUrl;
+            [self.tableView reloadData];
+        }
+    } faliure:^(NSError * _Nullable error, NSString * _Nullable descMessaeg) {
+        if ([NSString isEmptyString:descMessaeg]) {
+            [self MBPShow:descMessaeg];
+        }
+    }];
+}
+
 - (void)uploadUrlAndGetImagePath:(NSString *)videoUrl {
     [KSVideoHelper getLocalVideoPreViewUrlWithPath:videoUrl callback:^(UIImage * _Nullable firstImage) {
         if (firstImage) {
             // 上传图片
             NSData *imgData = [UIImage compressImage:firstImage maxLength:5];
-            NSString *fileName = @"whiteboardImage";
+            NSString *fileName = @"styleImage";
             [[KSUploadManager shareInstance] configBucketName:@"daya"];
             [[KSUploadManager shareInstance] uploadImage:imgData fileName:fileName successCallback:^(NSMutableArray * _Nonnull fileUrlArray) {
                 NSString *imageUrl = [fileUrlArray lastObject];

+ 29 - 0
KulexiuForTeacher/KulexiuForTeacher/Module/Mine/CreateStyle/View/MyStyleImageView.h

@@ -0,0 +1,29 @@
+//
+//  MyStyleImageView.h
+//  KulexiuForTeacher
+//
+//  Created by 王智 on 2022/8/17.
+//
+
+#import <UIKit/UIKit.h>
+#import "MyStyleVideoCell.h"
+#import "StyleVideoModel.h"
+
+@class MyStyleImageView;
+
+typedef void(^StyleImageAction)(STYLEVIDEO type, MyStyleImageView * _Nonnull videoView);
+
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface MyStyleImageView : UIView
+
++ (instancetype)shareInstance;
+
+- (void)configWithSource:(StyleVideoModel *)source;
+
+- (void)imageOperationAcion:(StyleImageAction)callback;
+
+@end
+
+NS_ASSUME_NONNULL_END

+ 79 - 0
KulexiuForTeacher/KulexiuForTeacher/Module/Mine/CreateStyle/View/MyStyleImageView.m

@@ -0,0 +1,79 @@
+//
+//  MyStyleImageView.m
+//  KulexiuForTeacher
+//
+//  Created by 王智 on 2022/8/17.
+//
+
+#import "MyStyleImageView.h"
+
+@interface MyStyleImageView ()
+
+@property (weak, nonatomic) IBOutlet UIButton *deleteButton;
+
+@property (weak, nonatomic) IBOutlet UIImageView *imageView;
+
+@property (weak, nonatomic) IBOutlet UIView *statusView;
+
+@property (weak, nonatomic) IBOutlet UILabel *statusLabel;
+
+@property (nonatomic, copy) StyleImageAction callback;
+
+@end
+
+@implementation MyStyleImageView
+
+- (void)awakeFromNib {
+    [super awakeFromNib];
+}
+
++ (instancetype)shareInstance {
+    MyStyleImageView *view = [[[NSBundle mainBundle] loadNibNamed:@"MyStyleImageView" owner:nil options:nil] firstObject];
+    return view;
+}
+
+- (void)imageOperationAcion:(StyleImageAction)callback {
+    if (callback) {
+        self.callback = callback;
+    }
+}
+
+- (void)configWithSource:(StyleVideoModel *)source {
+    
+    [self.imageView sd_setImageWithURL:[NSURL URLWithString:[source.cover getUrlEndcodeString]] placeholderImage:[UIImage imageNamed:@"video_placeholder"]];
+    
+    if ([source.authStatus isEqualToString:@"DOING"]) {
+        self.statusView.hidden = NO;
+        self.statusLabel.text = @"审核中";
+    }
+    else if ([source.authStatus isEqualToString:@"UNPASS"]) {
+        self.statusView.hidden = NO;
+        self.statusLabel.text = @"审核失败";
+    }
+    else {
+        self.statusView.hidden = YES;
+    }
+}
+
+- (IBAction)chooseImageAction:(id)sender {
+    
+    if (self.callback) {
+        self.callback(STYLEVIDEO_CHOOSEIMAGR, self);
+    }
+}
+
+- (IBAction)deleteAction:(id)sender {
+    if (self.callback) {
+        self.callback(STYLEVIDEO_DELETE_IMAGE, self);
+    }
+}
+
+/*
+// Only override drawRect: if you perform custom drawing.
+// An empty implementation adversely affects performance during animation.
+- (void)drawRect:(CGRect)rect {
+    // Drawing code
+}
+*/
+
+@end

+ 131 - 0
KulexiuForTeacher/KulexiuForTeacher/Module/Mine/CreateStyle/View/MyStyleImageView.xib

@@ -0,0 +1,131 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="20037" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
+    <device id="retina6_1" orientation="portrait" appearance="light"/>
+    <dependencies>
+        <deployment identifier="iOS"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
+        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
+    </dependencies>
+    <objects>
+        <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
+        <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
+        <view contentMode="scaleToFill" id="iN0-l3-epB" customClass="MyStyleImageView">
+            <rect key="frame" x="0.0" y="0.0" width="414" height="294"/>
+            <autoresizingMask key="autoresizingMask"/>
+            <subviews>
+                <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="BVO-RJ-Mvv">
+                    <rect key="frame" x="11" y="11" width="392" height="272"/>
+                    <subviews>
+                        <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="aUb-5W-GVT">
+                            <rect key="frame" x="0.0" y="0.0" width="392" height="272"/>
+                            <subviews>
+                                <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="video_placeholder" translatesAutoresizingMaskIntoConstraints="NO" id="A1f-3J-Sq7">
+                                    <rect key="frame" x="0.0" y="0.0" width="392" height="272"/>
+                                    <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                                </imageView>
+                                <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="NGV-Qo-TPC">
+                                    <rect key="frame" x="0.0" y="0.0" width="392" height="272"/>
+                                    <inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
+                                    <connections>
+                                        <action selector="chooseImageAction:" destination="iN0-l3-epB" eventType="touchUpInside" id="HGN-YZ-zoy"/>
+                                    </connections>
+                                </button>
+                                <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="RtX-XS-shm">
+                                    <rect key="frame" x="7" y="6" width="37" height="16"/>
+                                    <subviews>
+                                        <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="审核中" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ibk-rx-ltN">
+                                            <rect key="frame" x="3" y="0.0" width="31" height="16"/>
+                                            <fontDescription key="fontDescription" type="system" pointSize="10"/>
+                                            <color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                                            <nil key="highlightedColor"/>
+                                        </label>
+                                    </subviews>
+                                    <color key="backgroundColor" red="0.99215686270000003" green="0.3803921569" blue="0.3803921569" alpha="1" colorSpace="calibratedRGB"/>
+                                    <constraints>
+                                        <constraint firstItem="ibk-rx-ltN" firstAttribute="top" secondItem="RtX-XS-shm" secondAttribute="top" id="5J1-mh-c57"/>
+                                        <constraint firstAttribute="height" constant="16" id="N75-xW-v3k"/>
+                                        <constraint firstAttribute="trailing" secondItem="ibk-rx-ltN" secondAttribute="trailing" constant="3" id="NYn-nH-5Ha"/>
+                                        <constraint firstItem="ibk-rx-ltN" firstAttribute="leading" secondItem="RtX-XS-shm" secondAttribute="leading" constant="3" id="NcL-Hb-hZz"/>
+                                        <constraint firstAttribute="bottom" secondItem="ibk-rx-ltN" secondAttribute="bottom" id="kVf-UK-7k8"/>
+                                    </constraints>
+                                    <userDefinedRuntimeAttributes>
+                                        <userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
+                                            <real key="value" value="3"/>
+                                        </userDefinedRuntimeAttribute>
+                                    </userDefinedRuntimeAttributes>
+                                </view>
+                            </subviews>
+                            <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                            <constraints>
+                                <constraint firstAttribute="bottom" secondItem="A1f-3J-Sq7" secondAttribute="bottom" id="108-xD-Msu"/>
+                                <constraint firstItem="NGV-Qo-TPC" firstAttribute="leading" secondItem="A1f-3J-Sq7" secondAttribute="leading" id="KYX-cg-hEo"/>
+                                <constraint firstItem="NGV-Qo-TPC" firstAttribute="centerX" secondItem="aUb-5W-GVT" secondAttribute="centerX" id="OJ1-Hg-NKp"/>
+                                <constraint firstAttribute="trailing" secondItem="A1f-3J-Sq7" secondAttribute="trailing" id="V8d-Hx-Mfk"/>
+                                <constraint firstItem="NGV-Qo-TPC" firstAttribute="centerY" secondItem="aUb-5W-GVT" secondAttribute="centerY" id="VZT-A5-DI3"/>
+                                <constraint firstItem="RtX-XS-shm" firstAttribute="top" secondItem="aUb-5W-GVT" secondAttribute="top" constant="6" id="XeX-bw-wVj"/>
+                                <constraint firstItem="NGV-Qo-TPC" firstAttribute="bottom" secondItem="A1f-3J-Sq7" secondAttribute="bottom" id="bNa-dU-9hb"/>
+                                <constraint firstItem="NGV-Qo-TPC" firstAttribute="trailing" secondItem="A1f-3J-Sq7" secondAttribute="trailing" id="e6p-59-7Ey"/>
+                                <constraint firstItem="A1f-3J-Sq7" firstAttribute="leading" secondItem="aUb-5W-GVT" secondAttribute="leading" id="euc-g8-qP6"/>
+                                <constraint firstItem="A1f-3J-Sq7" firstAttribute="top" secondItem="aUb-5W-GVT" secondAttribute="top" id="mP5-tQ-wyW"/>
+                                <constraint firstItem="NGV-Qo-TPC" firstAttribute="top" secondItem="A1f-3J-Sq7" secondAttribute="top" id="phW-Nu-2bA"/>
+                                <constraint firstItem="RtX-XS-shm" firstAttribute="leading" secondItem="aUb-5W-GVT" secondAttribute="leading" constant="7" id="xLc-BO-7Tu"/>
+                            </constraints>
+                            <userDefinedRuntimeAttributes>
+                                <userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
+                                    <real key="value" value="10"/>
+                                </userDefinedRuntimeAttribute>
+                            </userDefinedRuntimeAttributes>
+                        </view>
+                    </subviews>
+                    <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                    <constraints>
+                        <constraint firstItem="aUb-5W-GVT" firstAttribute="leading" secondItem="BVO-RJ-Mvv" secondAttribute="leading" id="79I-0W-5D7"/>
+                        <constraint firstAttribute="trailing" secondItem="aUb-5W-GVT" secondAttribute="trailing" id="LoH-PF-rYJ"/>
+                        <constraint firstItem="aUb-5W-GVT" firstAttribute="top" secondItem="BVO-RJ-Mvv" secondAttribute="top" id="Tgx-z5-fP4"/>
+                        <constraint firstAttribute="bottom" secondItem="aUb-5W-GVT" secondAttribute="bottom" id="o52-Yt-WiM"/>
+                    </constraints>
+                    <userDefinedRuntimeAttributes>
+                        <userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
+                            <real key="value" value="10"/>
+                        </userDefinedRuntimeAttribute>
+                    </userDefinedRuntimeAttributes>
+                </view>
+                <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="8U5-Ad-7Q8">
+                    <rect key="frame" x="392" y="0.0" width="22" height="22"/>
+                    <constraints>
+                        <constraint firstAttribute="height" constant="22" id="5tF-CA-Nok"/>
+                        <constraint firstAttribute="width" constant="22" id="TEK-63-M1j"/>
+                    </constraints>
+                    <inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
+                    <state key="normal" image="video_delete"/>
+                    <connections>
+                        <action selector="deleteAction:" destination="iN0-l3-epB" eventType="touchUpInside" id="nUW-os-TG0"/>
+                    </connections>
+                </button>
+            </subviews>
+            <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+            <constraints>
+                <constraint firstItem="BVO-RJ-Mvv" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" constant="11" id="1LO-Cg-Mjx"/>
+                <constraint firstItem="8U5-Ad-7Q8" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" id="EmR-7o-Qhg"/>
+                <constraint firstItem="BVO-RJ-Mvv" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="11" id="JSD-yt-dC6"/>
+                <constraint firstAttribute="bottom" secondItem="BVO-RJ-Mvv" secondAttribute="bottom" constant="11" id="bIH-OG-BCz"/>
+                <constraint firstAttribute="trailing" secondItem="BVO-RJ-Mvv" secondAttribute="trailing" constant="11" id="e0H-ng-g5d"/>
+                <constraint firstAttribute="trailing" secondItem="8U5-Ad-7Q8" secondAttribute="trailing" id="ed8-ar-bGH"/>
+            </constraints>
+            <nil key="simulatedTopBarMetrics"/>
+            <nil key="simulatedBottomBarMetrics"/>
+            <freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
+            <connections>
+                <outlet property="deleteButton" destination="8U5-Ad-7Q8" id="P8q-xx-LE0"/>
+                <outlet property="imageView" destination="A1f-3J-Sq7" id="c86-5l-r4e"/>
+                <outlet property="statusLabel" destination="ibk-rx-ltN" id="Yuu-EG-4t0"/>
+                <outlet property="statusView" destination="RtX-XS-shm" id="mUP-3V-RQn"/>
+            </connections>
+            <point key="canvasLocation" x="131.8840579710145" y="-105.80357142857143"/>
+        </view>
+    </objects>
+    <resources>
+        <image name="video_delete" width="22" height="22"/>
+        <image name="video_placeholder" width="103" height="72"/>
+    </resources>
+</document>

+ 5 - 3
KulexiuForTeacher/KulexiuForTeacher/Module/Mine/CreateStyle/View/MyStyleVideoCell.h

@@ -7,9 +7,11 @@
 
 #import <UIKit/UIKit.h>
 typedef NS_ENUM(NSInteger, STYLEVIDEO) {
-    STYLEVIDEO_CHOOSEFILE,  // 选择文件
-    STYLEVIDEO_PLAY,        // 播放
-    STYLEVIDEO_DELETE,      // 删除
+    STYLEVIDEO_CHOOSEFILE,        // 选择文件
+    STYLEVIDEO_CHOOSEIMAGR,       // 设置视频封面
+    STYLEVIDEO_PLAY,              // 播放
+    STYLEVIDEO_DELETE_VIDEO,      // 删除
+    STYLEVIDEO_DELETE_IMAGE,      // 删除图片
 };
 
 typedef void(^StyleVideoCellAction)(STYLEVIDEO type, UIView * _Nullable containerView);

+ 45 - 14
KulexiuForTeacher/KulexiuForTeacher/Module/Mine/CreateStyle/View/MyStyleVideoCell.m

@@ -8,6 +8,7 @@
 #import "MyStyleVideoCell.h"
 #import "MyStyleVideoView.h"
 #import "MyStyleVideoChooseView.h"
+#import "MyStyleImageView.h"
 
 @interface MyStyleVideoCell ()
 
@@ -45,39 +46,69 @@
     CGFloat yPosition = 0.0f;
     for (NSInteger i = 0; i < videoArray.count; i++) {
         StyleVideoModel *model = self.videoArray[i];
-        if (i % 2 == 0 && i != 0) {
-            yPosition += height;
-            xPosition = 0.0f;
-        }
+        // 视频预览
         MyStyleVideoView *videoView = [MyStyleVideoView shareInstance];
         videoView.frame = CGRectMake(xPosition, yPosition, viewWidth, height);
         videoView.tag = i + 1000;
         [self.videoContainer addSubview:videoView];
-        [videoView configWithSource:model];
+        [videoView configWithSource:model displayCover:NO];
         MJWeakSelf;
+        __weak typeof(videoView) weakVideoView = videoView;
         [videoView videoOperationAcion:^(STYLEVIDEO type, MyStyleVideoView * _Nonnull videoView) {
-            [weakSelf previewVideoAction:type inView:videoView];
+            [weakSelf previewVideoAction:type inView:weakVideoView];
         }];
-        xPosition += viewWidth;
+        
+        CGFloat imagePositionX = viewWidth;
+        if (![NSString isEmptyString:model.cover]) {
+            MyStyleImageView *imageDisplayView = [MyStyleImageView shareInstance];
+            imageDisplayView.frame = CGRectMake(imagePositionX, yPosition, viewWidth, height);
+            imageDisplayView.tag = i + 2000;
+            [self.videoContainer addSubview:imageDisplayView];
+            [imageDisplayView configWithSource:model];
+            MJWeakSelf;
+            __weak typeof(imageDisplayView) weakImageView = imageDisplayView;
+            [imageDisplayView imageOperationAcion:^(STYLEVIDEO type, MyStyleImageView * _Nonnull videoView) {
+                [weakSelf previewVideoAction:type inView:weakImageView];
+            }];
+        }
+        else {
+            MyStyleVideoChooseView *imageChooseView = [[MyStyleVideoChooseView alloc] initWithFrame:CGRectMake(imagePositionX, yPosition, viewWidth, height)];
+            imageChooseView.isChooseImage = YES;
+            imageChooseView.tag = i + 2000;
+            MJWeakSelf;
+            __weak typeof(imageChooseView) weakChooseView = imageChooseView;
+            [imageChooseView chooseCallback:^{
+                [weakSelf chooseImageInView:weakChooseView];
+            }];
+            [self.videoContainer addSubview:imageChooseView];
+        }
+        
+        yPosition += height;
     }
     
     if (videoArray.count < 5) {
-        if (videoArray.count % 2 == 0 && videoArray.count != 0) {
-            yPosition += height;
-            xPosition = 0.0f;
-        }
+
         MyStyleVideoChooseView *view = [[MyStyleVideoChooseView alloc] initWithFrame:CGRectMake(xPosition, yPosition, viewWidth, height)];
+        view.isChooseImage = NO;
         MJWeakSelf;
         [view chooseCallback:^{
             [weakSelf chooseVideo];
         }];
         [self.videoContainer addSubview:view];
+        self.containerHeight.constant = yPosition + height;
+    }
+    else {
+        self.containerHeight.constant = yPosition;
+    }
+}
+
+- (void)chooseImageInView:(UIView *)displayView {
+    if (self.callback) {
+        self.callback(STYLEVIDEO_CHOOSEIMAGR, displayView);
     }
-    
-    self.containerHeight.constant = yPosition + height;
 }
 
-- (void)previewVideoAction:(STYLEVIDEO)type inView:(MyStyleVideoView *)displayView {
+- (void)previewVideoAction:(STYLEVIDEO)type inView:(UIView *)displayView {
     if (self.callback) {
         self.callback(type, displayView);
     }

+ 2 - 0
KulexiuForTeacher/KulexiuForTeacher/Module/Mine/CreateStyle/View/MyStyleVideoChooseView.h

@@ -13,6 +13,8 @@ NS_ASSUME_NONNULL_BEGIN
 
 @interface MyStyleVideoChooseView : UIView
 
+@property (nonatomic, assign) BOOL isChooseImage;
+
 - (void)chooseCallback:(StyleVideoChooseCallback)callback;
 
 @end

+ 9 - 3
KulexiuForTeacher/KulexiuForTeacher/Module/Mine/CreateStyle/View/MyStyleVideoChooseView.m

@@ -19,7 +19,7 @@
 - (instancetype)initWithFrame:(CGRect)frame {
     self = [super initWithFrame:frame];
     if (self) {
-        [self configUI];
+//        [self configUI];
     }
     return self;
 }
@@ -30,7 +30,9 @@
     [self addSubview:bgView];
     [bgView drawBoardDottedLine:1.0f length:4 space:4 cornerRadius:8.0f lineColor:HexRGB(0xe3e3e3)];
     
-    UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"image_upload"]];
+    NSString *imageName = self.isChooseImage ? @"image_upload" : @"video_upload";
+    NSString *descText = self.isChooseImage ? @"上传视频封面" : @"点击上传视频";
+    UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:imageName]];
     [bgView addSubview:imgView];
     
     [imgView mas_makeConstraints:^(MASConstraintMaker *make) {
@@ -42,7 +44,7 @@
     
     UILabel *label = [[UILabel alloc] init];
     label.textAlignment = NSTextAlignmentCenter;
-    label.text = @"点击上传视频";
+    label.text = descText;
     label.font = [UIFont systemFontOfSize:14.0f];
     label.textColor = HexRGB(0x999999);
     [bgView addSubview:label];
@@ -71,6 +73,10 @@
         self.callback();
     }
 }
+- (void)setIsChooseImage:(BOOL)isChooseImage {
+    _isChooseImage = isChooseImage;
+    [self configUI];
+}
 /*
 // Only override drawRect: if you perform custom drawing.
 // An empty implementation adversely affects performance during animation.

+ 1 - 1
KulexiuForTeacher/KulexiuForTeacher/Module/Mine/CreateStyle/View/MyStyleVideoView.h

@@ -20,7 +20,7 @@ NS_ASSUME_NONNULL_BEGIN
 
 + (instancetype)shareInstance;
 
-- (void)configWithSource:(StyleVideoModel *)source;
+- (void)configWithSource:(StyleVideoModel *)source displayCover:(BOOL)displayCover;
 
 - (void)videoOperationAcion:(StyleVidelAction)callback;
 

+ 13 - 4
KulexiuForTeacher/KulexiuForTeacher/Module/Mine/CreateStyle/View/MyStyleVideoView.m

@@ -41,14 +41,20 @@
     }
 }
 
-- (void)configWithSource:(StyleVideoModel *)source {
-    if ([NSString isEmptyString:source.cover]) {
+- (void)configWithSource:(StyleVideoModel *)source displayCover:(BOOL)displayCover {
+    if (displayCover == NO) { // 如果不展示选择封面图
         [KSVideoHelper getVideoPreviewImageUrl:source.videoUrl forImageView:self.imageView placeholder:[UIImage imageNamed:@"video_placeholder"]];
     }
     else {
-        [self.imageView sd_setImageWithURL:[NSURL URLWithString:[source.cover getUrlEndcodeString]] placeholderImage:[UIImage imageNamed:@"video_placeholder"]];
+        if ([NSString isEmptyString:source.cover]) { // 如果封面图为空
+            [KSVideoHelper getVideoPreviewImageUrl:source.videoUrl forImageView:self.imageView placeholder:[UIImage imageNamed:@"video_placeholder"]];
+        }
+        else {
+            [self.imageView sd_setImageWithURL:[NSURL URLWithString:[source.cover getUrlEndcodeString]] placeholderImage:[UIImage imageNamed:@"video_placeholder"]];
+        }
     }
     
+    
     if ([source.authStatus isEqualToString:@"DOING"]) {
         self.statusView.hidden = NO;
         self.statusLabel.text = @"审核中";
@@ -63,6 +69,7 @@
 }
 
 - (IBAction)playAction:(id)sender {
+    
     if (self.callback) {
         self.callback(STYLEVIDEO_PLAY, self);
     }
@@ -70,7 +77,7 @@
 
 - (IBAction)deleteAction:(id)sender {
     if (self.callback) {
-        self.callback(STYLEVIDEO_DELETE, self);
+        self.callback(STYLEVIDEO_DELETE_VIDEO, self);
     }
 }
 
@@ -85,6 +92,8 @@
         self.deleteButton.userInteractionEnabled = YES;
     }
 }
+
+
 /*
 // Only override drawRect: if you perform custom drawing.
 // An empty implementation adversely affects performance during animation.

+ 1 - 1
KulexiuForTeacher/KulexiuForTeacher/Module/Mine/MinePage/View/MineVideoCell.m

@@ -45,7 +45,7 @@
         videoView.tag = i + 1000;
         videoView.hideDeleteButton = YES;
         [self.videoContainer addSubview:videoView];
-        [videoView configWithSource:model];
+        [videoView configWithSource:model displayCover:YES];
         MJWeakSelf;
         [videoView videoOperationAcion:^(STYLEVIDEO type, MyStyleVideoView * _Nonnull videoView) {
             [weakSelf previewVideoAction:type inView:videoView];