1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123 |
- //
- // PeriodVC.m
- // jiaPei
- //
- // Created by apple on 16/7/27.
- // Copyright © 2016年 JCZ. All rights reserved.
- //
- #import "PeriodVC.h"
- #import "Tools.h"
- #import "DES3Util.h"
- typedef enum {
- AlertTypeStopTiming = 1,
- AlertTypeGotoLogin
- }AlertType;
- @interface PeriodVC ()
- /// 跑马灯
- @property (strong, readwrite, nonatomic) QMUIMarqueeLabel *marqueeLabel;
- @property (strong, readwrite, nonatomic) NSString *classIdStr;
- @property (assign, readwrite, nonatomic) LoginFlagType loginFlagType;
- @property (strong, readwrite, nonatomic) UIView *adView;
- @property (nonatomic, readwrite, strong) QMUIPopupMenuView *popupAtBarButtonItem;
- @property (nonatomic, readwrite, strong) UIBarButtonItem *rightBarButtonItem;
- @property (strong, readwrite, nonatomic) UILabel *timeLabel;
- @property (strong, readwrite, nonatomic) UIButton *on_offBtn;
- @property (assign, readwrite, nonatomic) CGFloat varY;
- @property (strong, readwrite, nonatomic) NSTimer *timer;
- @property (strong, readwrite, nonatomic) NSDateFormatter *formatter;
- @property (assign, readwrite, nonatomic) NSInteger seconds;
- @end
- @implementation PeriodVC
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.view.backgroundColor = backGroundColor;
-
- self.loginFlagType = LoginFlagType_Default;
- [self configNavigationBar];
-
- self.varY = 40;
-
- self.marqueeLabel.frame = CGRectMake(0, 0, kSize.width, self.varY);
- [self.view addSubview:_marqueeLabel];
-
-
-
- self.timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(25, self.varY, kSize.width - 50, kSize.width/3.0)];
- self.timeLabel.backgroundColor = backGroundColor;
- [self.timeLabel borderColor:RQlineColor width:2 cornorRadius:10];
- [self.timeLabel setText:@"00:00:00" Font:44 TextColor:kTitleColor Alignment:NSTextAlignmentCenter];
- [self.view addSubview:self.timeLabel];
-
- self.varY += kSize.width/3.0 + 50;
- self.on_offBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- self.on_offBtn.frame = CGRectMake(25, self.varY, kSize.width - 50, 40);
- [self.on_offBtn setTitle:@"开始计时" textColor:RQ_MAIN_COLOR Font:FontTitle fotState:UIControlStateNormal];
- [self.on_offBtn borderColor:RQ_MAIN_COLOR width:2 cornorRadius:5];
- [self.on_offBtn target:self tag:1];
- [self.view addSubview:self.on_offBtn];
-
- self.varY += 50;
- self.title = @"理论计时";
- [self myInitTheory];
-
- [self.view addSubview:self.adView];
- // RQ_COMMON_MANAGER.bannerOnVC = self;
- [RQ_AD_MANAGER loadAdWithAdType:RQADType_Banner customView:self.adView controller:self cycleSecound:RQ_COMMON_MANAGER.JSJP_APP_AD_CYCLE];
- if (RQ_USER_MANAGER.isCykh) {
- self.navigationItem.rightBarButtonItem = self.rightBarButtonItem;
- }
- }
- - (void)viewDidDisappear:(BOOL)animated {
- [super viewDidDisappear:animated];
- [self.adView removeFromSuperview];
- self.adView = nil;
-
- }
- - (void)dealloc {
-
- }
- #pragma mark 理论计时
- - (void)myInitTheory {
- NSString *str = @"根据运管部门要求,为了防止学员在打理论学时的时候挂学时,设定以下规则:\n1、开启理论计时后不允许最小化且不能切换到别的软件,否则计时暂停\n2、每天计时最大有效时间为4学时,单条学时不得超过4学时,否则视为无效学时\n3、计时完成后,请点击结束计时并立即上传,服务器要与运管系统同步,约30分后才会反馈回手机\n4、福州培训时间 \n 课堂时间:07:00---22:00 \n 模拟时间:05:00---23:00 \n 实操:05:00---23:00 \n 远程:05:00--23:59:59 \n 请学员注意!避免非培训时间导致学时无效。";
- UILabel *remindLabel = [[UILabel alloc] initWithFrame:CGRectMake(25, self.varY, kSize.width - 50, [str heightForWid:kSize.width - 50 Font:Font17])];
- remindLabel.numberOfLines = 0;
- [remindLabel setText:str Font:Font17 TextColor:[UIColor orangeColor] Alignment:NSTextAlignmentLeft];
- [self.view addSubview:remindLabel];
-
- }
- - (void)startTimingWithResultBlock:(void (^)(BOOL isSuccess))resultBlock {
- @weakify(self)
- if (RQ_USER_MANAGER.isCykh) {
- if (![self checkCykhChooseStr]) {
- !resultBlock? : resultBlock(NO);
- return;
- }
- }
-
- [self getCurrentPXKWithComplete:^(BOOL isSuccess, NSString *pxkm) {
- @strongify(self)
- if (!isSuccess) {
- !resultBlock? : resultBlock(NO);
- return;
- }
- [RQ_USER_MANAGER.currentUser updatePxjdWithPxjd:pxkm];
- /// 理论计时类型二地市编号:null (暂无地市;在科目二可以进行科目四的理论计时,科目三暂无理论计时)
- if ([RQ_SHARE_FUNCTION.theoryOfTimingTypeTwoCityCodeArr containsObject:RQ_USER_MANAGER.currentUser.city] && [pxkm isEqualToString:@"3"]) {
- ShowMsg(@"科目三暂无理论计时!");
- !resultBlock? : resultBlock(NO);
- return;
- }
- /// 理论计时类型三地市编号:3502 (厦门;在科目三可以进行科目四的理论计时,科目二暂无理论计时)
- else if ([RQ_SHARE_FUNCTION.theoryOfTimingTypeThreeCityCodeArr containsObject:RQ_USER_MANAGER.currentUser.city] && [pxkm isEqualToString:@"2"]) {
- ShowMsg(@"科目二暂无理论计时!");
- !resultBlock? : resultBlock(NO);
- return;
- } else {
- NSLog(@"-------------------%@-------------------",[RQ_SHARE_FUNCTION.theoryOfTimingTypeThreeCityCodeArr containsObject:RQ_USER_MANAGER.currentUser.city]? @"包含" : @"不包含");
-
- if (RQ_USER_MANAGER.isycbd == 1) {
- [RQ_RemoteTheory_MANAGER getTheoryStatusWithResultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull statusDict) {
- @strongify(self)
- if (isSuccess) {
- NSString *statusStr = statusDict[@"body"];
- if (!statusStr && [statusStr isEqualToString:@""]) {
- ShowMsg(@"获取学员状态异常!");
- !resultBlock? : resultBlock(NO);
- return;
- }
- BOOL statusIsSignIn = [statusStr isEqualToString:@"1"];
- NSString *pxkm = RQ_USER_MANAGER.currentUser.pxjd;
- if (pxkm.length < 1) {
- pxkm = @"1";
- }
- if (([pxkm isEqualToString:@"2"] || [pxkm isEqualToString:@"3"])) {
- pxkm = @"4";
- }
-
- if (RQ_USER_MANAGER.isCykh) {
- if (![self checkCykhChooseStr]) {
- !resultBlock? : resultBlock(NO);
- return;
- } else {
- pxkm = RQ_USER_MANAGER.cykhPxkmStr;
- }
- }
-
- NSArray* array = [DB_Helper quearyTrain:RQStringIsNotEmpty(RQ_USER_MANAGER.currentUser.outId)? RQ_USER_MANAGER.currentUser.outId : @"" Subject:pxkm];
- __block NSInteger trainTime = 0;
-
- [array.rac_sequence.signal subscribeNext:^(TrainRecord *record) {
- trainTime = trainTime + record.trainTime.integerValue;
- } completed:^{
- dispatch_async(dispatch_get_main_queue(), ^{
- @strongify(self)
- if (trainTime >= 30) {
- [RQ_SHARE_FUNCTION showAlertWithTitle:@"温馨提示" message:statusIsSignIn? @"检测到上次未正常签退,请签退后再开始理论计时" : @"检测到学员已签退!本地存在异常学时,是否删除异常学时?" alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"取消" otherButtonTitles:@[statusIsSignIn? @"签退" : @"删除"] otherButtonStyles:nil showInWindow:NO completion:^(NSUInteger selectedOtherButtonIndex) {
- @strongify(self)
- !resultBlock? : resultBlock(NO);
- if (selectedOtherButtonIndex == 0) {
- if (statusIsSignIn) {
- TrainRecord *lastRecord = [array lastObject];
- /// 1.本地活体检测
- [RQ_CHECKBODY_MANAGER beginCheckBodyWithCheckNum:RQ_USER_MANAGER.ycbdFaceCount completeBlock:^(BOOL success, NSDictionary * _Nullable dic) {
- @strongify(self)
- if (success) {
- /// 2.线上活体检测
- [RQ_RemoteTheory_MANAGER edufaceTofaceWithPhotoStr:dic[@"normalImg"] loginFlagType:LoginFlagType_SignOut resultBlock:^(BOOL isSuccess) {
- @strongify(self)
- if (isSuccess) {
- /// 2.5 温州(3303)上传照片的时间是实时取服务器时间 其他地市采取从开始计时时间+累计计时时长的时间
- if ([RQ_USER_MANAGER.currentUser.city isEqualToString:@"3303"]) {
- [RQ_RemoteTheory_MANAGER getCurrentTimeWithResultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull timeDict) {
- @strongify(self)
- if (isSuccess) {
- /// 3.签退
- [RQ_RemoteTheory_MANAGER uploadEduSignOutWithArray:array resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull signOutDict) {
- @strongify(self)
- if (success) {
- [self signOutSuccessWithTrainArray:array signOutSuccess:YES uploadImageSuccess:NO completion:nil];
- NSString *timeStr = timeDict[@"body"];
- /// 4.1上传签退照片
- [RQ_RemoteTheory_MANAGER uploadEduPicWithClassidStr:lastRecord.classid timeStr:timeStr actionPhotoStr:dic[@"actionImg"] loginFlagType:LoginFlagType_SignOut resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull uploadEduPicDict) {
- @strongify(self)
- if (isSuccess) {
- NSLog(@"上传签退照片成功!");
- [self signOutSuccessWithTrainArray:array signOutSuccess:YES uploadImageSuccess:YES completion:nil];
- } else {
- NSLog(@"上传签退照片失败!");
- [self signOutSuccessWithTrainArray:array signOutSuccess:YES uploadImageSuccess:NO completion:^{
- @strongify(self)
- [self reUploadPhotoWithClassidStr:self.classIdStr timeStr:timeStr actionPhotoStr:dic[@"actionImg"] loginFlagType:LoginFlagType_SignOut];
- }];
- }
- }];
- }
- !resultBlock? : resultBlock(NO);
- }];
- } else {
- !resultBlock? : resultBlock(NO);
- }
- }];
- } else {
- /// 3.签退
- [RQ_RemoteTheory_MANAGER uploadEduSignOutWithArray:array resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull signOutDict) {
- @strongify(self)
- if (success) {
- [self signOutSuccessWithTrainArray:array signOutSuccess:YES uploadImageSuccess:NO completion:nil];
- /// 4.2上传签退照片
- [RQ_RemoteTheory_MANAGER uploadEduPicWithClassidStr:lastRecord.classid timeStr:lastRecord.endTime actionPhotoStr:dic[@"actionImg"] loginFlagType:LoginFlagType_SignOut resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull uploadEduPicDict) {
- @strongify(self)
- if (isSuccess) {
- NSLog(@"上传签退照片成功!");
- [self signOutSuccessWithTrainArray:array signOutSuccess:YES uploadImageSuccess:YES completion:nil];
- } else {
- NSLog(@"上传签退照片失败!");
- [self signOutSuccessWithTrainArray:array signOutSuccess:YES uploadImageSuccess:NO completion:^{
- @strongify(self)
- [self reUploadPhotoWithClassidStr:self.classIdStr timeStr:lastRecord.endTime actionPhotoStr:dic[@"actionImg"] loginFlagType:LoginFlagType_SignOut];
- }];
- }
- }];
- }
- !resultBlock? : resultBlock(NO);
- }];
- }
- } else {
- !resultBlock? : resultBlock(NO);
- }
- }];
- } else {
- !resultBlock? : resultBlock(NO);
- }
- }];
- } else {
- for (TrainRecord *record in array) {
- [DB_Helper deleteTrainRecord:record];
- }
- }
- }
- }];
- } else {
- if (statusIsSignIn) {
- [RQ_RemoteTheory_MANAGER uploadEduSignOutWithArray:@[] resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull signOutDict) {
- @strongify(self)
- if (isSuccess) {
- [self signOutSuccessWithTrainArray:@[] signOutSuccess:YES uploadImageSuccess:NO completion:nil];
- }
- !resultBlock? : resultBlock(isSuccess);
- }];
- } else {
- /// 1.本地活体检测
- [RQ_CHECKBODY_MANAGER beginCheckBodyWithCheckNum:RQ_USER_MANAGER.ycbdFaceCount completeBlock:^(BOOL success, NSDictionary * _Nullable dic) {
- @strongify(self)
- if (success) {
- /// 2.线上活体检测
- [RQ_RemoteTheory_MANAGER edufaceTofaceWithPhotoStr:dic[@"normalImg"] loginFlagType:LoginFlagType_SignIn resultBlock:^(BOOL isSuccess) {
- @strongify(self)
- //#warning 测试阶段-绕开人脸
- // isSuccess = true;
- if (isSuccess) {
- /// 3.获取线上时间
- [RQ_RemoteTheory_MANAGER getCurrentTimeWithResultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull timeDict) {
- @strongify(self)
- if (isSuccess) {
- // NSString *timeStr = @"2022-03-13 22:46:59";
- NSDate *date = [NSDate rq_dateWithTimestamp:timeDict[@"body"]];
- // NSDate *date = [NSDate rq_dateWithTimestamp:timeStr];
- NSInteger timeStamp = [RQ_SHARE_FUNCTION getTimeStampWithDate:date];
- NSString *timeStampStr = [NSString stringWithFormat:@"%@",[NSNumber numberWithInteger:timeStamp]];
-
- self.classIdStr = timeStampStr;
- if (self.classIdStr.length < 10) {
- /// 如果生成时间戳错误 用一个随机十位数代替
- self.classIdStr = [NSString stringWithFormat:@"%@",[NSNumber numberWithInteger:[NSString rq_randomNumberWithFrom:1647311377 to:9999999999]]];
- }
-
- NSInteger todayEndTimestamp = [RQ_SHARE_FUNCTION getTimeStampWithHour:23 andMinute:59 andDate:[NSDate rq_dateWithTimestamp:timeDict[@"body"]]];
- BOOL isShow = (todayEndTimestamp - timeStamp) < 3 * RQ_D_HOUR;
- self.marqueeLabel.hidden = !isShow;
-
-
- /// 4.签到
- [RQ_RemoteTheory_MANAGER uploadEduSignInWithClassidStr:self.classIdStr resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull signInDict) {
- if (isSuccess) {
- @strongify(self)
- NSString *timeStr = signInDict[@"body"];
- [self signInSuccessWithBeginTime:timeStr];
- /// 5.上传照片
- [RQ_RemoteTheory_MANAGER uploadEduPicWithClassidStr:self.classIdStr timeStr:timeStr actionPhotoStr:dic[@"actionImg"] loginFlagType:LoginFlagType_SignIn resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull uploadEduPicDict) {
- // @strongify(self)
- }];
-
- }
-
- !resultBlock? : resultBlock(isSuccess);
- }];
- } else {
- !resultBlock? : resultBlock(NO);
- }
- }];
- } else {
- !resultBlock? : resultBlock(NO);
- }
- }];
- } else {
- !resultBlock? : resultBlock(NO);
- }
- }];
- }
- }
- });
- }];
- } else {
- !resultBlock? : resultBlock(NO);
- }
- }];
- } else {
- !resultBlock? : resultBlock(YES);
- [self getWebTime];
- }
- }
- }];
- }
- - (void)getCurrentPXKWithComplete:(void(^)(BOOL isSuccess,NSString *pxkm))complete {
- // @weakify(self)
- ShowHUD();
- if (![Util connectedToNetWork]) {
- ShowMsg(@"请检查网络连接。");
- RemoveHUD();
- !complete? : complete(NO, nil);
- return;
- }
- NSMutableArray *arr = [NSMutableArray array];
- [arr property:RQ_USER_MANAGER.currentUser.outId forKey:@"stuOutId"];
- [arr property:RQ_USER_MANAGER.currentUser.city forKey:@"dqbh"];
-
- NSString* method = @"getStudentStatusByStuOutId";
- [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary *dict) {
- // @strongify(self)
- RemoveHUD();
- if (!dict) {
- ShowMsgFailed();
- !complete? : complete(NO, nil);
- return;
- }
- if ([dict[@"code"] isEqualToString:@"0"]) {
- !complete? : complete(YES, dict[@"body"]);
- } else {
- ShowMsg(dict[@"body"]);
- !complete? : complete(NO, nil);
- }
- }];
- }
- - (void)getWebTime {
- @weakify(self)
- ShowHUD();
- if (![Util connectedToNetWork])
- {
- ShowMsg(@"请检查网络连接。");
- RemoveHUD();
- return;
- }
-
- NSMutableArray *arr=[NSMutableArray array];
- if([@"3310" isEqualToString:RQ_USER_MANAGER.currentUser.city]){
- [arr property:RQ_USER_MANAGER.currentUser.outId forKey:@"outId"];
- }
- [arr property:RQ_USER_MANAGER.currentUser.city forKey:@"dqbh"];
-
- NSString* method = @"isUsePhone";
- [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary *dict) {
- @strongify(self)
- RemoveHUD();
- //NSLog(@"获取服务器时间--%@---->%@",arr,dict);
-
- if (!dict) {
- ShowMsgFailed();
- return;
- }
-
- if ( [dict[@"code"] isEqualToString:@"0"]) {
- myDelegate.begin_Time = dict[@"body"];
- [Tools playAudioWithString:@"操作成功,开始计时"];
-
- self.seconds = 0;
- [self.on_offBtn setTitle:@"结束计时" forState:UIControlStateNormal];
-
- myDelegate.timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timeFireMethod) userInfo:nil repeats:YES];
- myDelegate.isUseriPhone = YES;
- self.timer = myDelegate.timer;
-
- myDelegate.tPeriodVC = self;
-
- ShowMsgSuc();
- }
- else
- {
- ShowMsg(dict[@"body"]);
- [Tools playAudioWithString:dict[@"body"]];
- }
- }];
- }
- - (void)setSecondString:(NSString *)secondString {
- _secondString = secondString;
- }
- - (void)timeFireMethod {
- @weakify(self)
- self.seconds++;
- [self setSecondString:[NSString stringWithFormat:@"%d",(int)self.seconds]];
- int hour = 0;
- int min = 0;
- int second = 0;
-
- if (RQ_USER_MANAGER.isycbd == 1) {
- NSString *pxkm = RQ_USER_MANAGER.currentUser.pxjd;
- if (pxkm.length < 1) {
- pxkm = @"1";
- }
- if (([pxkm isEqualToString:@"2"] || [pxkm isEqualToString:@"3"])) {
- pxkm = @"4";
- }
- int remainder1 = [RQ_USER_MANAGER.currentUser.city isEqualToString:@"3303"]? (int)(self.seconds)%1200 : (int)(self.seconds)%780;
- if (remainder1 == 0) {
- [self.timer setFireDate:[NSDate distantFuture]];
- SCLAlertView *alert = [[SCLAlertView alloc] initWithNewWindow];
- alert.backgroundViewColor = backGroundColor;
- alert.customViewColor = RQ_MAIN_COLOR;
- [alert addButton:@"立即开始 " actionBlock:^(void) {
- dispatch_async(dispatch_get_main_queue(), ^{
- @strongify(self)
- /// 1.本地活体检测
- [RQ_CHECKBODY_MANAGER beginCheckBodyWithCheckNum:RQ_USER_MANAGER.ycbdFaceCount completeBlock:^(BOOL success, NSDictionary * _Nullable dic) {
- @strongify(self)
- if (success) {
- /// 2.线上活体检测
- [RQ_RemoteTheory_MANAGER edufaceTofaceWithPhotoStr:dic[@"normalImg"] loginFlagType:LoginFlagType_Process resultBlock:^(BOOL isSuccess) {
- @strongify(self)
- if (isSuccess) {
- /// 2.5 温州(3303)上传照片的时间是实时取服务器时间 其他地市采取从开始计时时间+累计计时时长的时间
- if ([RQ_USER_MANAGER.currentUser.city isEqualToString:@"3303"]) {
- [RQ_RemoteTheory_MANAGER getCurrentTimeWithResultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull timeDict) {
- @strongify(self)
- if (isSuccess) {
- /// 3.1上传过程照片
- NSString *timeStr = timeDict[@"body"];
- [RQ_RemoteTheory_MANAGER uploadEduPicWithClassidStr:self.classIdStr timeStr:timeStr actionPhotoStr:dic[@"actionImg"] loginFlagType:LoginFlagType_Process resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull uploadEduPicDict) {
- @strongify(self)
- if (isSuccess) {
- [RQ_SHARE_FUNCTION showAlertWithTitle:@"温馨提示" message:@"过程验证成功" alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"确定" otherButtonTitles:nil otherButtonStyles:nil showInWindow:NO completion:^(NSUInteger selectedOtherButtonIndex) {
- @strongify(self)
- [self.timer setFireDate:[NSDate distantPast]];
- }];
- } else {
- self.seconds--;
- [self setSecondString:[NSString stringWithFormat:@"%d",(int)self.seconds]];
- [self.timer setFireDate:[NSDate distantPast]];
- }
- }];
- } else {
- self.seconds--;
- [self setSecondString:[NSString stringWithFormat:@"%d",(int)self.seconds]];
- [self.timer setFireDate:[NSDate distantPast]];
- }
- }];
- } else {
- NSString *timeStr = [self getTimes:self.seconds];
- /// 3.2上传过程照片
- [RQ_RemoteTheory_MANAGER uploadEduPicWithClassidStr:self.classIdStr timeStr:timeStr actionPhotoStr:dic[@"actionImg"] loginFlagType:LoginFlagType_Process resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull uploadEduPicDict) {
- @strongify(self)
- if (isSuccess) {
- [RQ_SHARE_FUNCTION showAlertWithTitle:@"温馨提示" message:@"过程验证成功" alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"确定" otherButtonTitles:nil otherButtonStyles:nil showInWindow:NO completion:^(NSUInteger selectedOtherButtonIndex) {
- @strongify(self)
- [self.timer setFireDate:[NSDate distantPast]];
- }];
- } else {
- self.seconds--;
- [self setSecondString:[NSString stringWithFormat:@"%d",(int)self.seconds]];
- [self.timer setFireDate:[NSDate distantPast]];
- }
- }];
- }
- } else {
- self.seconds--;
- [self setSecondString:[NSString stringWithFormat:@"%d",(int)self.seconds]];
- [self.timer setFireDate:[NSDate distantPast]];
- }
- }];
- } else {
- self.seconds--;
- [self setSecondString:[NSString stringWithFormat:@"%d",(int)self.seconds]];
- [self.timer setFireDate:[NSDate distantPast]];
- }
- }];
- });
- }];
- [alert addTimerToButtonIndex:0 reverse:YES];
- [alert showNotice:@"温馨提示" subTitle:@"即将开始活体检测,请做好准备" closeButtonTitle:nil duration:5.0f];
- }
- } else {
-
- }
- int remainder;
- if (RQ_USER_MANAGER.isycbd == 1) {
- remainder = (int)self.seconds%1800;
- } else {
- remainder = (int)self.seconds%300;
- }
-
- if (remainder == 0) {
- //每5分钟保存一次,温州每30分钟保存一次
- [self saveTrain];
- }
-
- hour = (int)self.seconds / 3600;
- min = (int)self.seconds % 3600 / 60;
- second = (int)self.seconds % 3600 % 60;
- NSString *min_s;
- NSString *second_s;
- if (min<10) {
- min_s=[NSString stringWithFormat:@"0%d",min];
- }else{
- min_s=[NSString stringWithFormat:@"%d",min];
- }
- if (second<10) {
- second_s=[NSString stringWithFormat:@"0%d",second];
- }else{
- second_s=[NSString stringWithFormat:@"%d",second];
- }
-
- //凌晨重新计时 只是为了防止夜里挂学时 导致一天挂学时超过4小时做的处理 但是这样的话 学员就可以一夜挂8个小时 这样反而不好 应该取消这个 如果连续超过四个小时 判定无效 dansonmark
- /*
- NSString *time=[myDelegate.begin_Time substringWithRange:NSMakeRange(0, 10)];
- time=[NSString stringWithFormat:@"%@ 23:59:59",time];
- if ([[self getTimes:self.seconds] isEqualToString:time]) {
- [self saveTrain];
-
- //加2就不会连在一起了
- self.seconds = self.seconds+2;
- //重置开始时间
- myDelegate.begin_Time = [self getTimes:self.seconds];
- self.seconds = 0;
- }
- */
- //更新UI上的时间
- self.timeLabel.text = [NSString stringWithFormat:@"0%d:%@:%@",hour,min_s,second_s];
- }
- - (void)stopTimingWithResultBlock:(void (^)(BOOL isSuccessed))resultBlock {
- @weakify(self)
- [self.timer setFireDate:[NSDate distantFuture]];
- [self saveTrain];
- if (RQ_USER_MANAGER.isycbd == 1) {
- /// 1.本地活体检测
- [RQ_CHECKBODY_MANAGER beginCheckBodyWithCheckNum:RQ_USER_MANAGER.ycbdFaceCount completeBlock:^(BOOL success, NSDictionary * _Nullable dic) {
- @strongify(self)
- if (success) {
- /// 2.线上活体检测
- [RQ_RemoteTheory_MANAGER edufaceTofaceWithPhotoStr:dic[@"normalImg"] loginFlagType:LoginFlagType_SignOut resultBlock:^(BOOL isSuccess) {
- @strongify(self)
- if (isSuccess) {
- /// 2.5 温州(3303)上传照片的时间是实时取服务器时间 其他地市采取从开始计时时间+累计计时时长的时间
- if ([RQ_USER_MANAGER.currentUser.city isEqualToString:@"3303"]) {
- [RQ_RemoteTheory_MANAGER getCurrentTimeWithResultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull timeDict) {
- @strongify(self)
- if (isSuccess) {
- /// 4.签退
- NSString *pxkm = RQ_USER_MANAGER.currentUser.pxjd;
- if (pxkm.length < 1) {
- pxkm = @"1";
- }
- if (([pxkm isEqualToString:@"2"] || [pxkm isEqualToString:@"3"])) {
- pxkm = @"4";
- }
-
- NSArray* array = [DB_Helper quearyTrain:RQStringIsNotEmpty(RQ_USER_MANAGER.currentUser.outId)? RQ_USER_MANAGER.currentUser.outId : @"" Subject:pxkm];
- if (array.count < 1) {
- !resultBlock? : resultBlock(YES);
- ShowMsg(@"本地无学时明细!");
- return;
- }
- [RQ_RemoteTheory_MANAGER uploadEduSignOutWithArray:array resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull signOutDict) {
- @strongify(self)
- if (isSuccess) {
- !resultBlock? : resultBlock(YES);
- [self signOutSuccessWithTrainArray:array signOutSuccess:YES uploadImageSuccess:NO completion:nil];
- /// 4.1上传签退照片
- NSString *timeStr = timeDict[@"body"];
-
- [RQ_RemoteTheory_MANAGER uploadEduPicWithClassidStr:self.classIdStr timeStr:timeStr actionPhotoStr:dic[@"actionImg"] loginFlagType:LoginFlagType_SignOut resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull uploadEduPicDict) {
- @strongify(self)
- if (isSuccess) {
- NSLog(@"上传签退照片成功!");
- [self signOutSuccessWithTrainArray:array signOutSuccess:YES uploadImageSuccess:YES completion:nil];
- } else {
- NSLog(@"上传签退照片失败!");
- [self signOutSuccessWithTrainArray:array signOutSuccess:YES uploadImageSuccess:NO completion:^{
- @strongify(self)
- [self reUploadPhotoWithClassidStr:self.classIdStr timeStr:timeStr actionPhotoStr:dic[@"actionImg"] loginFlagType:LoginFlagType_SignOut];
- }];
- }
- }];
- } else {
- !resultBlock? : resultBlock(NO);
- [self.timer setFireDate:[NSDate distantPast]];
- }
- }];
- } else {
- !resultBlock? : resultBlock(NO);
- [self.timer setFireDate:[NSDate distantPast]];
- }
- }];
- } else {
- /// 3.签退
- NSString *pxkm = RQ_USER_MANAGER.currentUser.pxjd;
- if (pxkm.length < 1) {
- pxkm = @"1";
- }
- if (([pxkm isEqualToString:@"2"] || [pxkm isEqualToString:@"3"])) {
- pxkm = @"4";
- }
- if (RQ_USER_MANAGER.isCykh) {
- if (![self checkCykhChooseStr]) {
- !resultBlock? : resultBlock(YES);
- return;
- } else {
- pxkm = RQ_USER_MANAGER.cykhPxkmStr;
- }
- }
- NSArray* array = [DB_Helper quearyTrain:RQStringIsNotEmpty(RQ_USER_MANAGER.currentUser.outId)? RQ_USER_MANAGER.currentUser.outId : @"" Subject:pxkm];
- if (array.count < 1) {
- !resultBlock? : resultBlock(YES);
- ShowMsg(@"本地无学时明细!");
- return;
- }
- [RQ_RemoteTheory_MANAGER uploadEduSignOutWithArray:array resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull signOutDict) {
- @strongify(self)
- if (isSuccess) {
- !resultBlock? : resultBlock(YES);
- [self signOutSuccessWithTrainArray:array signOutSuccess:YES uploadImageSuccess:NO completion:nil];
- /// 4.2上传签退照片
- NSString *timeStr = [self getTimes:self.seconds];
- [RQ_RemoteTheory_MANAGER uploadEduPicWithClassidStr:self.classIdStr timeStr:timeStr actionPhotoStr:dic[@"actionImg"] loginFlagType:LoginFlagType_SignOut resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull uploadEduPicDict) {
- @strongify(self)
- if (isSuccess) {
- NSLog(@"上传签退照片成功!");
- [self signOutSuccessWithTrainArray:array signOutSuccess:YES uploadImageSuccess:YES completion:nil];
- } else {
- NSLog(@"上传签退照片失败!");
- [self signOutSuccessWithTrainArray:array signOutSuccess:YES uploadImageSuccess:NO completion:^{
- [self reUploadPhotoWithClassidStr:self.classIdStr timeStr:timeStr actionPhotoStr:dic[@"actionImg"] loginFlagType:LoginFlagType_SignOut];
- }];
- }
- }];
- } else {
- !resultBlock? : resultBlock(NO);
- [self.timer setFireDate:[NSDate distantPast]];
- }
- }];
- }
- } else {
- !resultBlock? : resultBlock(NO);
- [self.timer setFireDate:[NSDate distantPast]];
- }
- }];
- } else {
- !resultBlock? : resultBlock(NO);
- [self.timer setFireDate:[NSDate distantPast]];
- }
- }];
- } else {
- !resultBlock? : resultBlock(YES);
- [self setSecondString:@"0"];
-
- [self.timer setFireDate:[NSDate distantFuture]];
- [self.timer invalidate];
- self.timer = nil;
- myDelegate.timer = nil;
- myDelegate.tPeriodVC = nil;
- myDelegate.isTrain = NO;
- self.timeLabel.text = @"00:00:00";
- // if (self.seconds < 60) {
- // ShowMsg(@"学时未满一分钟不统计");
- // return;
- // }
- [RQ_SHARE_FUNCTION showAlertWithTitle:@"温馨提示" message:@"结束计时,是否上传学时?" alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"暂不上传" otherButtonTitles:@[@"确定"] otherButtonStyles:nil showInWindow:NO completion:^(NSUInteger selectedOtherButtonIndex) {
- @strongify(self)
- if (selectedOtherButtonIndex == 0) {
- [self upLoadTrainRecord];
- }else if (selectedOtherButtonIndex == NSNotFound){
- ShowMsg(@"学时已保存在本地");
- }
- }];
- }
- }
- -(void)saveTrain {
- if (!self.formatter) {
- self.formatter = [NSDateFormatter rq_defaultDateFormatter];
- }
- TrainRecord *train = [[TrainRecord alloc]init];
-
- train.studentId = RQStringIsNotEmpty(RQ_USER_MANAGER.currentUser.outId)? RQ_USER_MANAGER.currentUser.outId : @"";
- train.beginTime = myDelegate.begin_Time;
-
- NSDate *date = [self.formatter dateFromString:myDelegate.begin_Time];
- date = [date dateByAddingTimeInterval:self.seconds];
- train.state = @"0";
- train.endTime=[self.formatter stringFromDate:date];
- NSInteger mins = self.seconds / 60;
- train.trainTime = [NSString stringWithFormat:@"%d",(int)mins];
- train.classid = (self.classIdStr && ![self.classIdStr isEqualToString:@""])? self.classIdStr : @"0";
- [DB_Helper saveTrain:train];
- }
- - (NSString *)getTimes:(int)second {
- if (!self.formatter) {
- self.formatter=[[NSDateFormatter alloc]init];
- [self.formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
- }
-
- NSString *beginTimeStr = myDelegate.begin_Time;
- [self.formatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]];
- NSDate *beginDate = [self.formatter dateFromString:beginTimeStr];
- NSDate *newDate = [NSDate dateWithTimeInterval:second sinceDate:beginDate];
- NSString *nowString = [self.formatter stringFromDate:newDate];
- return nowString;
- }
- - (void)upLoadTrainRecord{
- NSString *pxkm = RQ_USER_MANAGER.currentUser.pxjd;
-
- // NSString *crDate = RQ_USER_MANAGER.currentUser.crDate;
- // if (crDate.length > 10) {
- // crDate = [crDate substringToIndex:7];
- // }
- // NSArray *dateArray = [crDate componentsSeparatedByString:@"-"];
- // if ([[dateArray firstObject] integerValue] < 2016) {
- // pxkm = @"1";
- // }
- // if ([[dateArray firstObject] integerValue] == 2016) {
- //
- // if ([[dateArray lastObject] integerValue] < 11) {
- // pxkm = @"1";
- // }
- // }
-
- if (pxkm.length < 1) {
- pxkm = @"1";
- }
-
- /// 理论计时类型一地市编号:3501,3503 (福州,莆田;在科目二,科目三可以进行科目四的理论计时)
- if ([RQ_SHARE_FUNCTION.theoryOfTimingTypeOneCityCodeArr containsObject:RQ_USER_MANAGER.currentUser.city] && ([pxkm isEqualToString:@"2"] || [pxkm isEqualToString:@"3"])) {
- pxkm = @"4";
- }
- /// 理论计时类型二地市编号:null (暂无地市;在科目二可以进行科目四的理论计时)
- else if ([RQ_SHARE_FUNCTION.theoryOfTimingTypeTwoCityCodeArr containsObject:RQ_USER_MANAGER.currentUser.city] && [pxkm isEqualToString:@"2"]) {
- pxkm = @"4";
- }
- /// 理论计时类型三地市编号:3502 (厦门;在科目三可以进行科目四的理论计时)
- else if ([RQ_SHARE_FUNCTION.theoryOfTimingTypeThreeCityCodeArr containsObject:RQ_USER_MANAGER.currentUser.city] && [pxkm isEqualToString:@"3"]) {
- pxkm = @"4";
- }
- /// 新增地市 (新增地市;默认在科目二,科目三可以进行科目四的理论计时)
- else if (![RQ_SHARE_FUNCTION.theoryOfTimingTypeOneCityCodeArr containsObject:RQ_USER_MANAGER.currentUser.city] && ![RQ_SHARE_FUNCTION.theoryOfTimingTypeTwoCityCodeArr containsObject:RQ_USER_MANAGER.currentUser.city] && ![RQ_SHARE_FUNCTION.theoryOfTimingTypeThreeCityCodeArr containsObject:RQ_USER_MANAGER.currentUser.city] && ([pxkm isEqualToString:@"2"] || [pxkm isEqualToString:@"3"])) {
- pxkm = @"4";
- }
-
- if (RQ_USER_MANAGER.isCykh) {
- if (![self checkCykhChooseStr]) {
- return;
- } else {
- pxkm = RQ_USER_MANAGER.cykhPxkmStr;
- }
- }
-
- NSArray* array = [DB_Helper quearyTrain:RQStringIsNotEmpty(RQ_USER_MANAGER.currentUser.outId)? RQ_USER_MANAGER.currentUser.outId : @"" Subject:pxkm];
- if (array.count < 1) {
- ShowMsg(@"本地无学时明细!");
- return;
- }
-
- //这里是对分段上传学时做的处理 如果学时上传有问题 查看这里
- [self uploadMoreTrainRecordWithArray:array];
- }
- - (void)uploadMoreTrainRecordWithArray:(NSArray *)trainArray
- {
- ShowHUD();
- if (![Util connectedToNetWork]) {
- showMsgUnconnect();
- return;
- }
-
- NSString* str = @"";
- for (TrainRecord *record in trainArray) {
-
- str = [str stringByAppendingString:[NSString stringWithFormat:@"%@,%@,%@,%@;",record.studentId,record.beginTime,record.endTime,record.trainTime]];
- }
-
- TrainRecord *record = [trainArray firstObject];
- /// 理论计时类型一地市编号:3501,3503 (福州,莆田;在科目二,科目三可以进行科目四的理论计时)
- if ([RQ_SHARE_FUNCTION.theoryOfTimingTypeOneCityCodeArr containsObject:RQ_USER_MANAGER.currentUser.city] && ([record.subject isEqualToString:@"2"] || [record.subject isEqualToString:@"3"])) {
- record.subject = @"4";
- }
- /// 理论计时类型二地市编号:null (暂无地市;在科目二可以进行科目四的理论计时)
- else if ([RQ_SHARE_FUNCTION.theoryOfTimingTypeTwoCityCodeArr containsObject:RQ_USER_MANAGER.currentUser.city] && [record.subject isEqualToString:@"2"]) {
- record.subject = @"4";
- }
- /// 理论计时类型三地市编号:3502 (厦门;在科目三可以进行科目四的理论计时)
- else if ([RQ_SHARE_FUNCTION.theoryOfTimingTypeThreeCityCodeArr containsObject:RQ_USER_MANAGER.currentUser.city] && [record.subject isEqualToString:@"3"]) {
- record.subject = @"4";
- }
- /// 新增地市 (新增地市;默认在科目二,科目三可以进行科目四的理论计时)
- else if (![RQ_SHARE_FUNCTION.theoryOfTimingTypeOneCityCodeArr containsObject:RQ_USER_MANAGER.currentUser.city] && ![RQ_SHARE_FUNCTION.theoryOfTimingTypeTwoCityCodeArr containsObject:RQ_USER_MANAGER.currentUser.city] && ![RQ_SHARE_FUNCTION.theoryOfTimingTypeThreeCityCodeArr containsObject:RQ_USER_MANAGER.currentUser.city] && ([record.subject isEqualToString:@"2"] || [record.subject isEqualToString:@"3"])) {
- record.subject = @"4";
- }
- NSMutableArray *arr = [NSMutableArray array];
- [arr addObject:[NSDictionary dictionaryWithObjectsAndKeys:@"ios",@"trainType", nil]];
- [arr addObject:[NSDictionary dictionaryWithObjectsAndKeys:[DES3Util encrypt:str ],@"trainRecord", nil]];
- [arr addObject:[NSDictionary dictionaryWithObjectsAndKeys:record.subject,@"pxkm", nil]];
-
-
- NSString* method = @"uploadMoreTrainRecord";
-
- [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary *dict) {
-
- RemoveHUD();
- //NSLog(@"---------><>%@----><>%@",arr,dict);
-
- if (!dict) {
- ShowMsg(@"操作失败");
- return;
- }
- if ( [dict[@"code"] isEqualToString:@"1"]) {
- ShowMsg(dict[@"body"]);
- return;
- }
- if ( [dict[@"code"] isEqualToString:@"0"]) {
- for (TrainRecord *record in trainArray) {
-
- [DB_Helper updateTrainState:record];
- }
- [RQ_SHARE_FUNCTION showAlertWithTitle:@"温馨提示" message:@"上传学时成功!" alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"确定" otherButtonTitles:nil otherButtonStyles:nil showInWindow:NO completion:nil];
- }
- }];
- }
- #pragma mark btn
- - (void)btnClick:(UIButton *)sender {
- UIButton *btn = sender;
- @weakify(self, btn)
- if (btn.enabled) {
- btn.enabled = NO;
- }
-
- if (myDelegate.isUseriPhone) {
- //点击事件 如果已经开始计时 调用里边的内容
- [self stopTimingWithResultBlock:^(BOOL isSuccessed) {
- @strongify(self, btn)
- btn.enabled = YES;
- if (isSuccessed) {
- [self.on_offBtn setTitle:@"开始计时" forState:UIControlStateNormal];
- myDelegate.isUseriPhone = NO;
- }
- }];
-
- }else{
-
- if (myDelegate.timer) {
- ShowMsg(@"请先关闭其他计时");
- return;
- }
- [self startTimingWithResultBlock:^(BOOL isSuccess) {
- @strongify(btn)
- btn.enabled = YES;
- }];
- }
- }
- #pragma mark - 温州远程理论
- //远程理论签到成功
- - (void)signInSuccessWithBeginTime:(NSString *)beginTime {
- myDelegate.begin_Time = beginTime;
- [Tools playAudioWithString:@"操作成功,开始计时"];
- self.seconds = 0;
- [self.on_offBtn setTitle:@"结束计时" forState:UIControlStateNormal];
- myDelegate.timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timeFireMethod) userInfo:nil repeats:YES];
- myDelegate.isUseriPhone = YES;
- self.timer = myDelegate.timer;
- myDelegate.tPeriodVC = self;
- ShowMsgSuc();
-
- [RQ_COMMON_MANAGER keepIdleTimerDisabledisOpen:YES];
-
- if ([RQ_USER_MANAGER.currentUser.city isEqualToString:@"3501"]) {
- [RQ_ALERTVIEW_MANAGER showAlertWithTitle:@"温馨提示" message: @"福州培训时间 \n 课堂时间:07:00---22:00 \n 模拟时间:05:00---23:00 \n 实操:05:00---23:00 \n 远程:05:00--23:59:59 \n 请学员注意!避免非培训时间导致学时无效。" confirmTitle:@"确认" confirmAction:^(__kindof QMUIDialogViewController * _Nonnull dialogViewController) {
-
- }];
- }
- }
- //远程理论签退成功
- - (void)signOutSuccessWithTrainArray:(NSArray *)trainArray signOutSuccess:(BOOL)signOutSuccess uploadImageSuccess:(BOOL)uploadImageSuccess completion:(void (^)(void))completion {
- for (TrainRecord *record in trainArray) {
- [DB_Helper updateTrainState:record];
- }
- if (trainArray.count > 0) {
- if (signOutSuccess) {
- if (![_secondString isEqualToString:@"0"]) {
- [self setSecondString:@"0"];
- }
- if (self.timer.isValid) {
- [self.timer invalidate];
- }
- if (self.timer) {
- self.timer = nil;
- }
- if (myDelegate.timer) {
- myDelegate.timer = nil;
- }
- if (myDelegate.tPeriodVC) {
- myDelegate.tPeriodVC = nil;
- }
- if (myDelegate.isTrain) {
- myDelegate.isTrain = NO;
- }
- if (![self.timeLabel.text isEqualToString:@"00:00:00"]) {
- self.timeLabel.text = @"00:00:00";
- }
- }
-
- if (signOutSuccess && uploadImageSuccess) {
- [RQ_SHARE_FUNCTION showAlertWithTitle:@"温馨提示" message:@"签退成功!" alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"确定" otherButtonTitles:nil otherButtonStyles:nil showInWindow:NO completion:nil];
- } else if (signOutSuccess && !uploadImageSuccess && completion) {
- [RQ_SHARE_FUNCTION showAlertWithTitle:@"温馨提示" message:@"上传照片失败!" alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"重新上传" otherButtonTitles:nil otherButtonStyles:nil showInWindow:NO completion:^(NSUInteger selectedOtherButtonIndex) {
- completion();
- }];
- }
-
-
- } else {
- // 强制签退后再去调签到
- [self startTimingWithResultBlock:nil];
- }
- [RQ_COMMON_MANAGER keepIdleTimerDisabledisOpen:NO];
- }
- - (void)reUploadPhotoWithClassidStr:(NSString *)classidStr timeStr:(NSString *)timeStr actionPhotoStr:(NSString *)actionPhotoStr loginFlagType:(LoginFlagType)loginFlagType {
- __block BOOL reUploadSuccess = YES;
- __block BOOL isUploading = NO;
- int i = 0;
- do {
- if (i == 0) {
- if (!isUploading) {
- isUploading = YES;
- [RQ_RemoteTheory_MANAGER uploadEduPicWithClassidStr:classidStr timeStr:timeStr actionPhotoStr:actionPhotoStr loginFlagType:loginFlagType resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull uploadEduPicDict) {
- if (isSuccess) {
- ShowMsg(@"重新上传照片成功!");
- reUploadSuccess = YES;
- } else {
- reUploadSuccess = NO;
- }
- isUploading = NO;
- }];
- }
- } else {
- if (!isUploading) {
- isUploading = YES;
- [RQ_SHARE_FUNCTION showAlertWithTitle:@"温馨提示" message:@"上传照片失败!" alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"重新上传" otherButtonTitles:nil otherButtonStyles:nil showInWindow:NO completion:^(NSUInteger selectedOtherButtonIndex) {
- [RQ_RemoteTheory_MANAGER uploadEduPicWithClassidStr:classidStr timeStr:timeStr actionPhotoStr:actionPhotoStr loginFlagType:loginFlagType resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull uploadEduPicDict) {
- if (isSuccess) {
- ShowMsg(@"重新上传照片成功!");
- reUploadSuccess = YES;
- } else {
- reUploadSuccess = NO;
- }
- isUploading = NO;
- }];
- }];
- }
- }
- i ++;
- } while (reUploadSuccess == NO);
- }
- #pragma mark - LazyLoad
- - (QMUIMarqueeLabel *)marqueeLabel {
- if (!_marqueeLabel) {
- _marqueeLabel = [[QMUIMarqueeLabel alloc] qmui_initWithFont:[UIFont qmui_systemFontOfSize:17 weight:QMUIFontWeightBold italic:YES] textColor:UIColor.redColor];
- @weakify(_marqueeLabel)
- _marqueeLabel.text = @"在深夜时间,进行理论计时,记得在十二点前签退!否则,会丢失部分学时!!!";
- _marqueeLabel.hidden = YES;
- [RACObserve(_marqueeLabel, hidden) subscribeNext:^(id _Nullable x) {
- @strongify(_marqueeLabel)
- if (_marqueeLabel.hidden) {
- [_marqueeLabel requestToStopAnimation];
- } else {
- [_marqueeLabel requestToStartAnimation];
- }
- }];
- }
- return _marqueeLabel;
- }
- - (UIView *)adView {
- if (!_adView) {
- _adView = [[UIView alloc] initWithFrame:CGRectMake(25, (kSize.height - kNavOffSet - kSafeAreaBottomHeight) - 60, kSize.width - 50, (kSize.width - 50) / (640/100.0))];
- _adView.layer.cornerRadius = 5;
- _adView.clipsToBounds = YES;
- }
- return _adView;
- }
- - (QMUIPopupMenuView *)popupAtBarButtonItem {
- if (!_popupAtBarButtonItem) {
- @weakify(self)
- _popupAtBarButtonItem = [[QMUIPopupMenuView alloc] init];
- _popupAtBarButtonItem.automaticallyHidesWhenUserTap = YES;// 点击空白地方消失浮层
- _popupAtBarButtonItem.maximumWidth = RQ_SCREEN_WIDTH / 2.f;
- _popupAtBarButtonItem.shouldShowItemSeparator = YES;
- _popupAtBarButtonItem.tintColor = RQ_MAIN_COLOR;
- _popupAtBarButtonItem.items = @[[QMUIPopupMenuItem itemWithImage:nil title:@"从业科目一" handler:^(__kindof QMUIPopupMenuItem * _Nonnull aItem, __kindof UIControl<QMUIPopupMenuItemViewProtocol> * _Nonnull aItemView, NSInteger section, NSInteger index) {
- @strongify(self)
- self.rightBarButtonItem.title = aItem.title;
- RQ_USER_MANAGER.cykhPxkmStr = @"5";
- [aItem.menuView hideWithAnimated:YES];
- }],
- [QMUIPopupMenuItem itemWithImage:nil title:@"从业科目二" handler:^(__kindof QMUIPopupMenuItem * _Nonnull aItem, __kindof UIControl<QMUIPopupMenuItemViewProtocol> * _Nonnull aItemView, NSInteger section, NSInteger index) {
- @strongify(self)
- self.rightBarButtonItem.title = aItem.title;
- RQ_USER_MANAGER.cykhPxkmStr = @"6";
- [aItem.menuView hideWithAnimated:YES];
- }],
- [QMUIPopupMenuItem itemWithImage:nil title:@"从业科目四" handler:^(__kindof QMUIPopupMenuItem * _Nonnull aItem, __kindof UIControl<QMUIPopupMenuItemViewProtocol> * _Nonnull aItemView, NSInteger section, NSInteger index) {
- @strongify(self)
- self.rightBarButtonItem.title = aItem.title;
- RQ_USER_MANAGER.cykhPxkmStr = @"7";
- [aItem.menuView hideWithAnimated:YES];
- }],
- [QMUIPopupMenuItem itemWithImage:nil title:@"从业考核" handler:^(__kindof QMUIPopupMenuItem * _Nonnull aItem, __kindof UIControl<QMUIPopupMenuItemViewProtocol> * _Nonnull aItemView, NSInteger section, NSInteger index) {
- @strongify(self)
- self.rightBarButtonItem.title = aItem.title;
- RQ_USER_MANAGER.cykhPxkmStr = @"8";
- [aItem.menuView hideWithAnimated:YES];
- }]];
- }
- return _popupAtBarButtonItem;
- }
- - (UIBarButtonItem *)rightBarButtonItem {
- if (!_rightBarButtonItem) {
- _rightBarButtonItem = [UIBarButtonItem rq_systemItemWithTitle:RQStringIsEmpty(RQ_USER_MANAGER.cykhPxkmStr)? @"从业培训" : RQ_USER_MANAGER.cykhPxkmStr titleColor:RQ_MAIN_COLOR imageName:nil target:self selector:@selector(handleRightBarButtonItemEvent) textType:YES];
- @weakify(_rightBarButtonItem)
- [RACObserve(myDelegate, isUseriPhone) subscribeNext:^(id _Nullable x) {
- @strongify(_rightBarButtonItem)
- if (myDelegate.isUseriPhone) {
- _rightBarButtonItem.action = nil;
- } else {
- _rightBarButtonItem.action = @selector(handleRightBarButtonItemEvent);
- }
- }];
- }
- return _rightBarButtonItem;
- }
- - (void)handleRightBarButtonItemEvent {
- if (self.popupAtBarButtonItem.isShowing) {
- [self.popupAtBarButtonItem hideWithAnimated:YES];
- } else {
- // 相对于右上角的按钮布局
- self.popupAtBarButtonItem.sourceBarItem = self.navigationItem.rightBarButtonItem;
- [self.popupAtBarButtonItem showWithAnimated:YES];
- }
- }
- - (BOOL)checkCykhChooseStr {
- @weakify(self)
- if (RQStringIsNotEmpty(RQ_USER_MANAGER.cykhPxkmStr)) {
- return YES;
- } else {
- [NSObject rq_showAlertViewWithTitle:@"温馨提示" message:@"请选择从业计时类型" confirmTitle:@"确定" cancelTitle:@"取消" confirmAction:^{
- @strongify(self)
- [self handleRightBarButtonItemEvent];
- } cancelAction:nil];
- return NO;
- }
- }
- @end
|