|
@@ -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
|