123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245 |
- //
- // NYClassRoomPeiCell.m
- // jiaPei
- //
- // Created by Ning.ge on 2024/2/4.
- // Copyright © 2024 JCZ. All rights reserved.
- //
- #import "NYClassRoomPeiCell.h"
- #import "NYClassRoomPeiViewModel.h"
- #import "MapManager.h"
- #import "TZImagePickerController.h"//第三方相册
- @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
- #pragma mark - PublicMethods
- + (instancetype)cellWithCollectionView:(UICollectionView *)collectionView forIndexPath:(NSIndexPath *)indexPath {
- static NSString *ID = @"NYClassRoomPeiCell";
- [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;
- RAC(self.coach_name_label, text) = [[RACObserve(cultInfoModel, coachName) takeUntil:self.rac_prepareForReuseSignal] deliverOnMainThread];
- RAC(self.stu_name_label, text) = [[RACObserve(cultInfoModel, stuName) takeUntil:self.rac_prepareForReuseSignal] deliverOnMainThread];
- RAC(self.cat_type_label, text) = [[RACObserve(cultInfoModel, stuCx) takeUntil:self.rac_prepareForReuseSignal] deliverOnMainThread];
- RAC(self.cat_num_label, text) = [[RACObserve(cultInfoModel, licnum) takeUntil:self.rac_prepareForReuseSignal] deliverOnMainThread];
- RAC(self.room_name_label, text) = [[RACObserve(cultInfoModel, roomName) takeUntil:self.rac_prepareForReuseSignal] deliverOnMainThread];
- RAC(self.school_name_label, text) = [[RACObserve(cultInfoModel, schName) takeUntil:self.rac_prepareForReuseSignal] deliverOnMainThread];
- RAC(self.sign_time_label, text) = [[RACObserve(cultInfoModel, signTime) takeUntil:self.rac_prepareForReuseSignal] deliverOnMainThread];
- RAC(self.pei_type_label, text) = [[RACObserve(cultInfoModel, typeName) takeUntil:self.rac_prepareForReuseSignal] deliverOnMainThread];
-
- }
- - (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) {
- [MBProgressHUD rq_hideHUD];
- if (success) {
- _myLocation = location.coordinate;
- }
- }];
- }
- //获取 课堂 信息
- - (void)getClassRoomInfo{
- NSMutableArray *arr = [NSMutableArray array];
- [arr property:RQ_USER_MANAGER.currentUser.outId forKey:@"outid"];
- [arr property:@"1" forKey:@"type"];//1课堂 2模拟
- [arr property:RQ_USER_MANAGER.currentUser.city forKey:@"dqbh"];
- NSString* method = @"getStunocarSignInfo";
- [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * dict) {
- if ([dict[@"code"] intValue]!=0) {
- return;
- }
- CultivateInfoModel *cultInfoModel = [CultivateInfoModel modelWithDictionary:[NSMutableDictionary dictionaryWithDictionary:dict[@"body"]]];
- [self setCultivateInfoModel:cultInfoModel];
- }];
- }
- //获取课堂 照片
- - (void)getPhotoArray{
- NSMutableArray *arr = [NSMutableArray array];
- [arr property:RQ_USER_MANAGER.currentUser.outId forKey:@"outid"];
- [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";
- [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * dict) {
- //NSLog(@"getStunocarSignInfodict=====%@",dict);
- NSArray<CultivatePhotoModel*> *photo_array = [CultivatePhotoModel modelArrayWithJSON:dict[@"body"][@"photos"]];
- [self.photosArray addObjectsFromArray:photo_array];
- [self.collectionView reloadData];
- }];
- }
- - (IBAction)submit_clickdo:(UIButton *)sender {
-
- CultivateInfoModel *cultInfoModel = self.viewModel.cultivateInfoModel;
- // roomLat roomLng maxDistance
- NSString *title = [NSString stringWithFormat:@"您距离课堂超过了%@m",cultInfoModel.maxDistance];
- //计算距离
- double this_distance = 0.0;
- double lat1 = cultInfoModel.roomLat.doubleValue;
- double lng1 = cultInfoModel.roomLng.doubleValue;
- if(_myLocation.latitude >0){
- double lat2 = _myLocation.latitude;
- double lng2 = _myLocation.longitude;
- this_distance = [self distanceBetweenOrderBy:lat1 :lat2 :lng1 :lng2];
- }
- if(this_distance>cultInfoModel.maxDistance.doubleValue){//超出范围
- // if(cultInfoModel.isDistance){//是否强制 判断-范围
- // [RQ_SHARE_FUNCTION showAlertWithTitle:@"提示" message:title alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"取消" otherButtonTitles:@[@"确定"] otherButtonStyles:nil showInWindow:NO completion:^(NSUInteger selectedOtherButtonIndex) {
- // if (selectedOtherButtonIndex == 0) {
- //
- // }
- // }];
- // }else{
- // [RQ_SHARE_FUNCTION showAlertWithTitle:@"提示" message:title alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:nil otherButtonTitles:@[@"确定"] otherButtonStyles:@"取消" showInWindow:NO completion:^(NSUInteger selectedOtherButtonIndex) {
- // if (selectedOtherButtonIndex == 0) {
- //
- // }
- // }];
- // }
- }else{//未超出范围
- //直接-进入人脸-签到流程
-
- }
-
- //-人脸比对
- /// 1.本地活体检测
- [RQ_CHECKBODY_MANAGER beginCheckBodyWithCheckNum:RQ_USER_MANAGER.ycbdFaceCount completeBlock:^(BOOL success, NSDictionary * _Nullable dic) {
- //@strongify(self)
- if (success) {
- /// 2.线上活体检测
- NSMutableArray *arr = [NSMutableArray array];
- [arr property:RQ_USER_MANAGER.currentUser.outId forKey:@"stuId"];
- [arr property:@"1" forKey:@"type"];//1课堂 2模拟
- [arr property:RQ_USER_MANAGER.currentUser.city forKey:@"dqbh"];
- [arr property:@"183093223" forKey:@"photo"];
- NSString* method = @"stunocarfaceToface";
- [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * dict) {
- //NSLog(@"getStunocarSignInfodict=====%@",dict);
-
- }];
-
- /// 3. updateStunocarPhoto 过程上传
- }
- }];
- //上传-课堂照片
-
- }
- -(double)distanceBetweenOrderBy:(double) latitude1 :(double) latitude2 :(double) longitude1 :(double) longitude2{
-
- CLLocation *curLocation = [[CLLocation alloc] initWithLatitude:latitude1 longitude:longitude1];
-
- CLLocation *otherLocation = [[CLLocation alloc] initWithLatitude:latitude2 longitude:longitude2];
-
- // 计算两个坐标之间的距离
- CLLocationDistance distance = [curLocation distanceFromLocation:otherLocation];
- //double distance = [curLocation distanceFromLocation:otherLocation];
-
- return distance;
-
- }
- -(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 {
- [super awakeFromNib];
- self.contentView.backgroundColor = UIColor.clearColor;
-
- _px00_view.layer.shadowColor = RGBA_COLOR(124, 129, 136, 0.2).CGColor;
- _px01_view.layer.shadowColor = RGBA_COLOR(124, 129, 136, 0.2).CGColor;
-
- }
- - (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
|