Parcourir la source

课堂 签到 图片 展示 完成, 基本逻辑 写完。 up 85%

openlockPPP il y a 1 an
Parent
commit
53fd11526b

BIN
jiaPei.xcworkspace/xcuserdata/mimasigeling.xcuserdatad/UserInterfaceState.xcuserstate


+ 4 - 0
jiaPei/NewTheory/View/NYClassRoomPeiCell.h

@@ -34,6 +34,10 @@ NS_ASSUME_NONNULL_BEGIN
 
 @property (weak, nonatomic) IBOutlet UIButton *submit_btn;
 
+//照片 图片 - collectionView
+@property (weak, nonatomic) IBOutlet UIView *imageArrayView;
+@property (nonatomic ,strong) UICollectionView *collectionView;
+
 @end
 
 NS_ASSUME_NONNULL_END

+ 76 - 19
jiaPei/NewTheory/View/NYClassRoomPeiCell.m

@@ -9,13 +9,20 @@
 #import "NYClassRoomPeiCell.h"
 #import "NYClassRoomPeiViewModel.h"
 #import "MapManager.h"
+#import "TZImagePickerController.h"//第三方相册
 
-@interface NYClassRoomPeiCell ()
+@interface NYClassRoomPeiCell ()<TZImagePickerControllerDelegate,UICollectionViewDelegate,UICollectionViewDataSource>{
+    CGFloat _itemWH;
+    CGFloat _margin;
+    NSInteger _index;
+}
 
 @property (nonatomic, readwrite, strong) NYClassRoomPeiViewModel *viewModel;
 
 @property (nonatomic, readwrite, assign) CLLocationCoordinate2D  myLocation;
 
+@property (nonatomic ,strong) NSMutableArray *photosArray;
+
 @end
 
 @implementation NYClassRoomPeiCell
@@ -25,10 +32,19 @@
     [collectionView registerNib:[UINib nibWithNibName:ID bundle:nil] forCellWithReuseIdentifier:ID];
     NYClassRoomPeiCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:ID forIndexPath:indexPath];
     if (!cell) cell = [self rq_viewFromXib];
-
+    [cell setup_UI];
     return cell;
 }
 
+-(void)setup_UI{
+    [self.collectionView registerClass:[CollectionViewCell class] forCellWithReuseIdentifier:@"cell"];
+    [self.imageArrayView addSubview:self.collectionView];
+    [self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.edges.mas_equalTo(self.imageArrayView);
+    }];
+    self.collectionView.backgroundColor = [UIColor colorWithHexString:@"#F2F3F5" alpha:1.0];
+}
+
 //详细
 - (void)setCultivateInfoModel:(CultivateInfoModel *)cultInfoModel{
     self.viewModel.cultivateInfoModel = cultInfoModel;
@@ -46,6 +62,7 @@
 - (void)bindViewModel:(NYClassRoomPeiViewModel *)viewModel {
     self.viewModel = viewModel;
     [self getClassRoomInfo];
+    [self getPhotoArray];
     //定位功能
     [MBProgressHUD rq_showProgressHUD:@"正在获取当前位置..."];
     [[MapManager sharedManager] updateLocationWithCompleteBlock:^(BOOL success, CLLocation * _Nonnull location, BMKLocation * _Nullable bmkLocation) {
@@ -64,7 +81,7 @@
     [arr property:RQ_USER_MANAGER.currentUser.city   forKey:@"dqbh"];
     NSString* method = @"getStunocarSignInfo";
     [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * dict) {
-        if (!dict) {
+        if ([dict[@"code"] intValue]!=0) {
             return;
         }
         CultivateInfoModel *cultInfoModel = [CultivateInfoModel modelWithDictionary:[NSMutableDictionary dictionaryWithDictionary:dict[@"body"]]];
@@ -79,26 +96,13 @@
     [arr property:@"1"  forKey:@"type"];//1课堂 2模拟
     [arr property:RQ_USER_MANAGER.currentUser.city   forKey:@"dqbh"];
     [arr property:@"183093223"   forKey:@"classid"];
-    
+    [self.photosArray removeAllObjects];
     NSString* method = @"getStunocarPhoto";
-    NSLog(@"dqbh====%@",RQ_USER_MANAGER.currentUser.city)
     [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * dict) {
         //NSLog(@"getStunocarSignInfodict=====%@",dict);
         NSArray<CultivatePhotoModel*> *photo_array = [CultivatePhotoModel modelArrayWithJSON:dict[@"body"][@"photos"]];
-        NSLog(@"photo_array=%@",photo_array);
-//        CultivateInfoModel *cultInfoModel = [CultivateInfoModel modelWithDictionary:[NSMutableDictionary dictionaryWithDictionary:dict[@"body"][@"photos"]]];
-//        NSLog(@"%@",cultInfoModel)
-//        if (!dict) {
-//            ShowMsg(@"获取当前学员签到状态接口异常!");
-//            !resultBlock? : resultBlock(NO, nil);
-//            return;
-//        }
-//        if ([dict[@"code"] isEqualToString:@"0"]) {
-//            !resultBlock? : resultBlock(YES, dict);
-//        } else {
-//            ShowMsg((dict[@"body"] && ![dict[@"body"] isEqualToString:@""])? dict[@"body"] : @"获取当前学员签到状态失败");
-//            !resultBlock? : resultBlock(NO, nil);
-//        }
+        [self.photosArray addObjectsFromArray:photo_array];
+        [self.collectionView reloadData];
     }];
 }
 
@@ -152,6 +156,8 @@
                 //NSLog(@"getStunocarSignInfodict=====%@",dict);
        
             }];
+            
+            /// 3. updateStunocarPhoto 过程上传
         }
     }];
     //上传-课堂照片
