12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055 |
- //
- // 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 ()<UIAlertViewDelegate, RQMultiButtonsDelegate, OliveappLivenessResultDelegate, FaceDetectorsDelegate>
- @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<btnArr.count; i++) {
- btn = btnArr[i];
- [btn setImage:[UIImage imageNamed:images[i]] withTitle:titles[i] Font:NormalFont forState:UIControlStateNormal];
- [btn setTag:i];
- [scroll addSubview:btn];
- [btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
- }
- }];
-
- //远程视频
- videoCoverView = [[UIView alloc] initWithFrame:CGRectMake(0, [[scroll subviews] lastObject].bottom + 10, kFrame.size.width, 70)];
- videoCoverView.backgroundColor = [UIColor whiteColor];
- [scroll addSubview:videoCoverView];
-
- UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, kSize.width - 20, 30)];
- [label setText:@"教学视频" Font:FontTitle TextColor:kTitleColor];
- [videoCoverView addSubview:label];
- [label addViewWithRect:CGRectMake(10, 29.5, kSize.width - 20, .5)];
-
- getVideoBtn = [[UIButton alloc] initWithFrame:CGRectMake(10, 30, kSize.width - 20, 40)];
- [getVideoBtn setTitle:@"正在获取视频教学资源,请稍后..." textColor:subTitleColor font:Font17 fotState:UIControlStateNormal];
- // getVideoBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
- [getVideoBtn addTarget:self action:@selector(getVideos) forControlEvents:UIControlEventTouchUpInside];
- [videoCoverView addSubview:getVideoBtn];
- getVideoBtn.userInteractionEnabled = NO;
-
- // label = [[UILabel alloc] initWithFrame:CGRectMake(10, 30, kSize.width - 20, 40)];
- // [label setText:@"正在获取视频教学资源,请稍后..." Font:Font17 TextColor:subTitleColor Alignment:NSTextAlignmentCenter];
- // label.tag = 1;
- // [videoCoverView addSubview:label];
-
- [videoCoverView addViewWithRect:CGRectMake(0, videoCoverView.y - 10, kSize.width, 10) Color:KlineColor];
- [videoCoverView addViewWithRect:CGRectMake(0, videoCoverView.y + videoCoverView.height, kSize.width, 10) Color:KlineColor];
-
-
- //加一项许愿
- if (_subject == 1)
- {
- vowItem = [[VowBar alloc] initWithFrame:CGRectMake(0, [[scroll subviews] lastObject].bottom + 20, kFrame.size.width, VAWBAR_H) title:@"科目一"];
- }else {
- vowItem = [[VowBar alloc] initWithFrame:CGRectMake(0, [[scroll subviews] lastObject].bottom + 10, kFrame.size.width, VAWBAR_H) title:@"科目四"];
- }
- vowItem.countLabel.text = @"点击参与讨论>>";
- [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
|