123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788 |
- //
- // ImitatePeriodVC.m
- // jiaPei
- //
- // Created by apple on 2017/3/8.
- // Copyright © 2017年 JCZ. All rights reserved.
- //
- #define dingColor [UIColor colorWithRed:236/255.0 green:190/255.0 blue:44/255.0 alpha:1]
- #import "ImitatePeriodVC.h"
- #import "ScanVC.h"
- #import "ProgressBarView.h"
- #import <BaiduMapAPI_Map/BMKMapComponent.h>//引入地图功能所有的头文件
- #import <BaiduMapAPI_Search/BMKSearchComponent.h>//引入检索功能所有的头文件
- #import <BMKLocationkit/BMKLocationComponent.h>//引入定位功能所有的头文件
- @interface ImitatePeriodVC ()<BMKMapViewDelegate,BMKLocationManagerDelegate,BMKGeoCodeSearchDelegate,UITableViewDelegate,UITableViewDataSource>
- {
- BMKLocationManager *_locationManager ;
- 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; //是否开启其他计时 eg:实操、集中理论
- BOOL SP_IS_MNQisTure;
- }
- @end
- @implementation ImitatePeriodVC
- - (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.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"];
- [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:RQlineColor width:2 cornorRadius: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;
-
- //这个设置重复是为了消除一个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:kTitleColor 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 (ParamsItem *item in RQ_USER_MANAGER.currentUser.params) {
- if ([item.KEY isEqualToString:@"SP_IS_MNQ"]) {
- if ([item.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:RQlineColor 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:RQlineColor width:1 cornorRadius: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];
-
- //定位功能
- [self startLocation];
- }
- - (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];
- timeProgressView.RATIONKS = 60;
-
- 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];
- learnProgressView.RATIONKS = 60;
-
-
- 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:kTitleColor 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,否则影响内存的释放
- _searcher.delegate = self;
- _locationManager.delegate = self;
- }
- -(void)viewWillDisappear:(BOOL)animated
- {
- [super viewWillDisappear:animated];
- [_locationManager stopUpdatingLocation];
- [_mapView viewWillDisappear];
- _mapView.delegate = nil; // 不用时,置nil
- _searcher.delegate = nil;
- _locationManager.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 (![Util connectedToNetWork]) {
- return;
- }
- NSMutableArray *arr=[NSMutableArray array];
- [arr addPro:@"stuId" Value:RQ_USER_MANAGER.currentUser.outId];
- [arr addPro:@"dqbh" Value:RQ_USER_MANAGER.currentUser.city];
-
- NSString* method = @"getStuSignFlag";
- [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
-
- if (!root) {
- return;
- }
- if ([root[@"code"] isEqualToString:@"1"]) {
- return;
- }
-
- //这里接收服务器返回状态 当前训练培训训练状态 0 实操签退或模拟签退 1 实操签到 2 模拟签到 3 隔日训练
- switch ([[root[@"body"] objectForKey:@"status"] integerValue]) {
- case 0:
- //开始计时
- isPractice = NO;
- on_offBtn.selected = NO;
- break;
- case 1:
- //实操计时中
- isPractice = YES;
- break;
- case 2:
- //模拟计时中
- break;
- case 3:
- //隔日签到
-
- break;
- default:
- break;
- }
- }];
- }
- }else{
- //开始计时
- if (myDelegate.timer || isPractice) {
- ShowMsg(@"请先关闭其他计时");
- return;
- }
- [self getCurrentPXKWithComplete:^(NSString *pxkm) {
- [RQ_USER_MANAGER.currentUser updatePxjdWithPxjd:pxkm];
- [self showAlertForBeginOrEndPeriodWithString:@"请扫描设备二维码开始计时"];
- }];
- }
- }
- }
- - (void)showAlertForBeginOrEndPeriodWithString:(NSString *)aString {
- [RQ_SHARE_FUNCTION showAlertWithTitle:nil message:aString alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"取消" otherButtonTitles:@[@"确定"] otherButtonStyles:nil showInWindow:NO completion:^(NSUInteger selectedOtherButtonIndex) {
- if (selectedOtherButtonIndex == 0) {
- [self scanQRCode];
- }
- }];
- }
- - (void)scanQRCode {
- //调取相机扫描二维码
- ScanVC *scan = [[ScanVC alloc] init];
- scan.type = 2;
- [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{
- [RQ_SHARE_FUNCTION showAlertWithTitle:nil message:@"请扫描模拟计时二维码" alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"取消" otherButtonTitles:@[@"确定"] otherButtonStyles:nil showInWindow:NO completion:^(NSUInteger selectedOtherButtonIndex) {
- if (selectedOtherButtonIndex == 0) {
- [self scanQRCode];
- }
- }];
- }
- }];
- [self navPushHideTabbarToVC:scan];
- }
- - (void)getCurrentPXKWithComplete:(void(^)(NSString *pxkm))complete {
- ShowHUD();
- if (![Util connectedToNetWork]) {
- ShowMsg(@"请检查网络连接。");
- RemoveHUD();
- 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) {
- RemoveHUD();
- if (!dict) {
- ShowMsgFailed();
- return;
- }
- if ( [dict[@"code"] isEqualToString:@"0"]) {
- if (complete) {
- complete(dict[@"body"]);
- }
- } else {
- ShowMsg(dict[@"body"]);
- }
- }];
- }
- #pragma mark 地图
- -(void)startLocation
- {
- if (!_locationManager) {
- //初始化实例
- _locationManager = [[BMKLocationManager alloc] init];
- //设置返回位置的坐标系类型 默认为国标
- _locationManager.coordinateType = BMKLocationCoordinateTypeBMK09LL;//百度经纬度坐标
- }
-
- BOOL requestResult = [_locationManager requestLocationWithReGeocode:NO withNetworkState:NO completionBlock:^(BMKLocation * _Nullable location, BMKLocationNetworkState state, NSError * _Nullable error) {
- if (error)
- {
- ShowMsg([NSString stringWithFormat:@"定位失败:%@",error.description]);
- }else{
- myLocation = location.location.coordinate;
- _mapView.centerCoordinate = location.location.coordinate;
-
- //发起反向地理编码检索
- //发起反向地理编码检索
- _searcher =[[BMKGeoCodeSearch alloc]init];
- _searcher.delegate = self;
- BMKReverseGeoCodeSearchOption *reverseGeoCodeSearchOption = [[BMKReverseGeoCodeSearchOption alloc]init];
- reverseGeoCodeSearchOption.location = location.location.coordinate;
- BOOL flag = [_searcher reverseGeoCode:reverseGeoCodeSearchOption];;
- if (flag) {
- NSLog(@"反地理编码检索成功");
- } else {
- ShowMsg(@"反地理编码检索失败");
- }
- }
- }];
- if (requestResult == NO) {
- //
- ShowMsg(@"发起定位请求失败");
- }
- }
- /**
- 反向地理编码检索结果回调
-
- @param searcher 检索对象
- @param result 反向地理编码检索结果
- @param error 错误码,@see BMKCloudErrorCode
- */
- - (void)onGetReverseGeoCodeResult:(BMKGeoCodeSearch *)searcher result:(BMKReverseGeoCodeSearchResult *)result errorCode:(BMKSearchErrorCode)error {
-
- 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;
-
- //选择的位置加上标注
- BMKPointAnnotation* annotation = [[BMKPointAnnotation alloc]init];
- annotation.coordinate = result.location;
- [_mapView addAnnotation:annotation];
- }
- 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 = kTitleColor;
- 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;
- }
- -(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
- return [UIView new];
- }
- -(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:RQ_USER_MANAGER.currentUser.outId];
- [arr addPro:@"dqbh" Value:RQ_USER_MANAGER.currentUser.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 隔日训练 4集中理论 5终端实操
- 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;
- case 4:
- //集中理论
- isPractice = YES;
- break;
- case 5:
- //实操计时中
- isPractice = YES;
- 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:RQ_USER_MANAGER.currentUser.outId];
- [arr addPro:@"coachOutId" Value:[coachArray firstObject]];
- [arr addPro:@"dqbh" Value:RQ_USER_MANAGER.currentUser.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:RQ_USER_MANAGER.currentUser.loginCode];
- [arr addPro:@"devSn" Value:[coachArray firstObject]];
- [arr addPro:@"dynamicCode" Value:coachArray[1]];
- [arr addPro:@"dqbh" Value:RQ_USER_MANAGER.currentUser.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(@"开始计时成功");//@zhangrong
- [Tools playAudioWithString:@"开始计时成功"];
- on_offBtn.selected = YES;
- }];
- }
- /** 模拟签退
- */
- - (void)uploadMnSignOut
- {
- ShowHUD();
- if (![Util connectedToNetWork]) {
- showMsgUnconnect();
- return;
- }
-
- NSMutableArray *arr=[NSMutableArray array];
- [arr addPro:@"stuOutId" Value:RQ_USER_MANAGER.currentUser.outId];
- [arr addPro:@"dqbh" Value:RQ_USER_MANAGER.currentUser.city];
- [arr addPro:@"pxkm" Value:RQ_USER_MANAGER.currentUser.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((root[@"body"] || ![root[@"body"] isEqualToString:@""])? root[@"body"] : @"本次模拟计时已结束!");
- on_offBtn.selected = NO;
- }];
- }
- //获取学习进度
- - (void)getUserLearnRecord
- {
- if (![Util connectedToNetWork]) {
- showMsgUnconnect();
- return;
- }
-
- NSMutableArray *arr=[NSMutableArray array];
- [arr addPro:@"loginCode" Value:RQ_USER_MANAGER.currentUser.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
|