@@ -173,6 +179,28 @@
     
 }
 
+-(UICollectionView *)collectionView{
+    if (!_collectionView) {
+        UICollectionViewFlowLayout *flowLayOut = [[UICollectionViewFlowLayout alloc] init];
+        flowLayOut.itemSize = CGSizeMake(65, 65);
+        flowLayOut.sectionInset = UIEdgeInsetsMake(5, 5, 5, 5);
+        flowLayOut.scrollDirection = UICollectionViewScrollDirectionHorizontal;
+        self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:flowLayOut];
+        self.collectionView.showsHorizontalScrollIndicator = NO;
+        self.collectionView.delegate = self;
+        self.collectionView.dataSource = self;
+        //        self.collectionView.scrollEnabled = NO;
+    }
+    return _collectionView;
+}
+
+
+- (NSMutableArray *)photosArray{
+    if (!_photosArray) {
+        self.photosArray = [NSMutableArray array];
+    }
+    return _photosArray;
+}
 
 #pragma mark - SystemMethods
 - (void)awakeFromNib {
@@ -184,5 +212,34 @@
     
 }
 
+- (void)checkLocalPhoto{
+    int currentIndex = _index;
+    NSMutableArray *images = [NSMutableArray array];
+    for (CultivatePhotoModel *photoModel in self.photosArray) {
+        [images addObject:photoModel.filepath];
+    }
+    [RQ_SHARE_FUNCTION showPhotoBrowserWithDataSource:images currentIndex:currentIndex isCanSave:NO];
+}
+
+
+#pragma mark UICollectionViewDelegate
+- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
+    _index = indexPath.row;
+    [self checkLocalPhoto];
+}
+
+- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
+    return _photosArray.count;
+}
+
+- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
+    CollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
+    cell.deleteButton.hidden = YES;
+    cell.imagev.frame = CGRectMake(0, 0, 65, 65);
+    CultivatePhotoModel *photoModel = self.photosArray[indexPath.row];
+    [cell.imagev sd_setImageWithURL:[NSURL URLWithString:photoModel.filepath]];
+    return cell;
+    
+}
 
 @end

+ 16 - 2
jiaPei/NewTheory/View/NYClassRoomPeiCell.xib

@@ -249,17 +249,30 @@
                     <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="5AK-y0-nrp">
                         <rect key="frame" x="16" y="348" width="288" height="141"/>
                         <subviews>
-                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="培训照片" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="kYM-KR-Vu2">
+                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="培训照片" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="kYM-KR-Vu2">
                                 <rect key="frame" x="8" y="15" width="76" height="21"/>
-                                <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+                                <constraints>
+                                    <constraint firstAttribute="height" constant="21" id="0dI-jg-kJC"/>
+                                    <constraint firstAttribute="width" constant="76" id="2oY-jb-NNS"/>
+                                </constraints>
                                 <fontDescription key="fontDescription" type="system" pointSize="18"/>
                                 <nil key="textColor"/>
                                 <nil key="highlightedColor"/>
                             </label>
+                            <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="faB-qf-mKw">
+                                <rect key="frame" x="8" y="51" width="272" height="75"/>
+                                <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                            </view>
                         </subviews>
                         <color key="backgroundColor" systemColor="systemBackgroundColor"/>
                         <constraints>
+                            <constraint firstAttribute="trailing" secondItem="faB-qf-mKw" secondAttribute="trailing" constant="8" id="FAb-Sx-XIh"/>
+                            <constraint firstItem="kYM-KR-Vu2" firstAttribute="top" secondItem="5AK-y0-nrp" secondAttribute="top" constant="15" id="WJV-83-SKh"/>
+                            <constraint firstItem="kYM-KR-Vu2" firstAttribute="leading" secondItem="5AK-y0-nrp" secondAttribute="leading" constant="8" id="eiu-De-A1J"/>
+                            <constraint firstAttribute="bottom" secondItem="faB-qf-mKw" secondAttribute="bottom" constant="15" id="jPa-uk-Pya"/>
+                            <constraint firstItem="faB-qf-mKw" firstAttribute="leading" secondItem="5AK-y0-nrp" secondAttribute="leading" constant="8" id="lI8-K6-W2h"/>
                             <constraint firstAttribute="height" constant="141" id="mzc-NX-2nW"/>
+                            <constraint firstItem="faB-qf-mKw" firstAttribute="top" secondItem="kYM-KR-Vu2" secondAttribute="bottom" constant="15" id="p9m-Q2-nIO"/>
                         </constraints>
                         <userDefinedRuntimeAttributes>
                             <userDefinedRuntimeAttribute type="boolean" keyPath="layer.masksToBounds" value="NO"/>
@@ -319,6 +332,7 @@
                 <outlet property="cat_num_label" destination="ygt-6n-Mtq" id="v6B-nU-woo"/>
                 <outlet property="cat_type_label" destination="8rg-v2-hPZ" id="hVh-Jx-Kns"/>
                 <outlet property="coach_name_label" destination="5bo-dI-wJO" id="OQp-2E-KvC"/>
+                <outlet property="imageArrayView" destination="faB-qf-mKw" id="2c4-B2-fuQ"/>
                 <outlet property="pei_type_label" destination="P4l-Io-AnM" id="5jT-6A-GZ9"/>
                 <outlet property="px00_view" destination="lNa-sV-KWt" id="HoW-Zg-zOK"/>
                 <outlet property="px01_view" destination="5AK-y0-nrp" id="ftz-2W-xLd"/>