NYClassRoomPeiCell.m 23 KB

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