// // HmV1.m // jiaPei // // Created by apple on 15/11/13. // Copyright (c) 2015年 JCZ. All rights reserved. // #import "HmV1.h" #import "AdvertisingColumn.h" #import "STButton.h" #import "ExamVC.h" #import "StatisVC.h" #import "ScoreRankVC.h" #import "TRListVC.h" #import "TRDetailVC.h" #import "StrongVC.h" #import "VowBar.h" #import "TopicesVC.h" #import "ADView.h" #import "ExerciseVC.h" #import "ListVC.h" #import "ExamVC.h" #import "StatisVC.h" #import "MyGradeVC.h" #import "RQMultiButtons.h" #import "RQWebViewViewController.h" //#import "VipLessonViewController.h" #import "OliveappLivenessDetectionViewController.h" #import "OliveappCameraPreviewController.h" #import "OliveappDetectedFrame.h" #import "OliveappBase64Helper.h" @interface HmV1 () @property (nonatomic, readwrite, strong) RQMultiButtons *multibuttons; @end @implementation HmV1 { /**错题数标签 */ UILabel *faultLbl; AdvertisingColumn *adView; VowBar *vowItem;//许愿UI //视频 UIView *videoCoverView; UIView *videoView; UIButton *getVideoBtn; NSArray *videoArray; CLLocationCoordinate2D myLocation; } - (void)viewDidLoad { [super viewDidLoad]; [self myInit]; } -(void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; [self getFaultCntNew]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; } -(void)myInit { self.view.height = self.viewH; [self.view setBackgroundColor:[UIColor whiteColor]]; [self configNavigationBar]; scroll = self.zzScrollV; [self.view addSubview:scroll]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateAD:) name:@"updateAD" object:nil]; adView = [[AdvertisingColumn alloc]initWithFrame:CGRectMake(0, 0, kSize.width, kSize.width*9/32.0)]; //广告 NSMutableArray *newAD = [NSMutableArray array]; if (_subject == 1){ for (NSDictionary *dic in myDelegate.adArray) { if ([dic[@"LOCATION"] isEqualToString:@"3"]) { [newAD addObject:dic]; } } }else{ for (NSDictionary *dic in myDelegate.adArray) { if ([dic[@"LOCATION"] isEqualToString:@"6"]) { [newAD addObject:dic]; } } } [adView setImgArray:newAD]; adView.supVC = self; [scroll addSubview:adView]; CGFloat btn_w = kSize.width/3; CGFloat btn_H = btn_w*2/3; NSMutableArray* btnArr = [NSMutableArray array]; STButton* btn; { UIView* line0 = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(adView.frame)+btn_H, kSize.width, 1)]; [line0 setBackgroundColor:KlineColor]; [scroll addSubview:line0]; line0 = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(line0.frame)+btn_H, kSize.width, 10)]; [line0 setBackgroundColor:KlineColor]; [scroll addSubview:line0]; line0 = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(line0.frame)+btn_H, kSize.width, 1)]; [line0 setBackgroundColor:KlineColor]; [scroll addSubview:line0]; line0 = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(line0.frame)+btn_H, kSize.width, 10)]; [line0 setBackgroundColor:KlineColor]; [scroll addSubview:line0]; } btn= [[STButton alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(adView.frame), btn_w, btn_H)]; [btnArr addObject:btn]; btn = [[STButton alloc] initWithFrame:CGRectMake(btn_w*2, CGRectGetMaxY(adView.frame), btn_w, btn_H)]; [btnArr addObject:btn]; btn = [[STButton alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(btn.frame)+1, btn_w, btn_H)]; [btnArr addObject:btn]; btn = [[STButton alloc] initWithFrame:CGRectMake(btn_w*2, btn.frame.origin.y, btn_w, btn_H)]; [btnArr addObject:btn]; //middle1 CGPoint center = CGPointMake(kSize.width/2, btn_H+1/2+CGRectGetMaxY(adView.frame)); btn = [[STButton alloc] initWithFrame:CGRectMake(0, 0, btn_w, btn_w)]; btn.center = center; btn.clipsToBounds = YES; btn.layer.cornerRadius = btn_w/2; [btnArr addObject:btn]; UIImageView* iv = [[UIImageView alloc] initWithFrame:btn.frame]; CGPoint center2 = CGPointMake(iv.width/2, iv.height/2+btn_w/2*0.3); UILabel* lblx = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, btn_w, btn_w/2)]; lblx.center = center2; [RACObserve(defUser, car_type) subscribeNext:^(id _Nullable x) { [iv setImage:[UIImage imageNamed:RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN? @"exCircle.png" : ([defUser.car_type isEqualToString:@"2"]? @"examCircle.png" : @"exCircle.png")]]; [lblx setText:RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN? @"练习/考试" : ([defUser.car_type isEqualToString:@"2"]? @"结业考核" : @"练习/考试")]; }]; [lblx setFont:[UIFont scaleSize:NormalFont]]; [lblx setTextAlignment:NSTextAlignmentCenter]; [iv addSubview:lblx]; [scroll addSubview:iv]; UIButton *bjmsBtn = btnArr[btnArr.count-2]; btn= [[STButton alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(bjmsBtn.frame) + 10, btn_w, btn_H)]; [btnArr addObject:btn]; btn = [[STButton alloc] initWithFrame:CGRectMake(btn_w*2, btn.y, btn_w, btn_H)]; [btnArr addObject:btn]; btn = [[STButton alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(btn.frame) + 1, btn_w, btn_H)]; [btnArr addObject:btn]; btn = [[STButton alloc] initWithFrame:CGRectMake(btn_w*2, btn.y, btn_w, btn_H)]; [btnArr addObject:btn]; //middle2 CGPoint center3 = CGPointMake(kSize.width/2, btn.y-1/2); btn = [[STButton alloc] initWithFrame:CGRectMake(0, 0, btn_w, btn_w)]; btn.center = center3; btn.clipsToBounds = YES; btn.layer.cornerRadius = btn_w/2; [btnArr addObject:btn]; iv = [[UIImageView alloc] initWithFrame:btn.frame]; [iv setImage:[UIImage imageNamed:@"远程教育.png"]]; CGPoint center4 = CGPointMake(iv.width/2, iv.height/2+btn_w/2*0.3); lblx = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, btn_w, btn_w/2)]; lblx.center = center4; [lblx setText:@"远程教育"]; [lblx setFont:[UIFont scaleSize:NormalFont]]; [lblx setTextAlignment:NSTextAlignmentCenter]; [iv addSubview:lblx]; [scroll addSubview:iv]; UIButton *qhlxBtn = btnArr[btnArr.count-2]; CGFloat fiveBtn_Y = CGRectGetMaxY(qhlxBtn.frame) +10; btn_w = kSize.width/5; btn_H = 80; for (int i=0; i<5; i++) { btn= [[STButton alloc] initWithFrame:CGRectMake(btn_w*i, fiveBtn_Y, btn_w, btn_H)]; [btnArr addObject:btn]; } CGFloat lblW = 25; faultLbl = [[UILabel alloc] initWithFrame:CGRectMake(btn_w/2, lblW/2*1/10, lblW + 5, lblW/2)]; [faultLbl setTextAlignment:NSTextAlignmentCenter]; [faultLbl setTextColor:[UIColor whiteColor]]; [faultLbl.layer setCornerRadius:6]; [faultLbl setFont:[UIFont scaleSize:10]]; [faultLbl.layer setMasksToBounds:YES]; //错题按钮的tag和index是13, [btnArr[13] addSubview:faultLbl]; @weakify(btn); [RACObserve(defUser, car_type) subscribeNext:^(id _Nullable x) { @strongify(btn); NSArray* titles = RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN? @[ @"随机练习",@"章节练习",@"背题模式",@"排除的题",@"", @"我的成绩",@"练习统计",@"强化练习",@"排行榜 ",@"", @"交通法规",@"考试技巧",@"未做题",@"我的错题",@"我的收藏"] : @[[defUser.car_type isEqualToString:@"2"]? @"随机/顺序" : @"随机练习",@"章节练习",@"背题模式",@"排除的题",@"", @"我的成绩",@"练习统计",@"强化练习",@"排行榜 ",@"", @"交通法规",@"考试技巧",@"未做题",@"我的错题",@"我的收藏"]; NSArray* images = @[@"subject1_random_excercise_icon.png", @"menu_new_normal_ico_f.png", @"subject4_title_press.png", @"subject1_remove_excercise_icon.png", @"NULL.png",@"subject1_simulate_result_icon.png", @"subject1_statistical_excercise_icon.png", @"subject1_special_excercise_icon.png", @"subject1_rating_board_icon.png", @"NULL.png", @"drawer_img06.png",@"drawer_img04.png", @"question_undo_icon.png"/*未做题*/, @"question_add_error_press_icon.png", @"favoritestar_checked_icon", @"",@""]; for (int i =0; i>"; [vowItem.topicBtn addTarget:self action:@selector(vowClick:) forControlEvents:UIControlEventTouchUpInside]; vowItem.topicBtn.tag = 11; [vowItem.vomBtn addTarget:self action:@selector(vowClick:) forControlEvents:UIControlEventTouchUpInside]; vowItem.vomBtn.tag = 12; // [scroll addSubview:vowItem]; [scroll setContentSize:CGSizeMake(0, CGRectGetMaxY(vowItem.frame) + SCRV_BottomH)]; [self getVideos]; } - (void)updateAD:(NSNotification *)notifica { NSMutableArray *newAD = [NSMutableArray array]; if (_subject == 1){ for (NSDictionary *dic in myDelegate.adArray) { if ([dic[@"LOCATION"] isEqualToString:@"3"]) { [newAD addObject:dic]; } } }else{ for (NSDictionary *dic in myDelegate.adArray) { if ([dic[@"LOCATION"] isEqualToString:@"6"]) { [newAD addObject:dic]; } } } [adView setImgArray:newAD]; [[NSNotificationCenter defaultCenter] removeObserver:self name:@"updateAD" object:nil]; } -(void)vowClick:(UIButton *)btn { TopicesVC* vc = [[TopicesVC alloc] init]; vc.type = @"1"; if (btn.tag == 11) { if (_subject == 1) { vc.groupId = @"4"; } else { vc.groupId = @"7"; } } else { vc.groupId = @"9"; } [self navPushHideTabbarToVC:vc]; } -(void)btnClick:(STButton*)sender { int tag = (int)sender.tag; if (10 == tag) { TRListVC* vc = [[TRListVC alloc] init]; NSArray* arr = @[@"2016《机动车驾驶证申领和使用规定》", @"中华人民共和国道路交通安全法", @"道路交通安全违法行为处理程序规定", @"道路交通事故处理程序规定", @"酒驾新规"]; [vc setModels:arr]; [vc setTitle:@"交通法规"]; [self navPushHideTabbarToVC:vc]; } if (11 == tag) { TRListVC* vc = [[TRListVC alloc] init]; NSArray* arr = @[@"科目一考试技巧记忆口诀", @"科目一考试应试必备技巧", @"科目一到科目四,超牛的驾考经验技巧,科科必过!", @"理论考试知识汇总", @"【科目一】交规巧记十三条!", @"3分钟,快速掌握考试车内提示灯如何操作", @"日期类题目最头痛,来看看我们总结的快速学习方法!", @"帮您快速巧记交规秘诀,看完想不过都难!", @"交规理论考试十大“给力”攻略"]; [vc setModels:arr]; [vc setTitle:@"考试技巧"]; [self navPushHideTabbarToVC:vc]; } switch (sender.tag) { case 0:{//随机练习 if (RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN) { [myDelegate setType:@"2"]; [self gotoExerVC]; } else { if ([defUser.car_type isEqualToString:@"2"]) { if (_multibuttons) { _multibuttons = nil; } STButton *btn = [self.view viewWithTag:4]; _multibuttons = [[ RQMultiButtons alloc] initWithPoint:btn.center radius:140 inView:self.view]; _multibuttons.bubbleRadius = 40; _multibuttons.delegate = self; [_multibuttons addCustomButtonWithIcon:[UIImage imageNamed:@"subject1_random_excercise_icon.png"] title:@"随机练习" backgroundColor:UIColor.whiteColor andButtonId:103]; [_multibuttons addCustomButtonWithIcon:[UIImage imageNamed:@"exCircle.png"] title:@"顺序练习" backgroundColor:[UIColor colorWithRed:0.0 green:164.0/255.0 blue:120.0/255.0 alpha:1.0] andButtonId:104]; [_multibuttons show]; } else { [myDelegate setType:@"2"]; [self gotoExerVC]; } } } break; case 1://专项练习 [myDelegate setType:@"3"]; [self gotoListVC]; break; case 2://背题模式 [myDelegate setType:@"8"]; [self gotoExerVC]; break; case 3://排除的题 [myDelegate setType:@"6"]; [self gotoExerVC]; break; case 4: { //顺序练习 if (RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN) { if (_multibuttons) { _multibuttons = nil; } _multibuttons = [[RQMultiButtons alloc] initWithPoint:sender.center radius:140 inView:self.view]; _multibuttons.bubbleRadius = 40; _multibuttons.delegate = self; [_multibuttons addCustomButtonWithIcon:[UIImage imageNamed:@"exCircle.png"] title:@"顺序练习" backgroundColor:[UIColor colorWithRed:0.0 green:164.0/255.0 blue:120.0/255.0 alpha:1.0] andButtonId:100]; [_multibuttons addCustomButtonWithIcon:[UIImage imageNamed:@"examCircle.png"] title:@"模拟考试" backgroundColor:[UIColor colorWithRed:0.0 green:164.0/255.0 blue:120.0/255.0 alpha:1.0] andButtonId:101]; // [_multibuttons addCustomButtonWithIcon:[UIImage imageNamed:@"examCircle.png"] title:@"VIP课程" // backgroundColor:[UIColor colorWithRed:0.0 green:164.0/255.0 blue:120.0/255.0 alpha:1.0] // andButtonId:102]; [_multibuttons show]; } else { if ([defUser.car_type isEqualToString:@"2"]) { // [myDelegate setType:@"1"]; // [self gotoExerVC]; //结业考核 // [myDelegate setType:@"9"]; // [self gotoExamVC]; // return; if (!myDelegate.isLogin) { ShowMsg(@"请登录后再操作!"); [self userLoginAction]; }else { [MBProgressHUD showMessage:@"正在获取当前位置..." toView:self.view]; [[MapManager sharedManager] updateLocationWithCompleteBlock:^(BOOL success, CLLocation *location) { [MBProgressHUD hideHUDForView:self.view animated:YES]; if (success) { self->myLocation = location.coordinate; [self takePhoto]; } }]; } } else { if (_multibuttons) { _multibuttons = nil; } _multibuttons = [[RQMultiButtons alloc] initWithPoint:sender.center radius:140 inView:self.view]; _multibuttons.bubbleRadius = 40; _multibuttons.delegate = self; [_multibuttons addCustomButtonWithIcon:[UIImage imageNamed:@"exCircle.png"] title:@"顺序练习" backgroundColor:[UIColor colorWithRed:0.0 green:164.0/255.0 blue:120.0/255.0 alpha:1.0] andButtonId:100]; [_multibuttons addCustomButtonWithIcon:[UIImage imageNamed:@"examCircle.png"] title:@"模拟考试" backgroundColor:[UIColor colorWithRed:0.0 green:164.0/255.0 blue:120.0/255.0 alpha:1.0] andButtonId:101]; // [_multibuttons addCustomButtonWithIcon:[UIImage imageNamed:@"examCircle.png"] title:@"VIP课程" // backgroundColor:[UIColor colorWithRed:0.0 green:164.0/255.0 blue:120.0/255.0 alpha:1.0] // andButtonId:102]; [_multibuttons show]; } } break; } case 5://我的成绩 [self gotoMyGradeVC]; break; case 6://练习统计 [self gotoStaticVC]; break; case 7://强化练习 [myDelegate setType:@"5"]; [self gotoStrongVC]; break; case 8://排行榜 [self gotoScoreRank]; break; case 9: { if (!myDelegate.isLogin) { ShowMsg(@"请登录后再操作!"); [self userLoginAction]; }else { [Tools confirmImeiWithLogType:@"5" successBlock:^{ [self postCheckEduStu]; }]; } break; } case 12://未做题练习 [myDelegate setType:@"10"]; [self gotoExerVC]; break; case 13://错题练习 [myDelegate setType:@"4"]; [self gotoExerVC]; break; case 14://我的收藏 [myDelegate setType:@"7"]; [self gotoExerVC]; break; default: break; } if (tag == 20) { // DownLoadVC *downLoadVC = [[DownLoadVC alloc] init]; // downLoadVC.subject = _subject; // [self navPushHideTabbarToVC:downLoadVC]; // VideoDownLoadListVC *downLoadVC = [[VideoDownLoadListVC alloc] init]; // downLoadVC.videoListSegControlIndex = _subject - 1; // [self navPushHideTabbarToVC:downLoadVC]; } if (tag > 20 && tag < 27) { // VideoPlayVC *vc = [[VideoPlayVC alloc] init]; // if (videoArray.count > 5) { // vc.dataDic = videoArray[tag - 21]; // } // vc.subject = _subject; // [self navPushHideTabbarToVC:vc]; // LeeVideoVC *vc = [[LeeVideoVC alloc]init]; // if (videoArray.count > 5) { // vc.dataDic = videoArray[tag - 21]; // } // vc.subject = _subject; // vc.goDownLoadBlock = ^{ // DownLoadVC *downLoadVC = [[DownLoadVC alloc] init]; // downLoadVC.subject = _subject; // [self navPushHideTabbarToVC:downLoadVC]; // }; // vc.modalPresentationStyle = UIModalPresentationFullScreen; // [self presentViewController:vc animated:YES completion:nil]; // VideoPlayViewController *vc = [[VideoPlayViewController alloc] init]; // if (videoArray.count > 3) { // NSDictionary *dic = videoArray[sender.tag - 21]; // RQDownloadModel *downloadModel = [[RQDownloadModel alloc] init]; // downloadModel.videoId = dic[@"id"]; // downloadModel.subject = dic[@"subject"]; // downloadModel.title = dic[@"title"]; // downloadModel.urlString = dic[@"videoPath"]; // downloadModel.imageUrl = dic[@"image"]; // downloadModel.content = dic[@"content"]; // vc.currentModel = downloadModel; // } // [self navPushHideTabbarToVC:vc]; } } - (void)rqMultiButtons:(RQMultiButtons *)multiButtons tappedButtonWithType:(RQMultiButtonsType)buttonType { switch (buttonType) { case 100: case 104: //顺序练习 [myDelegate setType:@"1"]; [self gotoExerVC]; break; case 101: //模拟考试 [myDelegate setType:@"9"]; [self gotoExamVC]; break; case 102: //VIP课程 [self gotoVipVC]; break; case 103: //随机练习 [myDelegate setType:@"2"]; [self gotoExerVC]; break; default: break; } } //VIP课程 - (void)gotoVipVC { // VipLessonViewController* vc = [VipLessonViewController suspendCenterPageVC]; // [self navPushHideTabbarToVC:vc]; } -(void)gotoExerVC { ExerciseVC* vc = [[ExerciseVC alloc] init]; [self navPushHideTabbarToVC:vc]; } -(void)gotoListVC { ListVC* vc = [[ListVC alloc] init]; [self navPushHideTabbarToVC:vc]; } -(void)gotoExamVC { ExamVC* vc = [[ExamVC alloc] init]; [self navPushHideTabbarToVC:vc]; } -(void)gotoStaticVC { StatisVC* vc = [[StatisVC alloc] init]; [self navPushHideTabbarToVC:vc]; } -(void)gotoMyGradeVC { MyGradeVC* vc = [[MyGradeVC alloc] init]; [self navPushHideTabbarToVC:vc]; } -(void)gotoScoreRank { ScoreRankVC* vc = [[ScoreRankVC alloc] init]; [self navPushHideTabbarToVC:vc]; } -(void)gotoStrongVC { StrongVC *vc = [[StrongVC alloc] init]; [self navPushHideTabbarToVC:vc]; } -(void)setSubject:(int)subject{ _subject = subject; } - (void)userLoginAction { LoginViewController* vc = [[LoginViewController alloc] init]; vc.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; vc.modalPresentationStyle = UIModalPresentationFullScreen; [self.parentViewController presentViewController:vc animated:YES completion:nil]; } #pragma mark - 获取错题数新_NOW -(void)getFaultCntNew { NSInteger faultCnt = RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN? [DB_Que_Helper queryMarkQuestionWithMarkType:@"1"] : ([defUser.car_type isEqualToString:@"2"]? [DB_Que_Helper queryGZPZ_EXAM_CYRYMarkQuestionWithMarkType:@"1"] : [DB_Que_Helper queryMarkQuestionWithMarkType:@"1"]); if (faultCnt > 0) { [faultLbl setText:[NSString stringWithFormat:@"%d",(int)faultCnt]]; [faultLbl setBackgroundColor:[UIColor redColor]]; }else{ [faultLbl setText:@""]; [faultLbl setBackgroundColor:[UIColor clearColor]]; } } #pragma mark 之前非常麻烦的获取错题数 尽量弃用 /**获取错题数 同步完用的 */ -(void)getFaultCnt { if (myDelegate.faultArray.count > 2) { NSInteger faultCnt = 0; if (_subject == 1) { faultCnt = [myDelegate.faultArray[0] integerValue]; } if (_subject == 4) { faultCnt = [myDelegate.faultArray[1] integerValue]; } if ([defUser.car_type isEqualToString:@"1"] || [defUser.car_type isEqualToString:@"2"] || [defUser.car_type isEqualToString:@"3"] || [defUser.car_type isEqualToString:@"4"] || [defUser.car_type isEqualToString:@"5"] || [defUser.car_type isEqualToString:@"6"]) { faultCnt = [myDelegate.faultArray[2] integerValue]; } if (faultCnt > 0) { [faultLbl setText:[NSString stringWithFormat:@"%d",(int)faultCnt]]; [faultLbl setBackgroundColor:[UIColor redColor]]; }else{ [faultLbl setText:@""]; [faultLbl setBackgroundColor:[UIColor clearColor]]; } }else{ [self performSelector:@selector(waitFault) withObject:nil afterDelay:2]; [self waitFault]; } } -(void)waitFault { static NSInteger i = 0; i++; if (i > 5) { i = 0; return; } [self getFaultCnt]; } //在同步完错题后 之后的同步 用这个查询 -(void)getFault { //因为科四也要加载 所以会执行两次 NSString* sql = [NSString stringWithFormat:@"state = 1 and subject = %d",_subject]; if ([defUser.car_type isEqualToString:@"1"] || [defUser.car_type isEqualToString:@"2"] || [defUser.car_type isEqualToString:@"3"] || [defUser.car_type isEqualToString:@"4"] || [defUser.car_type isEqualToString:@"5"] || [defUser.car_type isEqualToString:@"6"]) { sql = [NSString stringWithFormat:@"state = 1"]; } NSInteger faultCnt = [DB_Que_Helper countForQuery:sql]; if (faultCnt > 0) { [faultLbl setText:[NSString stringWithFormat:@"%d",(int)faultCnt]]; [faultLbl setBackgroundColor:[UIColor redColor]]; }else{ [faultLbl setText:@""]; [faultLbl setBackgroundColor:[UIColor clearColor]]; } } #pragma mark 获取视频资源 -(void)getVideos { if (![Util connectedToNetWork]) { showMsgUnconnect(); return; } NSMutableArray *aArray=[NSMutableArray array]; [aArray addPro:@"chapterId" Value:[NSString stringWithFormat:@"%d",_subject]]; [aArray addPro:@"subject" Value:[NSString stringWithFormat:@"%d",_subject]]; [aArray addPro:@"isPage" Value:@"0"]; [aArray addPro:@"pageSize" Value:@"0"]; [aArray addPro:@"currentPage" Value:@"0"]; NSString* method = @"getVideos"; [jiaPeiManager requestAnythingWithURL:method array:aArray data:nil completion:^(NSDictionary *root) { //NSLog(@"获取视频aArray-->%@------------------root-->%@",aArray,root); if (!root) { //加载视频模块 [getVideoBtn setTitle:@"视频获取失败,点击重试" forState:UIControlStateNormal]; getVideoBtn.userInteractionEnabled = YES; return ; } if ([root[@"code"] isEqualToString:@"1"]) { ShowMsg(root[@"body"]); [getVideoBtn setTitle:@"视频获取失败,点击重试" forState:UIControlStateNormal]; getVideoBtn.userInteractionEnabled = YES; return; } getVideoBtn.userInteractionEnabled = NO; [getVideoBtn setTitle:@"" forState:UIControlStateNormal]; if ([root[@"body"] count] > 5) { videoArray = root[@"body"]; [self initVideoView]; } }]; } - (void)postCheckEduStu { if (![Util connectedToNetWork]) { showMsgUnconnect(); return; } NSMutableArray *aArray=[NSMutableArray array]; [aArray addPro:@"idcard" Value:[NSString stringWithFormat:@"%@",defUser.userDict[@"loginCode"]]]; [aArray addPro:@"pxcx" Value:[NSString stringWithFormat:@"%@",defUser.userDict[@"car_type"]]]; [aArray addPro:@"outid" Value:[NSString stringWithFormat:@"%@",defUser.userDict[@"outId"]]]; NSString* method = @"checkEduStu"; [MBProgressHUD showHUDAddedTo:self.view animated:YES]; [jiaPeiManager requestAnythingWithURL:method array:aArray data:nil completion:^(NSDictionary *root) { [MBProgressHUD hideHUDForView:self.view]; if (!root) { ShowMsgFailed(); return ; } if ([root[@"code"] isEqualToString:@"0"]) { //远程教育 SCLAlertView *alert = [[SCLAlertView alloc] initWithNewWindowWidth:kScreenWidth - 32]; alert.customViewColor = defGreen; alert.showAnimationType = SCLAlertViewShowAnimationFadeIn; alert.viewText.textAlignment = NSTextAlignmentLeft; UITextView *view = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth - 64, kScreenHeight * 0.5)]; view.font = [UIFont systemFontOfSize:15]; view.editable = NO; [alert addButton:@"确定" actionBlock:^(void) { RQWebViewViewController *vc = [[RQWebViewViewController alloc] init]; vc.webType = WebTypeEDU; if (root[@"data"][@"url"] && ![root[@"data"][@"url"] isEqualToString:@""]) { vc.url = [NSString stringWithFormat:@"%@", root[@"data"][@"url"]]; }else { vc.url = [NSString stringWithFormat:@"http://lncx.anjia365.com/h5/xzz/#/login?state=1&userName=%@&pwd=%@&area=2101&type=cx&pxcx=%@",defUser.userDict[@"loginCode"],defUser.userDict[@"password"],defUser.userDict[@"car_type"]]; } NSLog(@"%@",vc.url); [self navPushHideTabbarToVC:vc]; }]; NSMutableString *content = [NSMutableString string]; NSArray *strArr = root[@"data"][@"precautions"]; [strArr.rac_sequence.signal subscribeNext:^(NSString *str) { if (strArr.count > 1) { [content appendFormat:@"%d.%@\n\n",(int)[strArr indexOfObject:str] + 1,str]; }else { [content appendFormat:@"%@\n\n",str]; } } completed:^{ dispatch_main_async_safe(^{ if (content.length == 0) { content.string = @"1.训练已学习过的课件,学时不累加;\n\n2.每个科目的课件全部都学习完后可以重置,重置后的课件学习时可以再次累加学时;\n\n3.科目一科目四,混合训练时会产生多段培训记录;\n\n4.如果训练过程异常退出,30分钟内重新登录训练的,继续学习同一个科目将继续累加学时,继续学习不同科目上一段将做为异常记录上报;\n\n5.如果训练过程异常退出,超过30分钟内重新登录训练的, 上一段将做为异常记录上报;\n\n"; } view.text = content.mutableCopy; CGFloat textHeight = [view.text heightForWid:view.width Font:15]; view.height = (textHeight > kScreenHeight/2)? kScreenHeight/2 : textHeight; [alert addCustomView:view]; [alert showInfo:@"温馨提示" subTitle:@"" closeButtonTitle:@"取消" duration:0.0f]; }) }]; } else { ShowMsg(root[@"msg"]); return ; } }]; } -(void)initVideoView { //290*260 290*180 290*70 h = 265 videoView = [[UIView alloc] initWithFrame:videoCoverView.frame]; videoView.backgroundColor = [UIColor whiteColor]; //重置页面展示形式 CGFloat w = (kSize.width - 30)/2.0; videoView.height = w*78/29.0 + 40; [scroll addSubview:videoView]; [scroll setContentSize:CGSizeMake(0, videoView.bottom + (10+VAWBAR_H) + SCRV_BottomH)]; vowItem.y = videoView.bottom + 20; [vowItem addViewWithRect:CGRectMake(0, vowItem.y - 20, kSize.width, 10) Color:KlineColor]; UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, kSize.width/2.0 - 10, 40)]; [label setText:@"教学视频" Font:FontTitle TextColor:kTitleColor Alignment:NSTextAlignmentLeft]; [videoView addSubview:label]; label = [[UILabel alloc] initWithFrame:CGRectMake(kSize.width/2.0, 0, kSize.width/2.0 - 10, 40)]; [label setText:[NSString stringWithFormat:@"共%d个视频>",(int)videoArray.count] Font:Font17 TextColor:contentTextColor Alignment:NSTextAlignmentRight]; [videoView addSubview:label]; UIButton *moreVideoBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, kSize.width, 40)]; [moreVideoBtn target:self tag:20];//tag 20开始 [videoView addSubview:moreVideoBtn]; CGFloat bdH = w*26/29.0; CGFloat photoH = w*18/29.0; CGFloat labelH = w*7/29.0; NSInteger videoNum = videoArray.count; if (videoNum > 6) { videoNum = 6; } for (int i = 0; i < videoNum; i ++) { int row = i/2; int clumn = i%2; NSDictionary *dic = videoArray[i]; //照片 UIImageView *videoImageView = [[UIImageView alloc] initWithFrame:CGRectMake(10 + clumn*(w + 10), 40 + row*bdH, w, photoH)]; NSString *str = dic[@"image"]; if (!str) { str = @""; } [videoImageView sd_setImageWithURL:[NSURL URLWithString:str] placeholderImage:[UIImage imageNamed:@"NOIMG.png"]]; [videoView addSubview:videoImageView]; //时长 label = [[UILabel alloc] initWithFrame:CGRectMake(10 + clumn*(w + 10), row*bdH + photoH + 15, w - 10, 25)]; label.backgroundColor = windowBlockColor; int seconds = [dic[@"times"] intValue]; NSString *min = [NSString stringWithFormat:@"%d",seconds/60]; NSString *sec = [NSString stringWithFormat:@"%d",seconds%60]; if (seconds/60 < 10) { min = [NSString stringWithFormat:@"0%@",min]; } if (seconds%60 < 10) { sec = [NSString stringWithFormat:@"0%@",sec]; } [label setText:[NSString stringWithFormat:@"%@:%@",min,sec] Font:NormalFont TextColor:[UIColor whiteColor] Alignment:NSTextAlignmentRight]; [videoView addSubview:label]; //title label = [[UILabel alloc] initWithFrame:CGRectMake(10 + clumn*(w + 10), 40 + row*bdH + photoH, w, labelH)]; [label setText:dic[@"title"] Font:FontTitle TextColor:kTitleColor Alignment:NSTextAlignmentLeft]; [videoView addSubview:label]; //btn UIButton *playBtn = [[UIButton alloc] initWithFrame:CGRectMake(10 + clumn*(w + 10), 40 + row*bdH, w, bdH)]; playBtn.backgroundColor = [UIColor clearColor]; [playBtn target:self tag:21 + i];//21开始 [videoView addSubview:playBtn]; } } -(void)dealloc { //这个方法 只有在页面消失的时候才会调用 在本项目中只有关闭软件才会调用这个方法。所以不作处理也没有任何问题的 这样只是更严谨 [[NSNotificationCenter defaultCenter] removeObserver:self name:@"updateAD" object:nil]; } // 人脸比对 - (void)takePhoto { UIStoryboard * board = [UIStoryboard storyboardWithName:@"LivenessDetection" bundle:nil]; OliveappLivenessDetectionViewController * livenessDetectionViewController; livenessDetectionViewController = (OliveappLivenessDetectionViewController *)[ board instantiateViewControllerWithIdentifier:@"LivenessDetectionStoryboard"]; livenessDetectionViewController.modalPresentationStyle = 0; livenessDetectionViewController.faceDelegate = self; OliveappSessionManagerConfig* config = [OliveappSessionManagerConfig new]; // config.timeoutMs = 100000; [config usePredefinedConfig: 4]; // 这里配置检测步骤 livenessDetectionViewController.cusConfig = config; NSError *error; BOOL isSuccess = [livenessDetectionViewController setConfigLivenessDetection:self withError: &error]; if (isSuccess){ [self presentViewController:livenessDetectionViewController animated:YES completion:nil]; } } - (void)onLivenessSuccess:(OliveappDetectedFrame *)detectedFrame{ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [self dismissViewControllerAnimated:YES completion:nil]; }); } - (void)onLivenessFail:(int)sessionState withDetectedFrame:(OliveappDetectedFrame *)detectedFrame{ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [self dismissViewControllerAnimated:YES completion:nil]; UIAlertController *actionsheet = [UIAlertController alertControllerWithTitle:@"提示" message:@"获取人脸失败,是否重新进行人脸比对" preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"是" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { [self takePhoto]; }]; UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"否" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) { }]; [actionsheet addAction:action1]; [actionsheet addAction:action2]; [self presentViewController:actionsheet animated:YES completion:nil]; }); } - (void)onLivenessCancel{ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [self dismissViewControllerAnimated:YES completion:nil]; }); } - (void)sendFaceImage:(UIImage *)faceImage { UIImage *normalImage = [UIImage fixOrientation:faceImage]; NSData *imgData = UIImageJPEGRepresentation(normalImage, .2f); NSString *backString = [NSString stringWithFormat:@"%@",[OliveappBase64Helper encode:imgData]]; [self face2faceJykhWithPhotoStr:backString ResultBlock:^(BOOL success) { if (success) { //模拟考试 [myDelegate setType:@"9"]; [self gotoExamVC]; } }]; } - (void)sendFaceImageError { } - (void)face2faceJykhWithPhotoStr:(NSString *)photoStr ResultBlock:(void (^)(BOOL success))resultBlock { if (![Util connectedToNetWork]) { showMsgUnconnect(); resultBlock(NO); return; } if (myLocation.longitude == 0.0) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"位置获取失败" message:nil delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil]; [alert show]; resultBlock(NO); return; } NSMutableArray *arr=[NSMutableArray array]; [arr addPro:@"stunum" Value:defUser.userDict[@"stuNum"]]; [arr addPro:@"dqbh" Value:defUser.userDict[@"city"]]; [arr addPro:@"outId" Value:defUser.userDict[@"outId"]]; [arr addPro:@"lng" Value:[NSString stringWithFormat:@"%f",myLocation.longitude]]; [arr addPro:@"lat" Value:[NSString stringWithFormat:@"%f",myLocation.latitude]]; [arr addPro:@"photo" Value:photoStr]; NSString *method = @"face2faceJykh"; [MBProgressHUD showHUDAddedTo:self.view animated:YES]; [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) { [MBProgressHUD hideHUDForView:self.view]; if (!root) { ShowMsg(@"操作失败,请重试!"); [Tools playAudioWithString:@"操作失败,请重试!"]; resultBlock(NO); return; } resultBlock([root[@"code"] integerValue] == 0); [Tools playAudioWithString:root[@"msg"]]; ShowMsg(root[@"msg"]); }]; } @end