NYClassRoomPeiCell.m 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579
  1. //
  2. // NYClassRoomPeiCell.m
  3. // jiaPei
  4. //
  5. // Created by Ning.ge on 2024/2/4.
  6. // Copyright © 2024 JCZ. All rights reserved.
  7. // (怎么快,怎么来,先不抽取MVVM)
  8. #import "NYClassRoomPeiCell.h"
  9. #import "NYClassRoomPeiViewModel.h"
  10. #import "MapManager.h"
  11. #import "TZImagePickerController.h"//第三方相册
  12. #import "NYClassRoomPeiPhotoCell.h"
  13. #import "RQQRCodeViewController.h"
  14. @interface NYClassRoomPeiCell ()<TZImagePickerControllerDelegate,UICollectionViewDelegate,UICollectionViewDataSource>{
  15. CGFloat _itemWH;
  16. CGFloat _margin;
  17. NSInteger _index;
  18. }
  19. @property (nonatomic, readwrite, strong) NYClassRoomPeiViewModel *viewModel;
  20. @property (nonatomic, readwrite, assign) CLLocationCoordinate2D myLocation;
  21. @property (nonatomic ,strong) NSMutableArray *photosArray;
  22. @property (nonatomic ,strong) CultivateInfoModel *cultivateInfo;
  23. @property (nonatomic ,copy) NSString *qrcodeData;
  24. // 在头文件中定义一个属性来跟踪扫描状态
  25. @property (nonatomic, assign) BOOL isScanning;
  26. @property (nonatomic, assign) int gotoType;
  27. @end
  28. @implementation NYClassRoomPeiCell
  29. #pragma mark - PublicMethods
  30. + (instancetype)cellWithCollectionView:(UICollectionView *)collectionView forIndexPath:(NSIndexPath *)indexPath {
  31. static NSString *ID = @"NYClassRoomPeiCell";
  32. [collectionView registerNib:[UINib nibWithNibName:ID bundle:nil] forCellWithReuseIdentifier:ID];
  33. NYClassRoomPeiCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:ID forIndexPath:indexPath];
  34. if (!cell) cell = [self rq_viewFromXib];
  35. [cell setup_UI];
  36. return cell;
  37. }
  38. -(void)setup_UI{
  39. [self.collectionView registerClass:[NYClassRoomPeiPhotoCell class] forCellWithReuseIdentifier:@"cell"];
  40. [self.imageArrayView addSubview:self.collectionView];
  41. [self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
  42. make.edges.mas_equalTo(self.imageArrayView);
  43. }];
  44. self.collectionView.backgroundColor = [UIColor colorWithHexString:@"#F2F3F5" alpha:1.0];
  45. }
  46. //获取本地 classIdStr 绑定账号
  47. -(void)createClassIdStr{
  48. NSInteger timeStamp = [[NSDate date] timeIntervalSince1970] * 1000;
  49. NSString *timeStampStr = [NSString stringWithFormat:@"%@",[NSNumber numberWithInteger:timeStamp]];
  50. self.viewModel.cultivateInfoModel = NULL;
  51. self.viewModel.classIdStr = timeStampStr;
  52. }
  53. //详细
  54. - (void)setCultivateInfoModel:(CultivateInfoModel *)cultInfoModel{
  55. self.viewModel.cultivateInfoModel = cultInfoModel;
  56. RAC(self.coach_name_label, text) = [[RACObserve(cultInfoModel, coachName) takeUntil:self.rac_prepareForReuseSignal] deliverOnMainThread];
  57. RAC(self.stu_name_label, text) = [[RACObserve(cultInfoModel, stuName) takeUntil:self.rac_prepareForReuseSignal] deliverOnMainThread];
  58. // RAC(self.cat_type_label, text) = [[RACObserve(cultInfoModel, stuCx) takeUntil:self.rac_prepareForReuseSignal] deliverOnMainThread];
  59. RAC(self.cat_num_label, text) = [[RACObserve(cultInfoModel, licnum) takeUntil:self.rac_prepareForReuseSignal] deliverOnMainThread];
  60. RAC(self.room_name_label, text) = [[RACObserve(cultInfoModel, roomName) takeUntil:self.rac_prepareForReuseSignal] deliverOnMainThread];
  61. RAC(self.course_ptime_label, text) = [[RACObserve(cultInfoModel, timeAll) takeUntil:self.rac_prepareForReuseSignal] deliverOnMainThread];
  62. RAC(self.sign_time_label, text) = [[RACObserve(cultInfoModel, signTime) takeUntil:self.rac_prepareForReuseSignal] deliverOnMainThread];
  63. RAC(self.exit_ptime_label, text) = [[RACObserve(cultInfoModel, nextDate) takeUntil:self.rac_prepareForReuseSignal] deliverOnMainThread];
  64. RAC(self.stu_subject_label, text) = [[RACObserve(cultInfoModel, subject) takeUntil:self.rac_prepareForReuseSignal] deliverOnMainThread];
  65. if(self.viewModel.isSimulationRoom){
  66. self.submit_btn.hidden = !cultInfoModel.isTrainPhotoGc;
  67. [self updateUIBarButtonItem:0];
  68. }
  69. if(_cultivateInfo){
  70. //修改 签到状态
  71. self.not_data_view.hidden = YES;
  72. }
  73. }
  74. - (void)updateUIBarButtonItem:(int)code{
  75. self.signInOrsignOutItem.hidden = NO;
  76. if(code==99){
  77. self.signInOrsignOutItem.hidden = YES;
  78. }
  79. if(code==98){
  80. self.signInOrsignOutItem.hidden = YES;
  81. //提示-签退
  82. ShowMsg(@"后台签退了");
  83. }
  84. [self.signInOrsignOutItem setTitleNormal:@"签到"];
  85. if(_cultivateInfo){
  86. [self.signInOrsignOutItem setTitleNormal:@"签退"];
  87. }
  88. }
  89. - (void)bindViewModel:(NYClassRoomPeiViewModel *)viewModel {
  90. self.viewModel = viewModel;
  91. self.viewModel.photoType = @"19";
  92. self.viewModel.pxkm = RQ_USER_MANAGER.currentUser.pxjd;//用户阶段
  93. [self getClassRoomInfo];
  94. //定位功能
  95. __weak typeof(self) weakSelf = self;
  96. [MBProgressHUD rq_showProgressHUD:@"正在获取当前位置..."];
  97. [[MapManager sharedManager] updateLocationWithCompleteBlock:^(BOOL success, CLLocation * _Nonnull location, BMKLocation * _Nullable bmkLocation) {
  98. [MBProgressHUD rq_hideHUD];
  99. if (success) {
  100. _myLocation = location.coordinate;
  101. }
  102. }];
  103. }
  104. //获取 课堂 信息
  105. - (void)getClassRoomInfo{
  106. NSString *type = self.viewModel.classType;
  107. NSMutableArray *arr = [NSMutableArray array];
  108. [arr property:RQ_USER_MANAGER.currentUser.outId forKey:@"outid"];
  109. [arr property:type forKey:@"type"];//1课堂 2模拟
  110. [arr property:RQ_USER_MANAGER.currentUser.city forKey:@"dqbh"];
  111. NSString* method = @"getStunocarSignInfo";
  112. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * dict) {
  113. if (dict==nil||[dict[@"code"] intValue]!=0) {
  114. self.not_data_view.hidden = NO;
  115. self.cultivateInfo = nil;
  116. [self updateUIBarButtonItem:[dict[@"code"] intValue]];
  117. return;
  118. }
  119. CultivateInfoModel *cultInfoModel = [CultivateInfoModel modelWithDictionary:[NSMutableDictionary dictionaryWithDictionary:dict[@"body"]]];
  120. self.cultivateInfo = cultInfoModel;
  121. [self getPhotoArray];
  122. }];
  123. }
  124. //获取课堂 照片
  125. - (void)getPhotoArray{
  126. __weak typeof(self) weakSelf = self;
  127. NSString *classid = self.cultivateInfo.classid;
  128. NSString *type = self.viewModel.classType;
  129. NSMutableArray *arr = [NSMutableArray array];
  130. [arr property:RQ_USER_MANAGER.currentUser.outId forKey:@"outid"];
  131. [arr property:type forKey:@"type"];//1课堂 2模拟
  132. [arr property:RQ_USER_MANAGER.currentUser.city forKey:@"dqbh"];
  133. [arr property:classid forKey:@"classid"];
  134. [self.photosArray removeAllObjects];
  135. NSString* method = @"getStunocarPhoto";
  136. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * dict) {
  137. if (dict==nil||[dict[@"code"] intValue]!=0) {
  138. self.not_data_view.hidden = NO;
  139. return;
  140. }
  141. self.cultivateInfo.timeAll = dict[@"body"][@"timeAll"];
  142. self.cultivateInfo.nextDate = dict[@"body"][@"nextDate"];
  143. [self setCultivateInfoModel:self.cultivateInfo];
  144. NSArray<CultivatePhotoModel*> *photo_array = [CultivatePhotoModel modelArrayWithJSON:dict[@"body"][@"photos"]];
  145. [self.photosArray addObjectsFromArray:photo_array];
  146. [self.collectionView reloadData];
  147. NSLog(@"gotoType====%d",weakSelf.gotoType);
  148. if(weakSelf.gotoType!=1){//非签退状态-进行判断是否存在签退照片
  149. //判断遇见有签退-照片 - 直接签退
  150. NSPredicate *predicate = [NSPredicate predicateWithFormat:@"event=%d",18];
  151. NSArray *filterdArray = [photo_array filteredArrayUsingPredicate:predicate];
  152. if(filterdArray.count>0){
  153. [weakSelf gotoSignOutdo:weakSelf.cultivateInfo.qrcodeData];//签退
  154. return;
  155. }
  156. }
  157. }];
  158. }
  159. //过程照片
  160. - (IBAction)submit_clickdo:(UIButton *)sender {
  161. self.gotoType = 0;
  162. self.submit_btn.userInteractionEnabled = NO;
  163. //定位功能
  164. __weak typeof(self) weakSelf = self;
  165. [MBProgressHUD rq_showProgressHUD:@"正在获取当前位置..."];
  166. [[MapManager sharedManager] updateLocationWithCompleteBlock:^(BOOL success, CLLocation * _Nonnull location, BMKLocation * _Nullable bmkLocation) {
  167. [MBProgressHUD rq_hideHUD];
  168. if (success) {
  169. _myLocation = location.coordinate;
  170. NSString *photoType = @"19";
  171. if(weakSelf.photosArray.count==0){//如果没有签到记录
  172. photoType = @"17";//17签到照片18签退照片19过程照片
  173. }
  174. [weakSelf photoCoursedo:photoType];
  175. }else{
  176. ShowMsg(@"定位失败!请重新定位!");
  177. }
  178. }];
  179. }
  180. //拍照过程
  181. - (void)photoCoursedo:(NSString *)photoType{
  182. if(_myLocation.latitude<=0){
  183. ShowMsg(@"定位失败!请重新定位!");
  184. return;
  185. }
  186. self.viewModel.photoType = photoType;
  187. CultivateInfoModel *cultInfoModel = self.viewModel.cultivateInfoModel;
  188. // roomLat roomLng maxDistance
  189. //NSString *title = [NSString stringWithFormat:@"您距离课堂超过了%@m",cultInfoModel.maxDistance];
  190. //计算距离
  191. double this_distance = 0.0;
  192. double lat1 = cultInfoModel.roomLat.doubleValue;
  193. double lng1 = cultInfoModel.roomLng.doubleValue;
  194. // 26.122397, 119.251203
  195. if(_myLocation.latitude >0){
  196. double lat2 = _myLocation.latitude;//[[NSString stringWithFormat:@"%.6f",] doubleValue];
  197. double lng2 = _myLocation.longitude;//[[NSString stringWithFormat:@"%.6f",] doubleValue];
  198. this_distance = [MapManager getDistance:lat1 lng1:lng1 lat2:lat2 lng2:lng2]; // [self distanceBetweenOrderBy:lat1 :lat2 :lng1 :lng2];
  199. }
  200. if(this_distance>cultInfoModel.maxDistance.doubleValue){//超出范围
  201. if(cultInfoModel.isDistance){//是否强制 判断-范围
  202. [RQ_SHARE_FUNCTION showAlertWithTitle:@"提示" message:@"当前位置超出理论教室规定最大距离, 不能继续拍照" alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"取消" otherButtonTitles:@[@"确定"] otherButtonStyles:nil showInWindow:NO completion:^(NSUInteger selectedOtherButtonIndex) {
  203. if (selectedOtherButtonIndex == 0) {
  204. }
  205. }];
  206. }else{
  207. //友好提示一下
  208. [RQ_SHARE_FUNCTION showAlertWithTitle:@"提示" message:@"当前位置已超出理论教室规定最大距离, 是否继续拍照?" alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"取消" otherButtonTitles:@[@"确定"] otherButtonStyles:nil showInWindow:NO completion:^(NSUInteger selectedOtherButtonIndex) {
  209. if (selectedOtherButtonIndex == 0) {
  210. [self beginCheckBodyHumanface];
  211. }
  212. }];
  213. }
  214. }else{//未超出范围
  215. //直接-进入人脸-签到流程
  216. [self beginCheckBodyHumanface];
  217. }
  218. }
  219. //人脸比对流程
  220. -(void)beginCheckBodyHumanface{
  221. @weakify(self)
  222. /// 1.本地活体检测
  223. [RQ_CHECKBODY_MANAGER beginCheckBodyWithCheckNum:RQ_USER_MANAGER.ycbdFaceCount completeBlock:^(BOOL success, NSDictionary * _Nullable dic) {
  224. if (success) {
  225. NSString *type = self.viewModel.classType;
  226. //上传-课堂照片
  227. __block NSMutableArray *arr = [NSMutableArray array];
  228. NSData *imageData = [[NSData alloc] initWithBase64EncodedString:dic[@"normalImg"] options:NSDataBase64DecodingIgnoreUnknownCharacters];
  229. NSString *method = [NSString stringWithFormat:@"education/imageup/%@/%@/%@/nocar",RQ_USER_MANAGER.currentUser.city,type,RQ_USER_MANAGER.currentUser.outId];
  230. [jiaPeiManager requestAnythingImageWithURL:method array:arr data:imageData completion:^(NSDictionary *dict) {
  231. NSLog(@"%@",dict);
  232. int code = [dict[@"code"] intValue];
  233. if(code == 0 ){
  234. NSString *paths = dict[@"data"][@"paths"];
  235. NSString *photoid = dict[@"data"][@"id"];
  236. /// 2.线上活体检测
  237. [self stunocarfaceTofacedo:photoid];
  238. }else{
  239. self.submit_btn.userInteractionEnabled = YES;
  240. if (!RQObjectIsNil(dict[@"msg"])&&![dict[@"msg"] isEqualToString:@""]) {
  241. ShowMsg(dict[@"msg"]);
  242. return;
  243. }
  244. if (!RQObjectIsNil(dict[@"body"])&&![dict[@"body"] isEqualToString:@""]) {
  245. ShowMsg(dict[@"body"]);
  246. return;
  247. }
  248. }
  249. }];
  250. }else{
  251. ShowMsg(@"活体检测失败");
  252. }
  253. }];
  254. }
  255. // 人脸线上比对
  256. -(void)stunocarfaceTofacedo:(NSString *)photoid {
  257. NSMutableArray *arr = [NSMutableArray array];
  258. [arr property:RQ_USER_MANAGER.currentUser.outId forKey:@"stuId"];
  259. [arr property:RQ_USER_MANAGER.currentUser.city forKey:@"dqbh"];
  260. [arr property:photoid forKey:@"photo"];
  261. NSString* method = @"stunocarfaceToface";
  262. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * dict) {
  263. if ([dict[@"code"] intValue] == 0)
  264. {
  265. [self updateStunocarPhoto:photoid];
  266. }
  267. else
  268. {
  269. self.submit_btn.userInteractionEnabled = YES;
  270. if (!RQObjectIsNil(dict[@"msg"])&&![dict[@"msg"] isEqualToString:@""]) {
  271. ShowMsg(dict[@"msg"]);
  272. return;
  273. }
  274. if (!RQObjectIsNil(dict[@"body"])&&![dict[@"body"] isEqualToString:@""]) {
  275. ShowMsg(dict[@"body"]);
  276. return;
  277. }
  278. }
  279. }];
  280. }
  281. // 过程上传
  282. -(void)updateStunocarPhoto:(NSString *)photoid{
  283. NSString *classIdStr = self.viewModel.classIdStr;
  284. NSString *type = self.viewModel.classType;
  285. NSString *photoType = self.viewModel.photoType;
  286. NSString *lat = [NSString stringWithFormat:@"%.6f",_myLocation.latitude];
  287. NSString *lng = [NSString stringWithFormat:@"%.6f",_myLocation.longitude];
  288. NSMutableArray *arr = [NSMutableArray array];
  289. [arr property:RQ_USER_MANAGER.currentUser.outId forKey:@"stuId"];
  290. [arr property:type forKey:@"type"];//1课堂 2模拟
  291. [arr property:RQ_USER_MANAGER.currentUser.city forKey:@"dqbh"];
  292. [arr property:classIdStr forKey:@"classid"];
  293. [arr property:photoid forKey:@"photo"];
  294. [arr property:lng forKey:@"lng"];
  295. [arr property:lat forKey:@"lat"];
  296. [arr property:photoType forKey:@"photoType"];//17签到照片18签退照片19过程照片
  297. NSString* method = @"updateStunocarPhoto";
  298. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * dict) {
  299. self.submit_btn.userInteractionEnabled = YES;
  300. if ([dict[@"code"] intValue] == 0) {
  301. ShowMsg(@"上传照片成功!");
  302. if(self.gotoType==1&&[photoType isEqualToString:@"18"]){//签退
  303. if(self.cultivateInfo.isQrcodeQt){
  304. [self gotoSignOutdo:self.qrcodeData];//签退
  305. }else{
  306. [self gotoSignOutdo:self.cultivateInfo.qrcodeData];//签退
  307. }
  308. }else{
  309. [self getClassRoomInfo];
  310. }
  311. }
  312. else
  313. {
  314. if (!RQObjectIsNil(dict[@"msg"])&&![dict[@"msg"] isEqualToString:@""]) {
  315. ShowMsg(dict[@"msg"]);
  316. return;
  317. }
  318. if (!RQObjectIsNil(dict[@"body"])&&![dict[@"body"] isEqualToString:@""]) {
  319. ShowMsg(dict[@"body"]);
  320. return;
  321. }
  322. }
  323. }];
  324. }
  325. // 签到 签退
  326. - (void)gotoSignInOrsignOut{
  327. self.gotoType = 0;
  328. if(self.cultivateInfo){//已经有课堂-签退
  329. self.gotoType = 1;
  330. //定位功能
  331. __weak typeof(self) weakSelf = self;
  332. [MBProgressHUD rq_showProgressHUD:@"正在获取当前位置..."];
  333. [[MapManager sharedManager] updateLocationWithCompleteBlock:^(BOOL success, CLLocation * _Nonnull location, BMKLocation * _Nullable bmkLocation) {
  334. [MBProgressHUD rq_hideHUD];
  335. if (success) {
  336. _myLocation = location.coordinate;
  337. //先扫二维码
  338. if(weakSelf.gotoType==1){//签退
  339. if(weakSelf.cultivateInfo.isQrcodeQt){
  340. [weakSelf QRCodeScanningdo];
  341. }else{
  342. //签退-距离提示
  343. [weakSelf photoCoursedo:@"18"];
  344. }
  345. }
  346. }
  347. }];
  348. return;
  349. }
  350. [self createClassIdStr];
  351. //弹出选择
  352. if(self.viewModel.isSimulationRoom){
  353. __weak typeof(self) weakSelf = self;
  354. UIAlertController *alertFind = [UIAlertController alertControllerWithTitle:nil message:@"请选择训练科目" preferredStyle:UIAlertControllerStyleAlert];
  355. [alertFind addAction:[UIAlertAction actionWithTitle:@"科二" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
  356. weakSelf.viewModel.pxkm = @"2";
  357. [weakSelf QRCodeScanningdo];
  358. }]];
  359. [alertFind addAction:[UIAlertAction actionWithTitle:@"科三" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
  360. weakSelf.viewModel.pxkm = @"3";
  361. [weakSelf QRCodeScanningdo];
  362. }]];
  363. [[RQ_SHARE_FUNCTION topViewController] presentViewController:alertFind animated:true completion:nil];
  364. }
  365. }
  366. //扫码
  367. - (void)QRCodeScanningdo{
  368. __weak typeof(self) weakSelf = self;
  369. // 检查是否正在扫描,如果是,则直接返回
  370. if (self.isScanning) {
  371. return;
  372. }
  373. NSLog(@"点击了 扫码");
  374. // 设置扫描状态为正在进行
  375. self.isScanning = YES;
  376. RQQRCodeViewController *vc = [[RQQRCodeViewController alloc] init];
  377. vc.modalPresentationStyle = UIModalPresentationFullScreen;
  378. [vc initBlock:^(NSString * _Nonnull result, BOOL isSuccess) {
  379. if (isSuccess) {
  380. NSLog(@"二维码扫码成功");
  381. if(weakSelf.gotoType==1){
  382. weakSelf.qrcodeData = result;
  383. weakSelf.isScanning = NO;
  384. //签退-距离提示
  385. [weakSelf photoCoursedo:@"18"];
  386. }else{
  387. [weakSelf gotoSignIndo:result];//签到
  388. }
  389. } else {
  390. weakSelf.isScanning = NO;
  391. }
  392. }];
  393. [[RQ_SHARE_FUNCTION topViewController] presentViewController:vc
  394. animated:YES
  395. completion:nil];
  396. }
  397. //签到
  398. - (void)gotoSignIndo:(NSString *)qrcodeData {
  399. NSLog(@"调用签到--gotoSignIndogotoSignIndogotoSignIndo==========");
  400. self.viewModel.photoType = @"17";
  401. NSString *classIdStr = self.viewModel.classIdStr;
  402. NSString *type = self.viewModel.classType;
  403. NSString *pxkm = self.viewModel.pxkm;
  404. NSMutableArray *arr = [NSMutableArray array];
  405. [arr property:RQ_USER_MANAGER.currentUser.outId forKey:@"stuId"];
  406. [arr property:RQ_USER_MANAGER.currentUser.city forKey:@"dqbh"];
  407. [arr property:type forKey:@"type"];//培训类型 2模拟
  408. [arr property:classIdStr forKey:@"classid"];//课堂ID
  409. [arr property:qrcodeData forKey:@"qrcodeData"];//二维码数据
  410. [arr property:pxkm forKey:@"subject"];//模拟: 2科目二 3科目三
  411. NSString* method = @"uploadStunocarSignIn";
  412. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * dict) {
  413. self.isScanning = NO;
  414. if ([dict[@"code"] intValue] == 0)
  415. {
  416. //签到成功
  417. //直接-进入人脸-签到流程
  418. [self beginCheckBodyHumanface];
  419. }
  420. else
  421. {
  422. [self getClassRoomInfo];//刷新一次
  423. if (!RQObjectIsNil(dict[@"msg"])&&![dict[@"msg"] isEqualToString:@""]) {
  424. ShowMsg(dict[@"msg"]);
  425. return;
  426. }
  427. if (!RQObjectIsNil(dict[@"body"])&&![dict[@"body"] isEqualToString:@""]) {
  428. ShowMsg(dict[@"body"]);
  429. return;
  430. }
  431. }
  432. }];
  433. }
  434. //签退
  435. - (void)gotoSignOutdo:(NSString *)qrcodeData {
  436. NSLog(@"调用签退--gotoSignOutdogotoSignOutdogotoSignOutdogotoSignOutdogotoSignOutdo==========");
  437. __weak typeof(self) weakSelf = self;
  438. NSString *classIdStr = self.viewModel.classIdStr;
  439. NSString *type = self.viewModel.classType;
  440. NSMutableArray *arr = [NSMutableArray array];
  441. [arr property:RQ_USER_MANAGER.currentUser.outId forKey:@"stuId"];
  442. [arr property:RQ_USER_MANAGER.currentUser.city forKey:@"dqbh"];
  443. [arr property:type forKey:@"type"];//培训类型 2模拟
  444. [arr property:classIdStr forKey:@"classid"];//课堂ID
  445. [arr property:qrcodeData forKey:@"qrcodeData"];//二维码数据
  446. NSString* method = @"uploadStunocarSignOut";
  447. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * dict) {
  448. weakSelf.isScanning = NO;
  449. if ([dict[@"code"] intValue] == 0)
  450. {
  451. //签退成功-获取课堂
  452. // [NYTools delateClassIdStr:RQ_USER_MANAGER.currentUser.outId];
  453. ShowMsg(@"签退成功");
  454. [weakSelf getClassRoomInfo];
  455. }
  456. else
  457. {
  458. if (!RQObjectIsNil(dict[@"msg"])&&![dict[@"msg"] isEqualToString:@""]) {
  459. ShowMsg(dict[@"msg"]);
  460. return;
  461. }
  462. if (!RQObjectIsNil(dict[@"body"])&&![dict[@"body"] isEqualToString:@""]) {
  463. ShowMsg(dict[@"body"]);
  464. return;
  465. }
  466. }
  467. }];
  468. }
  469. -(double)distanceBetweenOrderBy:(double) latitude1 :(double) latitude2 :(double) longitude1 :(double) longitude2{
  470. CLLocation *curLocation = [[CLLocation alloc] initWithLatitude:latitude1 longitude:longitude1];
  471. CLLocation *otherLocation = [[CLLocation alloc] initWithLatitude:latitude2 longitude:longitude2];
  472. // 计算两个坐标之间的距离
  473. //CLLocationDistance distance = [curLocation distanceFromLocation:otherLocation];
  474. double distance = [curLocation distanceFromLocation:otherLocation];
  475. return distance;
  476. }
  477. -(UICollectionView *)collectionView{
  478. if (!_collectionView) {
  479. UICollectionViewFlowLayout *flowLayOut = [[UICollectionViewFlowLayout alloc] init];
  480. flowLayOut.itemSize = CGSizeMake(80, 150);
  481. flowLayOut.sectionInset = UIEdgeInsetsMake(5, 5, 5, 5);
  482. flowLayOut.scrollDirection = UICollectionViewScrollDirectionHorizontal;
  483. self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:flowLayOut];
  484. self.collectionView.showsHorizontalScrollIndicator = NO;
  485. self.collectionView.delegate = self;
  486. self.collectionView.dataSource = self;
  487. // self.collectionView.scrollEnabled = NO;
  488. }
  489. return _collectionView;
  490. }
  491. - (NSMutableArray *)photosArray{
  492. if (!_photosArray) {
  493. self.photosArray = [NSMutableArray array];
  494. }
  495. return _photosArray;
  496. }
  497. #pragma mark - SystemMethods
  498. - (void)awakeFromNib {
  499. [super awakeFromNib];
  500. self.contentView.backgroundColor = UIColor.clearColor;
  501. _px00_view.layer.shadowColor = RGBA_COLOR(124, 129, 136, 0.2).CGColor;
  502. _px01_view.layer.shadowColor = RGBA_COLOR(124, 129, 136, 0.2).CGColor;
  503. }
  504. - (void)checkLocalPhoto{
  505. int currentIndex = _index;
  506. NSMutableArray *images = [NSMutableArray array];
  507. for (CultivatePhotoModel *photoModel in self.photosArray) {
  508. [images addObject:photoModel.filepath];
  509. }
  510. [RQ_SHARE_FUNCTION showPhotoBrowserWithDataSource:images currentIndex:currentIndex isCanSave:NO];
  511. }
  512. #pragma mark UICollectionViewDelegate
  513. - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
  514. _index = indexPath.row;
  515. [self checkLocalPhoto];
  516. }
  517. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
  518. return _photosArray.count;
  519. }
  520. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
  521. NYClassRoomPeiPhotoCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
  522. CultivatePhotoModel *photoModel = self.photosArray[indexPath.row];
  523. cell.cultivatePhotoModel = photoModel;
  524. return cell;
  525. }
  526. @end