NYClassRoomPeiCell.m 23 KB

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