TimingBaseVC.m 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523
  1. //
  2. // TimingBaseVC.m
  3. // jiaPei
  4. //
  5. // Created by EchoShacolee on 2017/3/20.
  6. // Copyright © 2017年 JCZ. All rights reserved.
  7. //
  8. #import "TimingBaseVC.h"
  9. #import "AdvertisingColumn.h"
  10. #import "ThirdLoginBindYunGuanVC.h"
  11. #import "PeriodVC.h"//理论计时
  12. #import "ImitatePeriodVC.h"//模拟计时
  13. #import "TrainInfoVC.h"//我的学时
  14. #import "ShiCaoPeriodVC.h"//实操计时
  15. #import "ScanVC.h"
  16. #import "RQCollectionSectionModel.h"
  17. #import "TimingCommonCell.h"
  18. #import "RQCustomWebViewViewController.h"
  19. #import "RQCycleScrollView.h"
  20. @interface TimingBaseVC () <UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout>
  21. {
  22. PeriodVC *KVOPeriodVC;
  23. ShiCaoPeriodVC *KVOSCPeriodVC;
  24. NSString *orderId; // 订单ID
  25. NSString *classCode; // 课程编码
  26. NSString *subject; // 科目
  27. NSString *coachOrderId; // 教练订单ID
  28. NSDictionary *coachQRCodeDic;
  29. }
  30. @property (nonatomic, readonly, strong) RQTimeViewModel *viewModel;
  31. @property (nonatomic, readwrite, strong) UICollectionView *collectionView;
  32. @property (nonatomic, readwrite, strong) UICollectionViewFlowLayout *collectionViewFlowLayout;
  33. @property (nonatomic, readwrite, copy) NSArray *collectionDataArr;
  34. @property (nonatomic, readwrite, copy) NSDictionary *sourceDataDic;
  35. @property (nonatomic, readwrite, copy) NSString *noteStr;
  36. @property (nonatomic, readwrite, strong) RQCycleScrollView *cycleScrollView;
  37. @end
  38. @implementation TimingBaseVC
  39. @dynamic viewModel;
  40. #pragma mark - Public Methods
  41. - (void)viewDidLoad {
  42. [super viewDidLoad];
  43. [self.view setBackgroundColor:backGroundColor];
  44. self.navigationController.navigationBar.translucent = NO;
  45. self.navigationItem.title = @"学车计时";
  46. [self myInit];
  47. }
  48. #pragma mark - UICollectionViewDatasource
  49. - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
  50. return self.collectionDataArr.count;
  51. }
  52. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
  53. return ((RQCollectionSectionModel *)self.collectionDataArr[section]).sectionDataArr.count;
  54. }
  55. - (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
  56. TimingCommonCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"TimingCommonCell" forIndexPath:indexPath];
  57. RQCollectionSectionModel *collectionSectionModel = self.collectionDataArr[indexPath.section];
  58. cell.collectionItemModel = collectionSectionModel.sectionDataArr[indexPath.row];
  59. return cell;
  60. }
  61. - (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath {
  62. if ([kind isEqualToString:UICollectionElementKindSectionHeader]) {
  63. UICollectionReusableView *headerView = [collectionView dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:@"UICollectionViewHeader" forIndexPath:indexPath];
  64. headerView.backgroundColor = backGroundColor;
  65. AdvertisingColumn *adView = [[AdvertisingColumn alloc]initWithFrame:CGRectMake(0, 0, headerView.width, headerView.height)];
  66. //广告
  67. NSMutableArray *newAD = [NSMutableArray array];
  68. for (NSDictionary *dic in myDelegate.adArray) {
  69. if ([dic[@"LOCATION"] isEqualToString:@"3"]) {
  70. [newAD addObject:dic];
  71. }
  72. }
  73. [adView setImgArray:newAD];
  74. adView.supVC = self;
  75. self.cycleScrollView = [[RQCycleScrollView alloc] initWithFrame:CGRectMake(16, 8, RQ_SCREEN_WIDTH - 32.f, (RQ_SCREEN_WIDTH - 32.f) * (150 / 600.f)) dataArr:newAD];
  76. self.cycleScrollView.layer.cornerRadius = 10.f;
  77. self.cycleScrollView.layer.masksToBounds = 10.f;
  78. [headerView addSubview:self.cycleScrollView];
  79. return headerView;;
  80. } else if ([kind isEqualToString:UICollectionElementKindSectionFooter]) {
  81. UICollectionReusableView *footerView = [collectionView dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:@"UICollectionViewFooter" forIndexPath:indexPath];
  82. footerView.backgroundColor = backGroundColor;
  83. UILabel *noteLabel = [[UILabel alloc] initWithFrame:CGRectMake(16, 0, footerView.width - 32, footerView.height)];
  84. noteLabel.backgroundColor = backGroundColor;
  85. noteLabel.textColor = RQ_MAIN_COLOR;
  86. noteLabel.numberOfLines = 0;
  87. noteLabel.font = [UIFont systemFontOfSize:NormalFont];
  88. noteLabel.text = self.noteStr;
  89. [footerView addSubview:noteLabel];
  90. return footerView;;
  91. }
  92. return nil;
  93. }
  94. #pragma mark - UICollectionViewDelegateFlowLayout
  95. - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
  96. return CGSizeMake((RQ_SCREEN_WIDTH - 2 - 32) / 2.f, ((RQ_SCREEN_WIDTH - 2 - 32) / 2.f) * 0.8);
  97. }
  98. - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section {
  99. return CGSizeMake(RQ_SCREEN_WIDTH, (RQ_SCREEN_WIDTH - 32.f) * (150 / 600.f) + 16.f);
  100. }
  101. - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section {
  102. return CGSizeMake(RQ_SCREEN_WIDTH, [self.noteStr heightForWid:RQ_SCREEN_WIDTH Font:NormalFont] - 64);
  103. }
  104. #pragma mark - UICollectionViewDelegate
  105. - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
  106. [collectionView deselectItemAtIndexPath:indexPath animated:YES];
  107. RQCollectionSectionModel *collectionSectionModel = self.collectionDataArr[indexPath.section];
  108. RQCollectionItemModel *collectionItemModel = collectionSectionModel.sectionDataArr[indexPath.row];
  109. NSString *itemTitle = collectionItemModel.itemTitle;
  110. if ([itemTitle isEqualToString:@"理论计时"]) {
  111. [self theoryTimingAction];
  112. }else if ([itemTitle isEqualToString:@"实操计时"]) {
  113. [self tureTimingAction];
  114. }else if ([itemTitle isEqualToString:@"模拟计时"]) {
  115. [self simulationTimingAction];
  116. }else if ([itemTitle isEqualToString:@"我的学时"]) {
  117. [self myTrainInfoAction];
  118. }else {
  119. }
  120. }
  121. #pragma mark - PrivateMethods
  122. - (void)myInit {
  123. [self.view addSubview:self.collectionView];
  124. [RACObserve(RQ_USER_MANAGER, currentUser) subscribeNext:^(id _Nullable x) {
  125. NSLog(@"%@",x);
  126. [self.collectionView reloadData];
  127. }];
  128. }
  129. // 理论计时
  130. - (void)theoryTimingAction {
  131. @weakify(self)
  132. if (RQ_USER_MANAGER.currentUser.outId && [RQ_USER_MANAGER.currentUser.outId length] > 0) {
  133. [RQ_VIP_Module isActiveWithCcomplete:^(RQActivationModel * _Nullable activationModel, BOOL isSuccess) {
  134. @strongify(self)
  135. if (isSuccess) {
  136. if (activationModel.isShare) {
  137. if (activationModel.isActive == 1) {
  138. [self gotoPeriod];
  139. } else {
  140. [RQ_VIP_Module gotoVipViewWithDictType:RQ_USER_MANAGER.currentUser.city];
  141. }
  142. } else {
  143. [self gotoPeriod];
  144. }
  145. }
  146. }];
  147. }else {
  148. [self judgeLoginType];
  149. }
  150. }
  151. - (void)gotoPeriod {
  152. PeriodVC *vc = nil;
  153. if (myDelegate.tPeriodVC) {
  154. vc = myDelegate.tPeriodVC;
  155. }else {
  156. KVOPeriodVC = [[PeriodVC alloc] init];
  157. vc = KVOPeriodVC;
  158. }
  159. [self navPushHideTabbarToVC:vc];
  160. }
  161. // 实操计时
  162. - (void)tureTimingAction {
  163. @weakify(self)
  164. if (RQ_USER_MANAGER.currentUser.outId && [RQ_USER_MANAGER.currentUser.outId length] > 0) {
  165. [RQ_VIP_Module isActiveWithCcomplete:^(RQActivationModel * _Nullable activationModel, BOOL isSuccess) {
  166. @strongify(self)
  167. if (isSuccess) {
  168. if (activationModel.isShare) {
  169. if (activationModel.isActive == 1) {
  170. [self gotoTimi];
  171. } else {
  172. [RQ_VIP_Module gotoVipViewWithDictType:RQ_USER_MANAGER.currentUser.city];
  173. }
  174. } else {
  175. [self gotoTimi];
  176. }
  177. }
  178. }];
  179. }else {
  180. [self judgeLoginType];
  181. }
  182. }
  183. - (void)gotoTimi {
  184. SCLAlertView *alert = [[SCLAlertView alloc] initWithNewWindowWidth:RQ_SCREEN_WIDTH - 32];
  185. alert.backgroundViewColor = backGroundColor;
  186. alert.customViewColor = RQ_MAIN_COLOR;
  187. UITextView *view = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, RQ_SCREEN_WIDTH - 64, RQ_SCREEN_HEIGHT * 0.5)];
  188. view.font = [UIFont systemFontOfSize:15];
  189. NSMutableString *content = [NSMutableString string];
  190. content.string = @"请注意:\n\n 本系统是按照2016驾驶员培训新国标要求,严格照规范设计,终端上传分钟学时来计算,在计时过程中请注意以下几点: \n\n1、如果所在地市有开启围栏,请注意确保您当前的位置在规定的围栏内训练,否则分钟学时无效 \n\n2、如果所在地市有开启培训时段,请确保您当前训练时间符合规定,比如早上6:00-20:00 \n\n3、确保教练手机是正常联网且安装支持3G以上的移动,联通和电信的SIM,否则无法采集到手机终端的位置,系统会判定分钟学时无效 \n\n4、系统为防止特殊情况,教练带教过程接到电话,允许断网一段时间,默认15分钟,如果超过15分钟,所带教学员的分钟学时无效 \n\n5、学员和教练的有效距离不能超过规定距离,否则分钟学时无效,详情请咨询教练或您所在的驾校 \n\n6、系统默认在2分钟及以上时间段内,如果移动距离为0米,视为无效分钟学时 \n\n7、根据规定,学员科目二和科目三1分钟内移动距离不能低于规定的数值,否则分钟学时无效,具体询问驾校或教练 \n\n8、如果您选择计时收费训练,您可以在训练结束且支付完成后对教练进行评价和投诉,如果训练完成后不支付,您的学时将无效且无法进行下一次训练 \n\n 为了保证您的合法利益,请遵守规定,同时也请提醒您的教练,手机不能断网或在带教过程中长时间接听电话,否则会影响您的学时有效性判断,导致学时无效";
  191. view.text = content.mutableCopy;
  192. view.backgroundColor = backGroundColor;
  193. CGFloat textHeight = [view.text heightForWid:view.width Font:15];
  194. view.height = (textHeight > RQ_SCREEN_HEIGHT/2)? RQ_SCREEN_HEIGHT/2 : textHeight;
  195. [alert addCustomView:view];
  196. [alert addButton:@"不再显示" actionBlock:^(void) {
  197. [[NSUserDefaults standardUserDefaults] setValue:@"doNotShowNotice" forKey:@"isShowNotice"];
  198. [self gotoScanVCAction];
  199. }];
  200. [alert addButton:@"同意" actionBlock:^(void) {
  201. [self gotoScanVCAction];
  202. }];
  203. if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"isShowNotice"] isKindOfClass:[NSString class]] && [[[NSUserDefaults standardUserDefaults] objectForKey:@"isShowNotice"] isEqualToString:@"doNotShowNotice"]) {
  204. [self gotoScanVCAction];
  205. }else {
  206. [alert showInfo:self title:@"" subTitle:@"" closeButtonTitle:@"不同意" duration:0.0f];
  207. }
  208. /// RQ-MARK:计时修改
  209. // //判断是否绑定 如果绑定了 直接跳转 如果没有 跳转到绑定页面
  210. // if ([RQ_USER_MANAGER.currentUser.imei length] > 0) {
  211. //
  212. // if (![RQ_USER_MANAGER.currentUser.imei isEqualToString:[Tools getIDFV]]) {
  213. // ShowMsg(@"账号与绑定手机不匹配,请用本人手机计时");
  214. // [Tools playAudioWithString:@"账号与绑定手机不匹配,请用本人手机计时"];
  215. // [self.navigationController popViewControllerAnimated:YES];
  216. // }else{
  217. // //绑定且成功匹配
  218. // ShiCaoPeriodVC *vc = nil;
  219. // if (myDelegate.scPeriodVC) {
  220. // vc = myDelegate.scPeriodVC;
  221. // }else{
  222. // KVOSCPeriodVC = [[ShiCaoPeriodVC alloc] init];
  223. // vc = KVOSCPeriodVC;
  224. // //NSLog(@"创建kvo");
  225. // }
  226. // [self navPushHideTabbarToVC:vc];
  227. // }
  228. // }else{
  229. // [RQ_SHARE_FUNCTION showAlertWithTitle:@"温馨提示" message:@"您的账号暂未绑定手机,不能进行此操作,可以在“我的-绑定申请”中申请绑定" alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"确定" otherButtonTitles:nil otherButtonStyles:nil showInWindow:NO completion:nil];
  230. // }
  231. // }else{
  232. // [self judgeLoginType];
  233. }
  234. // 模拟计时
  235. - (void)simulationTimingAction {
  236. @weakify(self)
  237. if(RQ_USER_MANAGER.currentUser.outId && [RQ_USER_MANAGER.currentUser.outId length] > 0){
  238. [RQ_VIP_Module isActiveWithCcomplete:^(RQActivationModel * _Nullable activationModel, BOOL isSuccess) {
  239. @strongify(self)
  240. if (isSuccess) {
  241. if (activationModel.isShare) {
  242. if (activationModel.isActive == 1) {
  243. ImitatePeriodVC *imitVC = [[ImitatePeriodVC alloc] init];
  244. [self navPushHideTabbarToVC:imitVC];
  245. } else {
  246. [RQ_VIP_Module gotoVipViewWithDictType:RQ_USER_MANAGER.currentUser.city];
  247. }
  248. } else {
  249. ImitatePeriodVC *imitVC = [[ImitatePeriodVC alloc] init];
  250. [self navPushHideTabbarToVC:imitVC];
  251. }
  252. }
  253. }];
  254. }else {
  255. [self judgeLoginType];
  256. }
  257. }
  258. // 我的学时
  259. - (void)myTrainInfoAction {
  260. @weakify(self)
  261. if(RQ_USER_MANAGER.currentUser.outId && [RQ_USER_MANAGER.currentUser.outId length] > 0){
  262. [RQ_VIP_Module isActiveWithCcomplete:^(RQActivationModel * _Nullable activationModel, BOOL isSuccess) {
  263. @strongify(self)
  264. if (isSuccess) {
  265. if (activationModel.isShare) {
  266. if (activationModel.isActive == 1) {
  267. [self gotoTrainInfo];
  268. } else {
  269. [RQ_VIP_Module gotoVipViewWithDictType:RQ_USER_MANAGER.currentUser.city];
  270. }
  271. } else {
  272. [self gotoTrainInfo];
  273. }
  274. }
  275. }];
  276. }else{
  277. [self judgeLoginType];
  278. }
  279. }
  280. - (void)gotoTrainInfo {
  281. if (RQ_USER_MANAGER.isycbd == 1 && RQ_USER_MANAGER.ycbdFaceCount == 0) {
  282. NSURL *URL = [NSURL URLWithString:[NSString stringWithFormat:@"http://fj.jppt.com.cn/jsjp/wechat/toClassHourQueryByStuId.html?stuId=%@&dqbh=%@&app=ios",RQ_USER_MANAGER.currentUser.outId, RQ_USER_MANAGER.currentUser.city]];
  283. RQCustomWebViewViewController *vc = [[RQCustomWebViewViewController alloc] init];
  284. vc.url = URL.absoluteString;
  285. vc.webView.scrollView.bounces = NO;
  286. RQBaseNavigationController *nav = [[RQBaseNavigationController alloc] initWithRootViewController:vc];
  287. [RQControllerHelper.topViewController presentViewController:nav animated:YES completion:nil];
  288. } else {
  289. TrainInfoVC * tvc = [[TrainInfoVC alloc]init];
  290. [self navPushHideTabbarToVC:tvc];
  291. }
  292. }
  293. // 跳转至扫码页面
  294. - (void)gotoScanVCAction {
  295. ScanVC *scan = [[ScanVC alloc] init];
  296. scan.type = 1;
  297. scan.homeVC = self;
  298. [scan scanBlock:^(NSDictionary *scanQRCodeResultDic) {
  299. coachQRCodeDic = scanQRCodeResultDic;
  300. if ([scanQRCodeResultDic[@"scanType"] isEqualToString:@"allSignOut"]) {
  301. [self updateReserveEnd];
  302. }else if ([scanQRCodeResultDic[@"scanType"] isEqualToString:@"jhPeriod"]) {
  303. [self uploadReserveOrder];
  304. }
  305. }];
  306. [self navPushHideTabbarToVC:scan];
  307. }
  308. - (void)judgeLoginType {
  309. NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
  310. NSDictionary *udDic = [ud objectForKey:@"jiaPeiLoginTest"];
  311. if ([udDic[@"loginType"] isEqualToString:@"1"]){
  312. //身份证登录 说明不需要在这里计时
  313. ShowMsg(@"您的账号暂未在运管系统受理,无法计时!");
  314. }else {
  315. [RQ_SHARE_FUNCTION showAlertWithTitle:nil message:@"您的账号还未绑定运管系统账号" alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"取消" otherButtonTitles:@[@"绑定"] otherButtonStyles:nil showInWindow:NO completion:^(NSUInteger selectedOtherButtonIndex) {
  316. if (selectedOtherButtonIndex == 0) {
  317. //第三方登录 提示到绑定运管账号页面
  318. ThirdLoginBindYunGuanVC *vc = [[ThirdLoginBindYunGuanVC alloc] init];
  319. [self navPushHideTabbarToVC:vc];
  320. }
  321. }];
  322. }
  323. }
  324. #pragma mark - Net Methodds
  325. //生成订单
  326. - (void)uploadReserveOrder {
  327. [LoadingView showHUD];
  328. if (![Util connectedToNetWork]) {
  329. showMsgUnconnect();
  330. return;
  331. }
  332. NSMutableArray *arr=[NSMutableArray array];
  333. [arr addPro:@"reserveId" Value:[coachQRCodeDic[@"dataString"] componentsSeparatedByString:@";"][3]];
  334. [arr addPro:@"userId" Value:RQ_USER_MANAGER.currentUser._id];
  335. [arr addPro:@"dqbh" Value:RQ_USER_MANAGER.currentUser.city];
  336. [arr addPro:@"coachId" Value:[coachQRCodeDic[@"dataString"] componentsSeparatedByString:@";"].lastObject];
  337. [arr addPro:@"sim" Value:RQ_USER_MANAGER.currentUser.telphone];
  338. [arr addPro:@"stuOutId" Value:RQ_USER_MANAGER.currentUser.outId];
  339. [arr addPro:@"coachOutId" Value:[coachQRCodeDic[@"dataString"] componentsSeparatedByString:@";"][0]];
  340. NSString* method = @"uploadReserveOrder";
  341. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
  342. RemoveHUD();
  343. if (!root) {
  344. ShowMsg(@"开始计时失败,请重试!");
  345. [Tools playAudioWithString:@"开始计时失败,请崇试!"];
  346. return;
  347. }
  348. if ([root[@"code"] isEqualToString:@"1"]) {
  349. ShowMsg(root[@"body"]);
  350. [Tools playAudioWithString:root[@"body"]];
  351. return;
  352. }
  353. orderId = [root[@"body"] objectForKey:@"id"];
  354. subject = [root[@"body"] objectForKey:@"subject"];
  355. ShowMsg(@"签到成功!");
  356. [Tools playAudioWithString:@"签到成功,开始实操计时,请系好安全带"];
  357. }];
  358. }
  359. - (void)updateReserveEnd {
  360. [LoadingView showHUD];
  361. if (![Util connectedToNetWork]) {
  362. showMsgUnconnect();
  363. return;
  364. }
  365. NSMutableArray *arr = [NSMutableArray array];
  366. [arr addPro:@"orderId" Value:[coachQRCodeDic[@"dataString"] componentsSeparatedByString:@";"].lastObject];
  367. [arr addPro:@"userId" Value:RQ_USER_MANAGER.currentUser._id];
  368. [arr addPro:@"coachId" Value:[coachQRCodeDic[@"dataString"] componentsSeparatedByString:@";"][0]];
  369. NSString* method = @"updateReserveEnd";
  370. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
  371. RemoveHUD();
  372. if (!root) {
  373. ShowMsg(@"签退失败!");
  374. [Tools playAudioWithString:@"签退失败!"];
  375. return;
  376. }
  377. if ([root[@"code"] isEqualToString:@"1"]) {
  378. ShowMsg(root[@"body"]);
  379. [Tools playAudioWithString:root[@"body"]];
  380. return;
  381. }
  382. ShowMsg(@"签退成功!");
  383. [Tools playAudioWithString:@"签退成功!"];
  384. }];
  385. }
  386. #pragma mark - LazyLoad
  387. - (UICollectionView *)collectionView {
  388. if (!_collectionView) {
  389. _collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, RQ_SCREEN_WIDTH, RQ_SCREEN_HEIGHT) collectionViewLayout:self.collectionViewFlowLayout];
  390. _collectionView.backgroundColor = RQlineColor;
  391. _collectionView.delegate = self;
  392. _collectionView.dataSource = self;
  393. _collectionView.bounces = YES;
  394. _collectionView.showsVerticalScrollIndicator = NO;
  395. _collectionView.showsHorizontalScrollIndicator = NO;
  396. _collectionView.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);
  397. // 注册
  398. [_collectionView registerNib:[UINib nibWithNibName:@"TimingCommonCell" bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:@"TimingCommonCell"];
  399. [_collectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"UICollectionViewHeader"];
  400. [_collectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:@"UICollectionViewFooter"];
  401. }
  402. return _collectionView;
  403. }
  404. - (UICollectionViewFlowLayout *)collectionViewFlowLayout {
  405. if (!_collectionViewFlowLayout) {
  406. _collectionViewFlowLayout = [[UICollectionViewFlowLayout alloc] init];
  407. // 设置最小行间距
  408. _collectionViewFlowLayout.minimumLineSpacing = 2;
  409. // 最小列间距
  410. _collectionViewFlowLayout.minimumInteritemSpacing = 2;
  411. /**
  412. * 设置自动滚动的方向 垂直或者横向
  413. */
  414. _collectionViewFlowLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
  415. /**
  416. * 设置集合视图内边距的大小
  417. *
  418. * @param 20 上
  419. * @param 20 左
  420. * @param 20 下
  421. * @param 20 右
  422. *
  423. * @return UIEdgeInsetsMake 与下面的方法相同 -(UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
  424. */
  425. _collectionViewFlowLayout.sectionInset = UIEdgeInsetsMake(16, 16, 16, 16);
  426. }
  427. return _collectionViewFlowLayout;
  428. }
  429. - (NSArray *)collectionDataArr {
  430. if ([RQ_SHARE_FUNCTION.timingTypeOneCityCodeArr containsObject:RQ_USER_MANAGER.currentUser.city]) {
  431. return [RQCollectionSectionModel arrayOfModelsFromData:[NSJSONSerialization dataWithJSONObject:self.sourceDataDic[@"1"] options:0 error:nil] error:nil];
  432. } else if ([RQ_SHARE_FUNCTION.timingTypeTwoCityCodeArr containsObject:RQ_USER_MANAGER.currentUser.city]) {
  433. return [RQCollectionSectionModel arrayOfModelsFromData:[NSJSONSerialization dataWithJSONObject:self.sourceDataDic[@"1"] options:0 error:nil] error:nil];
  434. } else {
  435. return [RQCollectionSectionModel arrayOfModelsFromData:[NSJSONSerialization dataWithJSONObject:self.sourceDataDic[@"1"] options:0 error:nil] error:nil];
  436. }
  437. }
  438. - (NSDictionary *)sourceDataDic {
  439. return @{
  440. @"0" : @[@{@"sectionTitle" : @"",
  441. @"sectionDataArr" : @[@{@"itemTitle" : @"理论计时",
  442. @"itemSubTitle" : @"",
  443. @"itemImageName" : @"Time_lilun.png"},
  444. @{@"itemTitle" : @"实操计时",
  445. @"itemSubTitle" : @"",
  446. @"itemImageName" : @"Time_shicao.png"},
  447. @{@"itemTitle" : @"模拟计时",
  448. @"itemSubTitle" : @"",
  449. @"itemImageName" : @"Time_moni.png"},
  450. @{@"itemTitle" : @"我的学时",
  451. @"itemSubTitle" : @"",
  452. @"itemImageName" : @"Time_xueshi.png"}]}],
  453. @"1" : @[@{@"sectionTitle" : @"",
  454. @"sectionDataArr" : @[@{@"itemTitle" : @"理论计时",
  455. @"itemSubTitle" : @"",
  456. @"itemImageName" : @"Time_lilun.png"},
  457. @{@"itemTitle" : @"我的学时",
  458. @"itemSubTitle" : @"",
  459. @"itemImageName" : @"Time_xueshi.png"}]}],
  460. };
  461. }
  462. - (NSString *)noteStr {
  463. return @"请注意:\n\n 本系统是按照2016驾驶员培训新国标要求,严格照规范设计,终端上传分钟学时来计算,在计时过程中请注意以下几点: \n\n1、如果所在地市有开启围栏,请注意确保您当前的位置在规定的围栏内训练,否则分钟学时无效 \n\n2、如果所在地市有开启培训时段,请确保您当前训练时间符合规定,比如早上6:00-20:00 \n\n3、确保教练手机是正常联网且安装支持3G以上的移动,联通和电信的SIM,否则无法采集到手机终端的位置,系统会判定分钟学时无效 \n\n4、系统为防止特殊情况,教练带教过程接到电话,允许断网一段时间,默认15分钟,如果超过15分钟,所带教学员的分钟学时无效 \n\n5、学员和教练的有效距离不能超过规定距离,否则分钟学时无效,详情请咨询教练或您所在的驾校 \n\n6、系统默认在2分钟及以上时间段内,如果移动距离为0米,视为无效分钟学时 \n\n7、根据规定,学员科目二和科目三1分钟内移动距离不能低于规定的数值,否则分钟学时无效,具体询问驾校或教练 \n\n8、如果您选择计时收费训练,您可以在训练结束且支付完成后对教练进行评价和投诉,如果训练完成后不支付,您的学时将无效且无法进行下一次训练 \n\n 为了保证您的合法利益,请遵守规定,同时也请提醒您的教练,手机不能断网或在带教过程中长时间接听电话,否则会影响您的学时有效性判断,导致学时无效";
  464. }
  465. @end