123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755 |
- //
- // TheoryVC.m
- // jiaPei
- //
- // Created by EchoShacolee on 2017/7/5.
- // Copyright © 2017年 JCZ. All rights reserved.
- //
- #define dingColor [UIColor colorWithRed:236/255.0 green:190/255.0 blue:44/255.0 alpha:1]
- #import "TheoryVC.h"
- #import "ScanVC.h"
- #import "ProgressBarView.h"
- #import <BaiduMapAPI_Map/BMKMapComponent.h>//引入地图功能所有的头文件
- #import <BaiduMapAPI_Search/BMKSearchComponent.h>//引入检索功能所有的头文件
- #import <BaiduMapAPI_Location/BMKLocationComponent.h>//引入定位功能所有的头文件
- @interface TheoryVC ()<BMKMapViewDelegate,BMKLocationServiceDelegate,BMKGeoCodeSearchDelegate,UITableViewDelegate,UITableViewDataSource,UIAlertViewDelegate>
- {
- BMKLocationService *_locService;
- BMKMapView *_mapView;
- BMKGeoCodeSearch *_searcher;
- UIButton *loctionBtn;
-
-
- UILabel *addressLabel,*detailAddressLabel;
- UIButton *on_offBtn;
- UITableView *mainTableView;
-
- //学习进度
- UITableView *learntableView;
- ProgressBarView *timeProgressView, *learnProgressView;
- NSArray *learnTimeArray;
-
-
- NSArray *poiInfos;
- NSArray *coachArray;
- CLLocationCoordinate2D myLocation;
- BOOL isPractice;
- BOOL SP_IS_MNQisTure;
- }
- @end
- @implementation TheoryVC
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.title = @"理论计时";
- self.view.backgroundColor = backGroundColor;
- [self configNavigationBar];
-
- CGFloat x, y, w, h;
- x = 20;
- y = 10;
- w = (kSize.width - 40)/2.0;
- h = 60;
-
- NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
- [formatter setDateFormat:@"yyyy.MM.dd-HH:mm-EEEE"];
- NSString *dateString = [formatter stringFromDate:[NSDate date]];
- //NSLog(@"dateString---->%@",dateString);
- NSArray *dateArray = [NSArray arrayWithObjects:@"暂无",@"暂无",@"暂无", nil];
-
- if (dateString.length > 0) {
- if ([dateString containsString:@"-"]) {
- dateArray = [dateString componentsSeparatedByString:@"-"];
- }
- }
-
- UILabel *label = [[UILabel alloc] setxywh];
- [label setText:[NSString stringWithFormat:@"%@:%@",[dateArray lastObject],[dateArray firstObject]] Font:FontTitle TextColor:contentTextColor Alignment:NSTextAlignmentLeft];
- [self.view addSubview:label];
-
- x += w;
- label = [[UILabel alloc] setxywh];
- [label setText:[NSString stringWithFormat:@"当前时间: %@",dateArray[1]] Font:FontTitle TextColor:contentTextColor Alignment:NSTextAlignmentLeft];
- [self.view addSubview:label];
-
- x = 20;
- y += h;
- w = kSize.width - 40;
- h = 100;
-
- UIView *mapBar = [[UIView alloc] setxywh];
- [mapBar borderColor:lineColor width:2 cornorRadios:0];
- mapBar.clipsToBounds = YES;;
- [self.view addSubview:mapBar];
-
- x = y = 0;
- w = 110;
- h = 122;
- //创建地图
- _mapView = [[BMKMapView alloc]setxywh];
- [mapBar addSubview:_mapView];
- [_mapView addViewWithRect:CGRectMake(x + w, y, 2, h)];
-
- _mapView.mapType = BMKMapTypeStandard;
- //定位功能
- _locService = [[BMKLocationService alloc]init];
- _locService.distanceFilter = 1;
- _locService.delegate = self;
- [_locService startUserLocationService];
-
- //这个设置重复是为了消除一个bug 记得
- _mapView.showsUserLocation = NO;
- _mapView.userTrackingMode = BMKUserTrackingModeNone;
- _mapView.zoomLevel = 16;
- _mapView.showsUserLocation = YES;
-
- BMKLocationViewDisplayParam *displayParam = [[BMKLocationViewDisplayParam alloc]init];
- displayParam.isRotateAngleValid = true;//跟随态旋转角度是否生效
- displayParam.isAccuracyCircleShow = false;//精度圈是否显示
- displayParam.locationViewOffsetX = 0;//定位偏移量(经度)
- displayParam.locationViewOffsetY = 0;//定位偏移量(纬度)
- [_mapView updateLocationViewWithParam:displayParam];
-
-
- x += w + 5;
- w = kSize.width - 40 - 115;
- h = 25;
- label = [[UILabel alloc] setxywh];
- [label setText:@"正在定位..." Font:FontTitle TextColor:titleColor Alignment:NSTextAlignmentLeft];
- [mapBar addSubview:label];
- addressLabel = label;
-
- y += h;
- h = 50;
- label = [[UILabel alloc] setxywh];
- [label setText:@"" Font:FontTitle TextColor:contentTextColor Alignment:NSTextAlignmentLeft];
- label.numberOfLines = 0;
- [mapBar addSubview:label];
- detailAddressLabel = label;
-
- y += h;
- h = 20;
- UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
- btn.frame = CGRectMake(x, y, w, h);
- [btn setTitle:@"地点微调" textColor:[UIColor blueColor] font:FontTitle fotState:UIControlStateNormal];
- [btn setTitle:@"取消微调" forState:UIControlStateSelected];
- btn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
- [btn.titleLabel setTextAlignment:NSTextAlignmentLeft];
- [btn target:self tag:1];
- [mapBar addSubview:btn];
- loctionBtn = btn;
-
-
- for (NSDictionary * dic in defUser.userDict[@"params"]) {
- if ([dic[@"KEY"] isEqualToString:@"SP_IS_MNQ"]) {
- if ([dic[@"VALUE"] isEqualToString:@"1"]) {
- SP_IS_MNQisTure = YES;
- }else {
- SP_IS_MNQisTure = NO;
- }
- }
- }
-
- y = mapBar.y +mapBar.height + 40;
- x = 20;
- w = kSize.width - 40.0;
- h = 40;
- btn = [UIButton buttonWithType:UIButtonTypeCustom];
- btn.frame = CGRectMake(x, y, w, h);
- [btn setTitle:@"开始计时" textColor:lineColor font:20 fotState:UIControlStateNormal];
- if (!SP_IS_MNQisTure) {
- [btn setTitle:@"结束计时" textColor:dingColor font:20 fotState:UIControlStateSelected];
- }else{
- [btn setTitle:@"开始计时" textColor:dingColor font:20 fotState:UIControlStateSelected];
- }
- [btn borderColor:lineColor width:1 cornorRadios:5];
- [btn target:self tag:2];
- btn.userInteractionEnabled = NO;
- [self.view addSubview:btn];
- on_offBtn = btn;
-
- if (!SP_IS_MNQisTure) {
- //教练手机模拟计时
- NSString *noticeString = @"理论计时注意事项:\n模拟计时每天最多计时4个小时,若当日学习时间累计超过4小时,将按4小时计算。单次一次性产生4小时及以上学时的,系统将判断其为无效学时,自动清零,请知悉。";
- y += h + 30;
- h = [noticeString heightForWid:w Font:Font17] + 20;
- label = [[UILabel alloc] setxywh];
- [label setText:noticeString Font:Font17 TextColor:[UIColor orangeColor] Alignment:NSTextAlignmentLeft];
- label.numberOfLines = 0;
- [self.view addSubview:label];
- }else{
- //模拟器模拟计时 训练项目进度。 学时进度。 训练记录。
- if (myDelegate.isLogin) {
- [self getUserLearnRecord];
- }
- }
-
-
- y = mapBar.y +mapBar.height;
- h = kSize.height - y - kNavOffSet;
- mainTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, y, kSize.width, h) style:UITableViewStylePlain];
- mainTableView.delegate = self;
- mainTableView.dataSource = self;
- [self.view addSubview:mainTableView];
- mainTableView.hidden = YES;
-
- isPractice = NO;
- [self getStuSignFlag];
- }
- - (void)initLearnProgressWithDic:(NSDictionary *)dic {
-
- CGFloat y = on_offBtn.y + on_offBtn.height + 20;
-
- if (!timeProgressView) {
- timeProgressView = [[ProgressBarView alloc] initWithFrame:CGRectMake(0, y, kSize.width, 50)];
- timeProgressView.titleString = @"学时进度:";
- [self.view addSubview:timeProgressView];
- }
- timeProgressView.allNeedTime = [dic[@"mnq_all_time"] integerValue];
- timeProgressView.finishTime = [dic[@"mnq_time"] integerValue];
-
- y += 60;
- if (!learnProgressView) {
- learnProgressView = [[ProgressBarView alloc] initWithFrame:CGRectMake(0, y, kSize.width, 25)];
- learnProgressView.titleString = @"训练进度:";
- [self.view addSubview:learnProgressView];
- }
- learnProgressView.allCount = [dic[@"mnq_total"] integerValue];
- learnProgressView.finishCount = [dic[@"mnq_num"] integerValue];
-
-
- y += 40;
- if (!learntableView) {
- learnTimeArray = [NSArray array];
-
- learntableView = [[UITableView alloc] initWithFrame:CGRectMake(0, y, kSize.width, kSize.height - y - kNavOffSet) style:UITableViewStylePlain];
- learntableView.backgroundColor = backGroundColor;
- learntableView.delegate = self;
- learntableView.dataSource = self;
- [self.view addSubview:learntableView];
-
- UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, kSize.width, 30)];
- label.backgroundColor = backGroundColor;
- [label setText:@"学时记录" Font:FontTitle TextColor:titleColor Alignment:NSTextAlignmentCenter];
- learntableView.tableHeaderView = label;
- }
- if ([dic[@"mnq_list"] isKindOfClass:[NSArray class]]) {
- learnTimeArray = dic[@"mnq_list"];
- }else {
- learnTimeArray = [NSArray array];
- }
-
- [learntableView reloadData];
-
- [self.view bringSubviewToFront:mainTableView];
- }
- -(void)viewWillAppear:(BOOL)animated
- {
- [super viewWillAppear:animated];
- [_mapView viewWillAppear];
- _mapView.delegate = self; // 此处记得不用的时候需要置nil,否则影响内存的释放
- }
- -(void)viewWillDisappear:(BOOL)animated
- {
- [super viewWillDisappear:animated];
- [_locService stopUserLocationService];
- [_mapView viewWillDisappear];
- _mapView.delegate = nil; // 不用时,置nil
- _searcher.delegate = nil;
- _locService.delegate = nil;
- }
- -(void)btnClick:(UIButton *)sender
- {
- if (sender.tag == 1) {
- //微调
- sender.selected = !sender.selected;
-
- if (sender.selected) {
- mainTableView.hidden = NO;
- [mainTableView reloadData];
- }else{
- mainTableView.hidden = YES;
- }
- }
-
- if (sender.tag == 2) {
-
- if (sender.selected) {
- //结束计时
-
- if (!SP_IS_MNQisTure) {
- [self uploadMnSignOut];
- }else{
-
- if (myDelegate.timer) {
- ShowMsg(@"请先关闭其他计时");
- return;
- }
-
- if (![Util connectedToNetWork]) {
- return;
- }
- NSMutableArray *arr=[NSMutableArray array];
- [arr addPro:@"stuId" Value:defUser.userDict[@"outId"]];
- [arr addPro:@"dqbh" Value:defUser.userDict[@"city"]];
-
- NSString* method = @"getStuSignFlag";
- [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
-
- if (!root) {
- ShowMsg(@"网络错误,请稍后尝试");
- return;
- }
- if ([root[@"code"] isEqualToString:@"1"]) {
- ShowMsg(root[@"body"]);
- return;
- }
-
- //这里接收服务器返回状态 当前训练培训训练状态 0 实操签退或模拟签退 1 实操签到 2 模拟签到 3 隔日训练
- switch ([[root[@"body"] objectForKey:@"status"] integerValue]) {
- case 0:
- //开始计时
-
- isPractice = NO;
-
- [self showAlertForBeginOrEndPeriodWithString:@"请扫描设备二维码开始计时"];
- on_offBtn.selected = NO;
- break;
- case 1:
- //实操计时中
- isPractice = YES;
- ShowMsg(@"请先关闭实操计时");
- break;
- case 2:
- //模拟计时中
- ShowMsg(@"正在模拟计时");
- break;
- case 3:
- //隔日签到
-
- break;
- default:
- break;
- }
- }];
- }
- }else{
- //开始计时
- if (myDelegate.timer || isPractice) {
- ShowMsg(@"请先关闭其他计时");
- return;
- }
-
- [self showAlertForBeginOrEndPeriodWithString:@"请扫描设备二维码开始计时"];
- }
- }
- }
- - (void)showAlertForBeginOrEndPeriodWithString:(NSString *)aString
- {
- UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:aString delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
- alert.tag = 1;
- [alert show];
- }
- -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
- {
- if (alertView.tag == 1) {
- if (buttonIndex != alertView.cancelButtonIndex) {
- //调取相机扫描二维码
- ScanVC *scan = [[ScanVC alloc] init];
- [scan scanBlock:^(NSDictionary *dic) {
-
- //imitatePeriod 模拟器打模拟学时 imPeriod手机学时
- //教练outID 教练名字 教练经度 教练纬度 有效时间
- if ([dic[@"scanType"] isEqualToString:@"imPeriod"]) {
- if (![dic[@"dataString"] isKindOfClass:[NSString class]]) {
- ShowMsg(@"二维码数据错误,请重新扫描!");
- return;
- }
- coachArray = [dic[@"dataString"] componentsSeparatedByString:@";"];
- if (coachArray.count < 4) {
- ShowMsg(@"二维码数据错误,请重新扫描!");
- return;
- }
-
- [self uploadMnStuLoginWithType:1];//签到
- }else if ([dic[@"scanType"] isEqualToString:@"imitatePeriod"]) {
-
- //模拟器计时
- // devSn(序列号); dynamicCode(动态码);type(类型:1签到,2签退)
- if (![dic[@"dataString"] isKindOfClass:[NSString class]]) {
- ShowMsg(@"二维码数据错误,请重新扫描!");
- return;
- }
- coachArray = [dic[@"dataString"] componentsSeparatedByString:@";"];
- if (coachArray.count < 2) {
- ShowMsg(@"二维码数据错误,请重新扫描!");
- return;
- }
-
- [self uploadMnStuLoginWithType:2];//签到
-
- //重新扫码计时 刷新进度
- [self getUserLearnRecord];
- }else{
- UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"请扫描模拟计时二维码" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
- alert.tag = 1;
- [alert show];
- }
- }];
- [self navPushHideTabbarToVC:scan];
- }
- }
- }
- #pragma mark 地图
- /**用户拒绝开启定位服务等原因导致的定位失败会调用的方法
- */
- - (void)didFailToLocateUserWithError:(NSError *)error
- {
- //[LoadingView showMsg:@"拒绝将无法自动获取当前位置!"];
- UIAlertView *alert =[[UIAlertView alloc]initWithTitle:@"温馨提示" message:@"请在iPhone的“设置”-“隐私”-“定位服务”功能中,找到“极速驾培”打开位置访问权限" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles: nil];
- [alert show];
- [_locService stopUserLocationService];
- }
- //处理位置坐标更新
- - (void)didUpdateBMKUserLocation:(BMKUserLocation *)userLocation
- {
- if (userLocation.location){
-
- [_mapView updateLocationData:userLocation];
- _mapView.centerCoordinate = userLocation.location.coordinate;
- myLocation = userLocation.location.coordinate;
-
-
- //发起反向地理编码检索
- _searcher =[[BMKGeoCodeSearch alloc]init];
- _searcher.delegate = self;
- BMKReverseGeoCodeOption *reverseGeoCodeSearchOption = [[BMKReverseGeoCodeOption alloc]init];
- reverseGeoCodeSearchOption.reverseGeoPoint = userLocation.location.coordinate;
- [_searcher reverseGeoCode:reverseGeoCodeSearchOption];
- // if(flag){
- // NSLog(@"反geo检索发送成功");
- // }else{
- // NSLog(@"反geo检索发送失败");
- // }
- }
- }
- - (void)onGetGeoCodeResult:(BMKGeoCodeSearch *)searcher result:(BMKGeoCodeResult *)result errorCode:(BMKSearchErrorCode)error{
- if (error == BMK_SEARCH_NO_ERROR) {
- //在此处理正常结果
- BMKPointAnnotation* annotation = [[BMKPointAnnotation alloc]init];
- annotation.coordinate = result.location;
- [_mapView addAnnotation:annotation];
- }
- else {
- [LoadingView showMsg:@"定位失败!"];
- }
- }
- //反向编码
- -(void)onGetReverseGeoCodeResult:(BMKGeoCodeSearch *)searcher result:(BMKReverseGeoCodeResult *)result errorCode:(BMKSearchErrorCode)error
- {
- searcher.delegate = nil;
- if (error == BMK_SEARCH_NO_ERROR)
- {
- //在此处理正常结果
- addressLabel.text = [NSString stringWithFormat:@"%@%@%@",result.addressDetail.district,result.addressDetail.streetName,result.addressDetail.streetNumber];
- //默认这个地址作为签到地址
- detailAddressLabel.text = result.address;
-
- //将周边存起来 微调的时候用
- poiInfos = result.poiList;
- }
- else
- {
- //[LoadingView showMsg:@"编译位置失败!"];
- }
- }
- //标注的代理
- -(BMKAnnotationView *)mapView:(BMKMapView *)mapView viewForAnnotation:(id<BMKAnnotation>)annotation
- {
- if ([annotation isKindOfClass:[BMKPointAnnotation class]]) {
- BMKPinAnnotationView *newAnnotationView = [[BMKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"myAnnotation"];
- newAnnotationView.pinColor = BMKPinAnnotationColorPurple;
- // 设置该标注点动画显示
- newAnnotationView.animatesDrop = NO;
- return newAnnotationView;
- }
- return nil;
- }
- #pragma mark mainTableView
- -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- if (tableView == learntableView) {
- return learnTimeArray.count;
- }
- return poiInfos.count;
- }
- -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- if (tableView == learntableView) {
- UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"learnCell"];
- if (cell == nil)
- {
- cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"learnCell"];
- cell.contentView.backgroundColor = backGroundColor;
- cell.textLabel.font = [UIFont scaleSize:18];
- cell.detailTextLabel.font = [UIFont scaleSize:15];
- }
- NSDictionary *dic = learnTimeArray[indexPath.row];
-
- if ([dic[@"endDate"] length] > 10) {
- cell.textLabel.text = [NSString stringWithFormat:@"%@----%@",dic[@"userSignTime"],[dic[@"endDate"] substringFromIndex:10]];
- }else{
- cell.textLabel.text = [NSString stringWithFormat:@"%@----%@",dic[@"userSignTime"],dic[@"endDate"]];
- }
-
- int time = [dic[@"time"] intValue];
- int min = time%60;
- int hour = time/60;
- NSString *timeString = [NSString stringWithFormat:@"%d小时%d分钟",hour,min];
- if (hour == 0) {
- timeString = [NSString stringWithFormat:@"%d分钟",min];
- }
-
- cell.detailTextLabel.text = [NSString stringWithFormat:@"训练时间:%@ 设备号:%@",timeString,dic[@"devSn"]];
-
- return cell;
- }
-
- UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
- if (cell == nil)
- {
- cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell"];
- cell.textLabel.textColor = titleColor;
- cell.textLabel.font = [UIFont scaleSize:FontTitle];
-
- cell.detailTextLabel.textColor = contentTextColor;
- cell.detailTextLabel.font = [UIFont scaleSize:FontTitle];
- }
- BMKPoiInfo *poiInfo = poiInfos[indexPath.row];
- cell.textLabel.text = poiInfo.name;
- cell.detailTextLabel.text = poiInfo.address;
- return cell;
- }
- -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- if (tableView == learntableView) {
- return;
- }
-
- BMKPoiInfo *info = poiInfos[indexPath.row];
-
- addressLabel.text = info.name;
- detailAddressLabel.text = info.address;
- _mapView.centerCoordinate = info.pt;
-
- myLocation = info.pt;
-
- //加标注之前要移除之前的
- if (_mapView.annotations.count > 0) {
- [_mapView removeAnnotations:_mapView.annotations];
- }
- //选择的位置加上标注
- BMKPointAnnotation* annotation = [[BMKPointAnnotation alloc]init];
- annotation.coordinate = info.pt;
- [_mapView addAnnotation:annotation];
-
- mainTableView.hidden = YES;
- loctionBtn.selected = NO;
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
- return .1;
- }
- #pragma mark 数据请求
- //获取当前学员签到状态
- - (void)getStuSignFlag
- {
- // if (![Util connectedToNetWork]) {
- // on_offBtn.userInteractionEnabled = YES;
- // [on_offBtn setTitleColor:dingColor forState:UIControlStateNormal];
- // on_offBtn.layer.borderColor = dingColor.CGColor;
- // return;
- // }
- // NSMutableArray *arr=[NSMutableArray array];
- // [arr addPro:@"stuId" Value:defUser.userDict[@"outId"]];
- // [arr addPro:@"dqbh" Value:defUser.userDict[@"city"]];
- //
- // NSString* method = @"getStuSignFlag";
- // [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
- //
- // isPractice = NO;
- // on_offBtn.userInteractionEnabled = YES;
- // [on_offBtn setTitleColor:dingColor forState:UIControlStateNormal];
- // on_offBtn.layer.borderColor = dingColor.CGColor;
- //
- // if (!root || [root[@"code"] isEqualToString:@"1"]) {
- // return;
- // }
- //
- // //这里接收服务器返回状态 当前训练培训训练状态 0 实操签退或模拟签退 1 实操签到 2 模拟签到 3 隔日训练
- // switch ([[root[@"body"] objectForKey:@"status"] integerValue]) {
- // case 0:
- // //代表签退状态 看本地是否是签退状态 如果不是 置为签退状态
- // on_offBtn.selected = NO;
- // break;
- // case 1:
- // //实操计时中
- // isPractice = YES;
- // break;
- // case 2:
- // //模拟计时中
- // on_offBtn.selected = YES;
- // break;
- // case 3:
- // //隔日签到
- //
- // break;
- // default:
- // break;
- // }
- // }];
- }
- /** 开始模拟计时
-
- @param type type 1:教练手机生成二维码。 2:设备生成二维码
- */
- - (void)uploadMnStuLoginWithType:(NSInteger)type
- {
- // ShowHUD();
- // if (![Util connectedToNetWork]) {
- // showMsgUnconnect();
- // return;
- // }
- //
- // NSMutableArray *arr=[NSMutableArray array];
- // NSString *method = @"uploadMnStuLogin";
- //
- // if (type == 1) {
- // //教练outID 教练名字 教练经度 教练纬度 有效时间
- // [arr addPro:@"stuOutId" Value:defUser.userDict[@"outId"]];
- // [arr addPro:@"coachOutId" Value:[coachArray firstObject]];
- // [arr addPro:@"dqbh" Value:defUser.userDict[@"city"]];
- // [arr addPro:@"stuLon" Value:[NSString stringWithFormat:@"%f",myLocation.longitude]];
- // [arr addPro:@"stuLat" Value:[NSString stringWithFormat:@"%f",myLocation.latitude]];
- // [arr addPro:@"coachLon" Value:coachArray[2]];
- // [arr addPro:@"coachLat" Value:coachArray[3]];
- // }else {
- // //devSn(序列号);dynamicCode(动态码);type(类型:1签到,3签退)
- // [arr addPro:@"loginCode" Value:defUser.userDict[@"loginCode"]];
- // [arr addPro:@"devSn" Value:[coachArray firstObject]];
- // [arr addPro:@"dynamicCode" Value:coachArray[1]];
- // [arr addPro:@"dqbh" Value:defUser.userDict[@"city"]];
- // [arr addPro:@"lng" Value:[NSString stringWithFormat:@"%f",myLocation.longitude]];
- // [arr addPro:@"lat" Value:[NSString stringWithFormat:@"%f",myLocation.latitude]];
- //
- // method = @"userLogin";
- // }
- //
- // [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
- // RemoveHUD();
- // if (!root) {
- // ShowMsg(@"开始计时失败,请重试!");
- // [Tools playAudioWithString:@"开始计时失败,请重试"];
- // return;
- // }
- // if ([root[@"code"] isEqualToString:@"1"]) {
- // ShowMsg(root[@"body"]);
- // [Tools playAudioWithString:root[@"body"]];
- // return;
- // }
- // ShowMsg(@"开始计时成功");
- // [Tools playAudioWithString:@"开始计时成功"];
- // on_offBtn.selected = YES;
- // }];
- }
- /** 模拟签退
- */
- - (void)uploadMnSignOut
- {
- // ShowHUD();
- // if (![Util connectedToNetWork]) {
- // showMsgUnconnect();
- // return;
- // }
- //
- // NSMutableArray *arr=[NSMutableArray array];
- // [arr addPro:@"stuOutId" Value:defUser.userDict[@"outId"]];
- // [arr addPro:@"dqbh" Value:defUser.userDict[@"city"]];
- // [arr addPro:@"pxkm" Value:defUser.userDict[@"pxjd"]];
- // NSString *method = @"uploadMnSignOut";
- //
- // [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
- // RemoveHUD();
- // if (!root) {
- // ShowMsg(@"结束计时失败,请重试!");
- // return;
- // }
- // if ([root[@"code"] isEqualToString:@"1"]) {
- // ShowMsg(root[@"body"]);
- // return;
- // }
- // ShowMsg(@"本次模拟计时已结束!");
- // on_offBtn.selected = NO;
- // }];
- }
- //获取学习进度
- - (void)getUserLearnRecord
- {
- // if (![Util connectedToNetWork]) {
- // showMsgUnconnect();
- // return;
- // }
- //
- // NSMutableArray *arr=[NSMutableArray array];
- // [arr addPro:@"loginCode" Value:defUser.userDict[@"loginCode"]];
- // NSString *method = @"getUserLearnRecord";
- //
- // [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
- // if (!root) {
- // ShowMsg(@"获取学习进度失败");
- // return;
- // }
- // if ([root[@"code"] isEqualToString:@"1"]) {
- // ShowMsg(root[@"body"]);
- // return;
- // }
- //
- // [self initLearnProgressWithDic:root[@"body"]];
- // }];
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- }
- @end
|