TheoryVC.m 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755
  1. //
  2. // TheoryVC.m
  3. // jiaPei
  4. //
  5. // Created by EchoShacolee on 2017/7/5.
  6. // Copyright © 2017年 JCZ. All rights reserved.
  7. //
  8. #define dingColor [UIColor colorWithRed:236/255.0 green:190/255.0 blue:44/255.0 alpha:1]
  9. #import "TheoryVC.h"
  10. #import "ScanVC.h"
  11. #import "ProgressBarView.h"
  12. #import <BaiduMapAPI_Map/BMKMapComponent.h>//引入地图功能所有的头文件
  13. #import <BaiduMapAPI_Search/BMKSearchComponent.h>//引入检索功能所有的头文件
  14. #import <BaiduMapAPI_Location/BMKLocationComponent.h>//引入定位功能所有的头文件
  15. @interface TheoryVC ()<BMKMapViewDelegate,BMKLocationServiceDelegate,BMKGeoCodeSearchDelegate,UITableViewDelegate,UITableViewDataSource,UIAlertViewDelegate>
  16. {
  17. BMKLocationService *_locService;
  18. BMKMapView *_mapView;
  19. BMKGeoCodeSearch *_searcher;
  20. UIButton *loctionBtn;
  21. UILabel *addressLabel,*detailAddressLabel;
  22. UIButton *on_offBtn;
  23. UITableView *mainTableView;
  24. //学习进度
  25. UITableView *learntableView;
  26. ProgressBarView *timeProgressView, *learnProgressView;
  27. NSArray *learnTimeArray;
  28. NSArray *poiInfos;
  29. NSArray *coachArray;
  30. CLLocationCoordinate2D myLocation;
  31. BOOL isPractice;
  32. BOOL SP_IS_MNQisTure;
  33. }
  34. @end
  35. @implementation TheoryVC
  36. - (void)viewDidLoad {
  37. [super viewDidLoad];
  38. self.title = @"理论计时";
  39. self.view.backgroundColor = backGroundColor;
  40. [self configNavigationBar];
  41. CGFloat x, y, w, h;
  42. x = 20;
  43. y = 10;
  44. w = (kSize.width - 40)/2.0;
  45. h = 60;
  46. NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
  47. [formatter setDateFormat:@"yyyy.MM.dd-HH:mm-EEEE"];
  48. NSString *dateString = [formatter stringFromDate:[NSDate date]];
  49. //NSLog(@"dateString---->%@",dateString);
  50. NSArray *dateArray = [NSArray arrayWithObjects:@"暂无",@"暂无",@"暂无", nil];
  51. if (dateString.length > 0) {
  52. if ([dateString containsString:@"-"]) {
  53. dateArray = [dateString componentsSeparatedByString:@"-"];
  54. }
  55. }
  56. UILabel *label = [[UILabel alloc] setxywh];
  57. [label setText:[NSString stringWithFormat:@"%@:%@",[dateArray lastObject],[dateArray firstObject]] Font:FontTitle TextColor:contentTextColor Alignment:NSTextAlignmentLeft];
  58. [self.view addSubview:label];
  59. x += w;
  60. label = [[UILabel alloc] setxywh];
  61. [label setText:[NSString stringWithFormat:@"当前时间: %@",dateArray[1]] Font:FontTitle TextColor:contentTextColor Alignment:NSTextAlignmentLeft];
  62. [self.view addSubview:label];
  63. x = 20;
  64. y += h;
  65. w = kSize.width - 40;
  66. h = 100;
  67. UIView *mapBar = [[UIView alloc] setxywh];
  68. [mapBar borderColor:lineColor width:2 cornorRadios:0];
  69. mapBar.clipsToBounds = YES;;
  70. [self.view addSubview:mapBar];
  71. x = y = 0;
  72. w = 110;
  73. h = 122;
  74. //创建地图
  75. _mapView = [[BMKMapView alloc]setxywh];
  76. [mapBar addSubview:_mapView];
  77. [_mapView addViewWithRect:CGRectMake(x + w, y, 2, h)];
  78. _mapView.mapType = BMKMapTypeStandard;
  79. //定位功能
  80. _locService = [[BMKLocationService alloc]init];
  81. _locService.distanceFilter = 1;
  82. _locService.delegate = self;
  83. [_locService startUserLocationService];
  84. //这个设置重复是为了消除一个bug 记得
  85. _mapView.showsUserLocation = NO;
  86. _mapView.userTrackingMode = BMKUserTrackingModeNone;
  87. _mapView.zoomLevel = 16;
  88. _mapView.showsUserLocation = YES;
  89. BMKLocationViewDisplayParam *displayParam = [[BMKLocationViewDisplayParam alloc]init];
  90. displayParam.isRotateAngleValid = true;//跟随态旋转角度是否生效
  91. displayParam.isAccuracyCircleShow = false;//精度圈是否显示
  92. displayParam.locationViewOffsetX = 0;//定位偏移量(经度)
  93. displayParam.locationViewOffsetY = 0;//定位偏移量(纬度)
  94. [_mapView updateLocationViewWithParam:displayParam];
  95. x += w + 5;
  96. w = kSize.width - 40 - 115;
  97. h = 25;
  98. label = [[UILabel alloc] setxywh];
  99. [label setText:@"正在定位..." Font:FontTitle TextColor:titleColor Alignment:NSTextAlignmentLeft];
  100. [mapBar addSubview:label];
  101. addressLabel = label;
  102. y += h;
  103. h = 50;
  104. label = [[UILabel alloc] setxywh];
  105. [label setText:@"" Font:FontTitle TextColor:contentTextColor Alignment:NSTextAlignmentLeft];
  106. label.numberOfLines = 0;
  107. [mapBar addSubview:label];
  108. detailAddressLabel = label;
  109. y += h;
  110. h = 20;
  111. UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
  112. btn.frame = CGRectMake(x, y, w, h);
  113. [btn setTitle:@"地点微调" textColor:[UIColor blueColor] font:FontTitle fotState:UIControlStateNormal];
  114. [btn setTitle:@"取消微调" forState:UIControlStateSelected];
  115. btn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
  116. [btn.titleLabel setTextAlignment:NSTextAlignmentLeft];
  117. [btn target:self tag:1];
  118. [mapBar addSubview:btn];
  119. loctionBtn = btn;
  120. for (NSDictionary * dic in defUser.userDict[@"params"]) {
  121. if ([dic[@"KEY"] isEqualToString:@"SP_IS_MNQ"]) {
  122. if ([dic[@"VALUE"] isEqualToString:@"1"]) {
  123. SP_IS_MNQisTure = YES;
  124. }else {
  125. SP_IS_MNQisTure = NO;
  126. }
  127. }
  128. }
  129. y = mapBar.y +mapBar.height + 40;
  130. x = 20;
  131. w = kSize.width - 40.0;
  132. h = 40;
  133. btn = [UIButton buttonWithType:UIButtonTypeCustom];
  134. btn.frame = CGRectMake(x, y, w, h);
  135. [btn setTitle:@"开始计时" textColor:lineColor font:20 fotState:UIControlStateNormal];
  136. if (!SP_IS_MNQisTure) {
  137. [btn setTitle:@"结束计时" textColor:dingColor font:20 fotState:UIControlStateSelected];
  138. }else{
  139. [btn setTitle:@"开始计时" textColor:dingColor font:20 fotState:UIControlStateSelected];
  140. }
  141. [btn borderColor:lineColor width:1 cornorRadios:5];
  142. [btn target:self tag:2];
  143. btn.userInteractionEnabled = NO;
  144. [self.view addSubview:btn];
  145. on_offBtn = btn;
  146. if (!SP_IS_MNQisTure) {
  147. //教练手机模拟计时
  148. NSString *noticeString = @"理论计时注意事项:\n模拟计时每天最多计时4个小时,若当日学习时间累计超过4小时,将按4小时计算。单次一次性产生4小时及以上学时的,系统将判断其为无效学时,自动清零,请知悉。";
  149. y += h + 30;
  150. h = [noticeString heightForWid:w Font:Font17] + 20;
  151. label = [[UILabel alloc] setxywh];
  152. [label setText:noticeString Font:Font17 TextColor:[UIColor orangeColor] Alignment:NSTextAlignmentLeft];
  153. label.numberOfLines = 0;
  154. [self.view addSubview:label];
  155. }else{
  156. //模拟器模拟计时 训练项目进度。 学时进度。 训练记录。
  157. if (myDelegate.isLogin) {
  158. [self getUserLearnRecord];
  159. }
  160. }
  161. y = mapBar.y +mapBar.height;
  162. h = kSize.height - y - kNavOffSet;
  163. mainTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, y, kSize.width, h) style:UITableViewStylePlain];
  164. mainTableView.delegate = self;
  165. mainTableView.dataSource = self;
  166. [self.view addSubview:mainTableView];
  167. mainTableView.hidden = YES;
  168. isPractice = NO;
  169. [self getStuSignFlag];
  170. }
  171. - (void)initLearnProgressWithDic:(NSDictionary *)dic {
  172. CGFloat y = on_offBtn.y + on_offBtn.height + 20;
  173. if (!timeProgressView) {
  174. timeProgressView = [[ProgressBarView alloc] initWithFrame:CGRectMake(0, y, kSize.width, 50)];
  175. timeProgressView.titleString = @"学时进度:";
  176. [self.view addSubview:timeProgressView];
  177. }
  178. timeProgressView.allNeedTime = [dic[@"mnq_all_time"] integerValue];
  179. timeProgressView.finishTime = [dic[@"mnq_time"] integerValue];
  180. y += 60;
  181. if (!learnProgressView) {
  182. learnProgressView = [[ProgressBarView alloc] initWithFrame:CGRectMake(0, y, kSize.width, 25)];
  183. learnProgressView.titleString = @"训练进度:";
  184. [self.view addSubview:learnProgressView];
  185. }
  186. learnProgressView.allCount = [dic[@"mnq_total"] integerValue];
  187. learnProgressView.finishCount = [dic[@"mnq_num"] integerValue];
  188. y += 40;
  189. if (!learntableView) {
  190. learnTimeArray = [NSArray array];
  191. learntableView = [[UITableView alloc] initWithFrame:CGRectMake(0, y, kSize.width, kSize.height - y - kNavOffSet) style:UITableViewStylePlain];
  192. learntableView.backgroundColor = backGroundColor;
  193. learntableView.delegate = self;
  194. learntableView.dataSource = self;
  195. [self.view addSubview:learntableView];
  196. UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, kSize.width, 30)];
  197. label.backgroundColor = backGroundColor;
  198. [label setText:@"学时记录" Font:FontTitle TextColor:titleColor Alignment:NSTextAlignmentCenter];
  199. learntableView.tableHeaderView = label;
  200. }
  201. if ([dic[@"mnq_list"] isKindOfClass:[NSArray class]]) {
  202. learnTimeArray = dic[@"mnq_list"];
  203. }else {
  204. learnTimeArray = [NSArray array];
  205. }
  206. [learntableView reloadData];
  207. [self.view bringSubviewToFront:mainTableView];
  208. }
  209. -(void)viewWillAppear:(BOOL)animated
  210. {
  211. [super viewWillAppear:animated];
  212. [_mapView viewWillAppear];
  213. _mapView.delegate = self; // 此处记得不用的时候需要置nil,否则影响内存的释放
  214. }
  215. -(void)viewWillDisappear:(BOOL)animated
  216. {
  217. [super viewWillDisappear:animated];
  218. [_locService stopUserLocationService];
  219. [_mapView viewWillDisappear];
  220. _mapView.delegate = nil; // 不用时,置nil
  221. _searcher.delegate = nil;
  222. _locService.delegate = nil;
  223. }
  224. -(void)btnClick:(UIButton *)sender
  225. {
  226. if (sender.tag == 1) {
  227. //微调
  228. sender.selected = !sender.selected;
  229. if (sender.selected) {
  230. mainTableView.hidden = NO;
  231. [mainTableView reloadData];
  232. }else{
  233. mainTableView.hidden = YES;
  234. }
  235. }
  236. if (sender.tag == 2) {
  237. if (sender.selected) {
  238. //结束计时
  239. if (!SP_IS_MNQisTure) {
  240. [self uploadMnSignOut];
  241. }else{
  242. if (myDelegate.timer) {
  243. ShowMsg(@"请先关闭其他计时");
  244. return;
  245. }
  246. if (![Util connectedToNetWork]) {
  247. return;
  248. }
  249. NSMutableArray *arr=[NSMutableArray array];
  250. [arr addPro:@"stuId" Value:defUser.userDict[@"outId"]];
  251. [arr addPro:@"dqbh" Value:defUser.userDict[@"city"]];
  252. NSString* method = @"getStuSignFlag";
  253. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
  254. if (!root) {
  255. ShowMsg(@"网络错误,请稍后尝试");
  256. return;
  257. }
  258. if ([root[@"code"] isEqualToString:@"1"]) {
  259. ShowMsg(root[@"body"]);
  260. return;
  261. }
  262. //这里接收服务器返回状态 当前训练培训训练状态 0 实操签退或模拟签退 1 实操签到 2 模拟签到 3 隔日训练
  263. switch ([[root[@"body"] objectForKey:@"status"] integerValue]) {
  264. case 0:
  265. //开始计时
  266. isPractice = NO;
  267. [self showAlertForBeginOrEndPeriodWithString:@"请扫描设备二维码开始计时"];
  268. on_offBtn.selected = NO;
  269. break;
  270. case 1:
  271. //实操计时中
  272. isPractice = YES;
  273. ShowMsg(@"请先关闭实操计时");
  274. break;
  275. case 2:
  276. //模拟计时中
  277. ShowMsg(@"正在模拟计时");
  278. break;
  279. case 3:
  280. //隔日签到
  281. break;
  282. default:
  283. break;
  284. }
  285. }];
  286. }
  287. }else{
  288. //开始计时
  289. if (myDelegate.timer || isPractice) {
  290. ShowMsg(@"请先关闭其他计时");
  291. return;
  292. }
  293. [self showAlertForBeginOrEndPeriodWithString:@"请扫描设备二维码开始计时"];
  294. }
  295. }
  296. }
  297. - (void)showAlertForBeginOrEndPeriodWithString:(NSString *)aString
  298. {
  299. UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:aString delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
  300. alert.tag = 1;
  301. [alert show];
  302. }
  303. -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
  304. {
  305. if (alertView.tag == 1) {
  306. if (buttonIndex != alertView.cancelButtonIndex) {
  307. //调取相机扫描二维码
  308. ScanVC *scan = [[ScanVC alloc] init];
  309. [scan scanBlock:^(NSDictionary *dic) {
  310. //imitatePeriod 模拟器打模拟学时 imPeriod手机学时
  311. //教练outID 教练名字 教练经度 教练纬度 有效时间
  312. if ([dic[@"scanType"] isEqualToString:@"imPeriod"]) {
  313. if (![dic[@"dataString"] isKindOfClass:[NSString class]]) {
  314. ShowMsg(@"二维码数据错误,请重新扫描!");
  315. return;
  316. }
  317. coachArray = [dic[@"dataString"] componentsSeparatedByString:@";"];
  318. if (coachArray.count < 4) {
  319. ShowMsg(@"二维码数据错误,请重新扫描!");
  320. return;
  321. }
  322. [self uploadMnStuLoginWithType:1];//签到
  323. }else if ([dic[@"scanType"] isEqualToString:@"imitatePeriod"]) {
  324. //模拟器计时
  325. // devSn(序列号); dynamicCode(动态码);type(类型:1签到,2签退)
  326. if (![dic[@"dataString"] isKindOfClass:[NSString class]]) {
  327. ShowMsg(@"二维码数据错误,请重新扫描!");
  328. return;
  329. }
  330. coachArray = [dic[@"dataString"] componentsSeparatedByString:@";"];
  331. if (coachArray.count < 2) {
  332. ShowMsg(@"二维码数据错误,请重新扫描!");
  333. return;
  334. }
  335. [self uploadMnStuLoginWithType:2];//签到
  336. //重新扫码计时 刷新进度
  337. [self getUserLearnRecord];
  338. }else{
  339. UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"请扫描模拟计时二维码" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
  340. alert.tag = 1;
  341. [alert show];
  342. }
  343. }];
  344. [self navPushHideTabbarToVC:scan];
  345. }
  346. }
  347. }
  348. #pragma mark 地图
  349. /**用户拒绝开启定位服务等原因导致的定位失败会调用的方法
  350. */
  351. - (void)didFailToLocateUserWithError:(NSError *)error
  352. {
  353. //[LoadingView showMsg:@"拒绝将无法自动获取当前位置!"];
  354. UIAlertView *alert =[[UIAlertView alloc]initWithTitle:@"温馨提示" message:@"请在iPhone的“设置”-“隐私”-“定位服务”功能中,找到“极速驾培”打开位置访问权限" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles: nil];
  355. [alert show];
  356. [_locService stopUserLocationService];
  357. }
  358. //处理位置坐标更新
  359. - (void)didUpdateBMKUserLocation:(BMKUserLocation *)userLocation
  360. {
  361. if (userLocation.location){
  362. [_mapView updateLocationData:userLocation];
  363. _mapView.centerCoordinate = userLocation.location.coordinate;
  364. myLocation = userLocation.location.coordinate;
  365. //发起反向地理编码检索
  366. _searcher =[[BMKGeoCodeSearch alloc]init];
  367. _searcher.delegate = self;
  368. BMKReverseGeoCodeOption *reverseGeoCodeSearchOption = [[BMKReverseGeoCodeOption alloc]init];
  369. reverseGeoCodeSearchOption.reverseGeoPoint = userLocation.location.coordinate;
  370. [_searcher reverseGeoCode:reverseGeoCodeSearchOption];
  371. // if(flag){
  372. // NSLog(@"反geo检索发送成功");
  373. // }else{
  374. // NSLog(@"反geo检索发送失败");
  375. // }
  376. }
  377. }
  378. - (void)onGetGeoCodeResult:(BMKGeoCodeSearch *)searcher result:(BMKGeoCodeResult *)result errorCode:(BMKSearchErrorCode)error{
  379. if (error == BMK_SEARCH_NO_ERROR) {
  380. //在此处理正常结果
  381. BMKPointAnnotation* annotation = [[BMKPointAnnotation alloc]init];
  382. annotation.coordinate = result.location;
  383. [_mapView addAnnotation:annotation];
  384. }
  385. else {
  386. [LoadingView showMsg:@"定位失败!"];
  387. }
  388. }
  389. //反向编码
  390. -(void)onGetReverseGeoCodeResult:(BMKGeoCodeSearch *)searcher result:(BMKReverseGeoCodeResult *)result errorCode:(BMKSearchErrorCode)error
  391. {
  392. searcher.delegate = nil;
  393. if (error == BMK_SEARCH_NO_ERROR)
  394. {
  395. //在此处理正常结果
  396. addressLabel.text = [NSString stringWithFormat:@"%@%@%@",result.addressDetail.district,result.addressDetail.streetName,result.addressDetail.streetNumber];
  397. //默认这个地址作为签到地址
  398. detailAddressLabel.text = result.address;
  399. //将周边存起来 微调的时候用
  400. poiInfos = result.poiList;
  401. }
  402. else
  403. {
  404. //[LoadingView showMsg:@"编译位置失败!"];
  405. }
  406. }
  407. //标注的代理
  408. -(BMKAnnotationView *)mapView:(BMKMapView *)mapView viewForAnnotation:(id<BMKAnnotation>)annotation
  409. {
  410. if ([annotation isKindOfClass:[BMKPointAnnotation class]]) {
  411. BMKPinAnnotationView *newAnnotationView = [[BMKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"myAnnotation"];
  412. newAnnotationView.pinColor = BMKPinAnnotationColorPurple;
  413. // 设置该标注点动画显示
  414. newAnnotationView.animatesDrop = NO;
  415. return newAnnotationView;
  416. }
  417. return nil;
  418. }
  419. #pragma mark mainTableView
  420. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  421. {
  422. if (tableView == learntableView) {
  423. return learnTimeArray.count;
  424. }
  425. return poiInfos.count;
  426. }
  427. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  428. {
  429. if (tableView == learntableView) {
  430. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"learnCell"];
  431. if (cell == nil)
  432. {
  433. cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"learnCell"];
  434. cell.contentView.backgroundColor = backGroundColor;
  435. cell.textLabel.font = [UIFont scaleSize:18];
  436. cell.detailTextLabel.font = [UIFont scaleSize:15];
  437. }
  438. NSDictionary *dic = learnTimeArray[indexPath.row];
  439. if ([dic[@"endDate"] length] > 10) {
  440. cell.textLabel.text = [NSString stringWithFormat:@"%@----%@",dic[@"userSignTime"],[dic[@"endDate"] substringFromIndex:10]];
  441. }else{
  442. cell.textLabel.text = [NSString stringWithFormat:@"%@----%@",dic[@"userSignTime"],dic[@"endDate"]];
  443. }
  444. int time = [dic[@"time"] intValue];
  445. int min = time%60;
  446. int hour = time/60;
  447. NSString *timeString = [NSString stringWithFormat:@"%d小时%d分钟",hour,min];
  448. if (hour == 0) {
  449. timeString = [NSString stringWithFormat:@"%d分钟",min];
  450. }
  451. cell.detailTextLabel.text = [NSString stringWithFormat:@"训练时间:%@ 设备号:%@",timeString,dic[@"devSn"]];
  452. return cell;
  453. }
  454. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
  455. if (cell == nil)
  456. {
  457. cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell"];
  458. cell.textLabel.textColor = titleColor;
  459. cell.textLabel.font = [UIFont scaleSize:FontTitle];
  460. cell.detailTextLabel.textColor = contentTextColor;
  461. cell.detailTextLabel.font = [UIFont scaleSize:FontTitle];
  462. }
  463. BMKPoiInfo *poiInfo = poiInfos[indexPath.row];
  464. cell.textLabel.text = poiInfo.name;
  465. cell.detailTextLabel.text = poiInfo.address;
  466. return cell;
  467. }
  468. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  469. {
  470. if (tableView == learntableView) {
  471. return;
  472. }
  473. BMKPoiInfo *info = poiInfos[indexPath.row];
  474. addressLabel.text = info.name;
  475. detailAddressLabel.text = info.address;
  476. _mapView.centerCoordinate = info.pt;
  477. myLocation = info.pt;
  478. //加标注之前要移除之前的
  479. if (_mapView.annotations.count > 0) {
  480. [_mapView removeAnnotations:_mapView.annotations];
  481. }
  482. //选择的位置加上标注
  483. BMKPointAnnotation* annotation = [[BMKPointAnnotation alloc]init];
  484. annotation.coordinate = info.pt;
  485. [_mapView addAnnotation:annotation];
  486. mainTableView.hidden = YES;
  487. loctionBtn.selected = NO;
  488. }
  489. -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
  490. return .1;
  491. }
  492. #pragma mark 数据请求
  493. //获取当前学员签到状态
  494. - (void)getStuSignFlag
  495. {
  496. // if (![Util connectedToNetWork]) {
  497. // on_offBtn.userInteractionEnabled = YES;
  498. // [on_offBtn setTitleColor:dingColor forState:UIControlStateNormal];
  499. // on_offBtn.layer.borderColor = dingColor.CGColor;
  500. // return;
  501. // }
  502. // NSMutableArray *arr=[NSMutableArray array];
  503. // [arr addPro:@"stuId" Value:defUser.userDict[@"outId"]];
  504. // [arr addPro:@"dqbh" Value:defUser.userDict[@"city"]];
  505. //
  506. // NSString* method = @"getStuSignFlag";
  507. // [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
  508. //
  509. // isPractice = NO;
  510. // on_offBtn.userInteractionEnabled = YES;
  511. // [on_offBtn setTitleColor:dingColor forState:UIControlStateNormal];
  512. // on_offBtn.layer.borderColor = dingColor.CGColor;
  513. //
  514. // if (!root || [root[@"code"] isEqualToString:@"1"]) {
  515. // return;
  516. // }
  517. //
  518. // //这里接收服务器返回状态 当前训练培训训练状态 0 实操签退或模拟签退 1 实操签到 2 模拟签到 3 隔日训练
  519. // switch ([[root[@"body"] objectForKey:@"status"] integerValue]) {
  520. // case 0:
  521. // //代表签退状态 看本地是否是签退状态 如果不是 置为签退状态
  522. // on_offBtn.selected = NO;
  523. // break;
  524. // case 1:
  525. // //实操计时中
  526. // isPractice = YES;
  527. // break;
  528. // case 2:
  529. // //模拟计时中
  530. // on_offBtn.selected = YES;
  531. // break;
  532. // case 3:
  533. // //隔日签到
  534. //
  535. // break;
  536. // default:
  537. // break;
  538. // }
  539. // }];
  540. }
  541. /** 开始模拟计时
  542. @param type type 1:教练手机生成二维码。 2:设备生成二维码
  543. */
  544. - (void)uploadMnStuLoginWithType:(NSInteger)type
  545. {
  546. // ShowHUD();
  547. // if (![Util connectedToNetWork]) {
  548. // showMsgUnconnect();
  549. // return;
  550. // }
  551. //
  552. // NSMutableArray *arr=[NSMutableArray array];
  553. // NSString *method = @"uploadMnStuLogin";
  554. //
  555. // if (type == 1) {
  556. // //教练outID 教练名字 教练经度 教练纬度 有效时间
  557. // [arr addPro:@"stuOutId" Value:defUser.userDict[@"outId"]];
  558. // [arr addPro:@"coachOutId" Value:[coachArray firstObject]];
  559. // [arr addPro:@"dqbh" Value:defUser.userDict[@"city"]];
  560. // [arr addPro:@"stuLon" Value:[NSString stringWithFormat:@"%f",myLocation.longitude]];
  561. // [arr addPro:@"stuLat" Value:[NSString stringWithFormat:@"%f",myLocation.latitude]];
  562. // [arr addPro:@"coachLon" Value:coachArray[2]];
  563. // [arr addPro:@"coachLat" Value:coachArray[3]];
  564. // }else {
  565. // //devSn(序列号);dynamicCode(动态码);type(类型:1签到,3签退)
  566. // [arr addPro:@"loginCode" Value:defUser.userDict[@"loginCode"]];
  567. // [arr addPro:@"devSn" Value:[coachArray firstObject]];
  568. // [arr addPro:@"dynamicCode" Value:coachArray[1]];
  569. // [arr addPro:@"dqbh" Value:defUser.userDict[@"city"]];
  570. // [arr addPro:@"lng" Value:[NSString stringWithFormat:@"%f",myLocation.longitude]];
  571. // [arr addPro:@"lat" Value:[NSString stringWithFormat:@"%f",myLocation.latitude]];
  572. //
  573. // method = @"userLogin";
  574. // }
  575. //
  576. // [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
  577. // RemoveHUD();
  578. // if (!root) {
  579. // ShowMsg(@"开始计时失败,请重试!");
  580. // [Tools playAudioWithString:@"开始计时失败,请重试"];
  581. // return;
  582. // }
  583. // if ([root[@"code"] isEqualToString:@"1"]) {
  584. // ShowMsg(root[@"body"]);
  585. // [Tools playAudioWithString:root[@"body"]];
  586. // return;
  587. // }
  588. // ShowMsg(@"开始计时成功");
  589. // [Tools playAudioWithString:@"开始计时成功"];
  590. // on_offBtn.selected = YES;
  591. // }];
  592. }
  593. /** 模拟签退
  594. */
  595. - (void)uploadMnSignOut
  596. {
  597. // ShowHUD();
  598. // if (![Util connectedToNetWork]) {
  599. // showMsgUnconnect();
  600. // return;
  601. // }
  602. //
  603. // NSMutableArray *arr=[NSMutableArray array];
  604. // [arr addPro:@"stuOutId" Value:defUser.userDict[@"outId"]];
  605. // [arr addPro:@"dqbh" Value:defUser.userDict[@"city"]];
  606. // [arr addPro:@"pxkm" Value:defUser.userDict[@"pxjd"]];
  607. // NSString *method = @"uploadMnSignOut";
  608. //
  609. // [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
  610. // RemoveHUD();
  611. // if (!root) {
  612. // ShowMsg(@"结束计时失败,请重试!");
  613. // return;
  614. // }
  615. // if ([root[@"code"] isEqualToString:@"1"]) {
  616. // ShowMsg(root[@"body"]);
  617. // return;
  618. // }
  619. // ShowMsg(@"本次模拟计时已结束!");
  620. // on_offBtn.selected = NO;
  621. // }];
  622. }
  623. //获取学习进度
  624. - (void)getUserLearnRecord
  625. {
  626. // if (![Util connectedToNetWork]) {
  627. // showMsgUnconnect();
  628. // return;
  629. // }
  630. //
  631. // NSMutableArray *arr=[NSMutableArray array];
  632. // [arr addPro:@"loginCode" Value:defUser.userDict[@"loginCode"]];
  633. // NSString *method = @"getUserLearnRecord";
  634. //
  635. // [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
  636. // if (!root) {
  637. // ShowMsg(@"获取学习进度失败");
  638. // return;
  639. // }
  640. // if ([root[@"code"] isEqualToString:@"1"]) {
  641. // ShowMsg(root[@"body"]);
  642. // return;
  643. // }
  644. //
  645. // [self initLearnProgressWithDic:root[@"body"]];
  646. // }];
  647. }
  648. - (void)didReceiveMemoryWarning {
  649. [super didReceiveMemoryWarning];
  650. }
  651. @end