TerminalScreenVC.m 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751
  1. //
  2. // TerminalScreenVC.m
  3. // JSJPCoach
  4. //
  5. // Created by apple on 2017/6/19.
  6. // Copyright © 2017年 Danson. All rights reserved.
  7. //
  8. #import "TerminalScreenVC.h"
  9. #import "PriceCell.h"
  10. #import "MinRescord.h"
  11. #import "SelectImgVC.h"
  12. #import "ViewController.h"
  13. #import "MyUINavigationController.h"
  14. @interface TerminalScreenVC ()<UITableViewDelegate,UITableViewDataSource>
  15. {
  16. UILabel *subjectLabel, *priceLabel;
  17. UIView *stuInfoView;
  18. UIView *setTrainInfoView;
  19. UIButton *setTrainInfoBtn;
  20. UILabel *stuNamelabel;
  21. //当前培训信息
  22. UILabel *allTimeLabel, *valueTimeLabel, *invalidTimeLabel, *waitTimeLabel, *mileAndSpeedLabel;
  23. NSTimer *timer;
  24. NSTimer *preTimer;
  25. UIButton *keErBtn, *keSanBtn;
  26. UITableView *priceTableView;
  27. UITableViewCell *priceCell;
  28. NSArray *moneyArr;
  29. NSString *keMuString;
  30. NSString *priceString;
  31. NSDictionary *dataDic;
  32. }
  33. @end
  34. @implementation TerminalScreenVC
  35. - (void)viewDidLoad {
  36. [super viewDidLoad];
  37. if (_isNotification == YES){
  38. //推送状态 要将根视图变回去
  39. UIBarButtonItem* backBtn = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"back.png"] style:UIBarButtonItemStylePlain target:self action:@selector(dismissNavgation)];
  40. [backBtn setTintColor:defGreen];
  41. // self.navigationController.navigationBar.translucent = NO;
  42. [self.navigationItem setLeftBarButtonItem:backBtn];
  43. }
  44. UIImageView *backImageView = [[UIImageView alloc] initWithFrame:kFrame];
  45. backImageView.image = [UIImage imageNamed:@"bgImage"];
  46. [self.view addSubview:backImageView];
  47. //带教科目&价格
  48. CGFloat y = kNavOffSet + 30;
  49. UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(20, y, kSize.width - 40, 30)];
  50. [label setText:@"带教科目:未设置" Font:Font18 TextColor:newTitleColor];
  51. [self.view addSubview:label];
  52. subjectLabel = label;
  53. y += 30;
  54. label = [[UILabel alloc] initWithFrame:CGRectMake(20, y, kSize.width - 40, 30)];
  55. [label setText:@"带教价格:未设置" Font:Font18 TextColor:newTitleColor];
  56. [self.view addSubview:label];
  57. priceLabel = label;
  58. y = kNavOffSet + 40;
  59. UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(kSize.width - 100, y, 80, 40)];
  60. btn.backgroundColor = [UIColor colorWithWhite:.7 alpha:.2];
  61. [btn setTitle:@"设置科目" textColor:defGreen font:Font18 fotState:UIControlStateNormal];
  62. [btn borderColor:defGreen width:1 cornorRadios:5];
  63. [btn target:self Tag:-1];
  64. [self.view addSubview:btn];
  65. setTrainInfoBtn = btn;
  66. //学员info
  67. stuInfoView = [[UIView alloc] initWithFrame:CGRectMake(0, kNavOffSet + 100, kSize.width, kSize.height - kNavOffSet - 100)];
  68. [self.view addSubview:stuInfoView];
  69. label = [[UILabel alloc] initWithFrame:CGRectMake(20, 10, kSize.width - 40, 50)];
  70. [label setText:@"暂未查询到正在带教学员!" Font:Font18 TextColor:newTitleColor];
  71. [stuInfoView addSubview:label];
  72. //设置带教info
  73. CGFloat x, w, h;
  74. x = 20;
  75. y = kNavOffSet + 110;
  76. w = kSize.width - 2*x;
  77. h = kSize.height - y - kSize.height/6.0;
  78. setTrainInfoView = [[UIView alloc] setxywh];
  79. setTrainInfoView.backgroundColor = [UIColor colorWithWhite:.7 alpha:.2];
  80. [self.view addSubview:setTrainInfoView];
  81. y = 10;
  82. w -= 2*x;
  83. h = 40;
  84. label = [[UILabel alloc] setxywh];
  85. [label setText:@"设置培训信息" Font:Font17 TextColor:[UIColor whiteColor] Alignment:NSTextAlignmentCenter];
  86. [setTrainInfoView addSubview:label];
  87. [label addViewWithRect:CGRectMake(x + 30, y + 19, w/2.0 - 100, 1) Color:[UIColor colorWithWhite:.7 alpha:.5]];
  88. [label addViewWithRect:CGRectMake(kSize.width/2.0 + 50, y + 19, w/2.0 - 100, 1) Color:[UIColor colorWithWhite:.7 alpha:.5]];
  89. x = 10;
  90. y += h + 20;
  91. w = (setTrainInfoView.width - 2*x)/3.0;
  92. h = 30;
  93. label = [[UILabel alloc] setxywh];
  94. [label setText:@"培训科目:" Font:Font17 TextColor:newTitleColor Alignment:NSTextAlignmentLeft];
  95. [setTrainInfoView addSubview:label];
  96. x += w;
  97. keMuString = @"2";
  98. UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
  99. button.frame = setDIYFrame;
  100. [button setImage:[UIImage imageNamed:@"selectAll"] Tit:@"科目二" Font:Font16 State:UIControlStateNormal];
  101. [button setImage:[UIImage imageNamed:@"selectedAll"] forState:UIControlStateSelected];
  102. [button setTitleColor:newTitleColor forState:UIControlStateNormal];
  103. [button setTitleColor:defGreen forState:UIControlStateSelected];
  104. [button target:self Tag:2];
  105. [setTrainInfoView addSubview:button];
  106. button.selected = YES;
  107. keErBtn = button;
  108. x += w;
  109. button = [UIButton buttonWithType:UIButtonTypeCustom];
  110. button.frame = setDIYFrame;
  111. [button setImage:[UIImage imageNamed:@"selectAll"] Tit:@"科目三" Font:Font16 State:UIControlStateNormal];
  112. [button setImage:[UIImage imageNamed:@"selectedAll"] forState:UIControlStateSelected];
  113. [button setTitleColor:newTitleColor forState:UIControlStateNormal];
  114. [button setTitleColor:defGreen forState:UIControlStateSelected];
  115. [button target:self Tag:3];
  116. [setTrainInfoView addSubview:button];
  117. keSanBtn = button;
  118. x = 10;
  119. y += h + 20;
  120. w = setTrainInfoView.width - 2*x;
  121. label = [[UILabel alloc] setxywh];
  122. [label setText:@"培训价格:" Font:Font17 TextColor:newTitleColor Alignment:NSTextAlignmentLeft];
  123. [setTrainInfoView addSubview:label];
  124. [label addViewWithRect:CGRectMake(x, y+h, w, 1) Color:backGroundColor];
  125. y += h + 1;
  126. h = setTrainInfoView.height - y;
  127. priceString = @"免费";
  128. UITableView *tableView = [[UITableView alloc] initWithFrame:setDIYFrame style:UITableViewStyleGrouped];
  129. tableView.backgroundColor = [UIColor clearColor];
  130. tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLineEtched;
  131. tableView.delegate = self;
  132. tableView.dataSource = self;
  133. tableView.estimatedSectionHeaderHeight = 0;
  134. tableView.estimatedSectionFooterHeight = 0;
  135. [setTrainInfoView addSubview:tableView];
  136. priceTableView = tableView;
  137. setTrainInfoView.hidden = YES;
  138. moneyArr = [NSArray array];
  139. [self getStudentTrainInfos];
  140. [self getTrainPrice];
  141. }
  142. -(void)viewDidDisappear:(BOOL)animated {
  143. [super viewDidDisappear:animated];
  144. if (timer) {
  145. [timer invalidate];
  146. timer = nil;
  147. }
  148. if (preTimer) {
  149. [preTimer invalidate];
  150. preTimer = nil;
  151. }
  152. }
  153. -(void)dismissNavgation
  154. {
  155. //推送过来 返回主页面 不晓得能不能行--推送 待测试 dansonmark
  156. ViewController *vc = [ViewController new];
  157. MyUINavigationController *nav = [[MyUINavigationController alloc] initWithRootViewController:vc];
  158. [UIApplication sharedApplication].delegate.window.rootViewController = nav;
  159. }
  160. - (void)loadStudentInfoWithDic:(NSDictionary *)dic {
  161. //这里还没有生成展示学员信息的控件 或者已换学员带教 重新布局
  162. /*
  163. body = {
  164. HEADIMG = "http://image.jppt.com.cn/tms/student/201703/14897144128021583.jpg";
  165. STATE = 2;
  166. STUNAME = "\U6768\U4e3d\U4e3d";
  167. SCHOOLNAME = "\U798f\U5efa\U6781\U901f\U9a7e\U57f9\U6d4b\U8bd5\U9a7e\U6821";
  168. IDCARD = 350881199205290949;
  169. PHONE = 13235006144;
  170. ONE = 720; 科目一已完成学时
  171. ONESEND = 0;
  172. ONESTATUS = 1;
  173. TWO = 18716;
  174. TWOSEND = 0;
  175. TWOSTATUS = 1;
  176. THREE = 0;
  177. THREESEND = 0;
  178. THREESTATUS = 0;
  179. FOUR = 0;
  180. FOURSEND = 0;
  181. FOURSTATUS = 0;
  182. TRAINTYPE = C1;//培训车型
  183. TOTALMILE = 0;//总里程
  184. noVaildTime = 43;//无效学时
  185. notAuditTime = 0;//未审核学时
  186. totalTime = 1;//总时长
  187. vaildTime = 0;//有效学时
  188. subject = 2;
  189. AVGSPEED = 0;//平均速度
  190. };
  191. */
  192. for (UIView *view in stuInfoView.subviews) {
  193. [view removeFromSuperview];
  194. }
  195. subjectLabel.text = [NSString stringWithFormat:@"带教科目:%@",[dic[@"STATE"] isEqualToString:@"2"]?@"科目二":@"科目三"];
  196. priceLabel.text = [NSString stringWithFormat:@"带教价格:已设置"];
  197. UIScrollView *scroll = [[UIScrollView alloc] initWithFrame:stuInfoView.bounds];
  198. [stuInfoView addSubview:scroll];
  199. CGFloat x, y, w, h;
  200. x = 20;
  201. y = 10;
  202. w = 70;
  203. h = 80;
  204. UIImageView *headerImg = [[UIImageView alloc] setxywh];
  205. headerImg.backgroundColor = [UIColor colorWithWhite:.7 alpha:.2];
  206. [headerImg borderColor:[UIColor whiteColor] width:.3 cornorRadios:3];
  207. [headerImg sd_setImageWithURL:[NSURL URLWithString:dic[@"HEADIMG"]] placeholderImage:[UIImage imageNamed:@"noHeadImg"]];
  208. [scroll addSubview:headerImg];
  209. x += w + 10;
  210. w = kSize.width - x - 20;
  211. h = 30;
  212. //姓名
  213. UILabel *label = [[UILabel alloc] setxywh];
  214. [label setText:[dic[@"STATE"] isEqualToString:@"2"]?@"科目二学员":@"科目三学员" Font:Font17 TextColor:newSubTitleColor Alignment:NSTextAlignmentRight];
  215. [scroll addSubview:label];
  216. stuNamelabel = label;
  217. //科目
  218. label = [[UILabel alloc] setxywh];
  219. [label setText:dic[@"STUNAME"] Font:Font21 TextColor:newTitleColor];
  220. [scroll addSubview:label];
  221. y += h;
  222. h = 25;
  223. //电话
  224. label = [[UILabel alloc] setxywh];
  225. [label setText:dic[@"PHONE"] Font:Font18 TextColor:newSubTitleColor];
  226. [scroll addSubview:label];
  227. y += h;
  228. //驾校
  229. label = [[UILabel alloc] setxywh];
  230. [label setText:dic[@"SCHOOLNAME"] Font:Font18 TextColor:newSubTitleColor];
  231. [scroll addSubview:label];
  232. y += h + 20;
  233. x = 15;
  234. w = kSize.width - 2*x;
  235. h = 30;
  236. label = [[UILabel alloc] setxywh];
  237. [label setText:@"学员学时信息" Font:Font18 TextColor:newTitleColor Alignment:NSTextAlignmentCenter];
  238. [scroll addSubview:label];
  239. UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem];
  240. btn.backgroundColor = [UIColor brownColor];
  241. btn.frame = CGRectMake(kSize.width - 120 - x, y, 120, h);
  242. btn.backgroundColor = [UIColor colorWithWhite:.7 alpha:.2];
  243. [btn setTitle:@"查看训练照片" textColor:defGreen font:Font18 fotState:UIControlStateNormal];
  244. // [btn borderColor:defGreen width:1 cornorRadios:5];
  245. [btn target:self Tag:101];
  246. [scroll addSubview:btn];
  247. y += h + 5;
  248. [label addViewWithRect:CGRectMake(x, y, w, 1) Color:newSubTitleColor];
  249. [label addViewWithRect:CGRectMake(x, y + 50, w, 1) Color:newSubTitleColor];
  250. [label addViewWithRect:CGRectMake(x, y + 75, w, 1) Color:newSubTitleColor];
  251. [label addViewWithRect:CGRectMake(x, y + 100, w, 1) Color:newSubTitleColor];
  252. [label addViewWithRect:CGRectMake(x, y + 125, w, 1) Color:newSubTitleColor];
  253. [label addViewWithRect:CGRectMake(x, y + 150, w, 1) Color:newSubTitleColor];
  254. w = w/4.0;
  255. [label addViewWithRect:CGRectMake(x, y, 1, 150) Color:newSubTitleColor];
  256. [label addViewWithRect:CGRectMake(x + w, y, 1, 150) Color:newSubTitleColor];
  257. [label addViewWithRect:CGRectMake(x + 2*w, y, 1, 150) Color:newSubTitleColor];
  258. [label addViewWithRect:CGRectMake(x + 3*w, y, 1, 150) Color:newSubTitleColor];
  259. [label addViewWithRect:CGRectMake(x + 4*w, y, 1, 150) Color:newSubTitleColor];
  260. NSArray *titleArray = @[@"培训阶段",@"当前完成学时",@"学时审核状态",@"学时是否已传输"];
  261. for (int i = 0; i < titleArray.count; i ++) {
  262. label = [[UILabel alloc] initWithFrame:CGRectMake(x + 5 + i*w, y + 1, w - 10, 49)];
  263. [label setText:titleArray[i] Font:Font17 TextColor:newSubTitleColor Alignment:NSTextAlignmentCenter];
  264. label.numberOfLines = 0;
  265. [scroll addSubview:label];
  266. }
  267. y += 50;
  268. NSArray *subjectArray = @[@"第一阶段",@"第二阶段",@"第三阶段",@"第四阶段"];
  269. NSArray *trainTimeArray = @[dic[@"ONE"],dic[@"TWO"],dic[@"THREE"],dic[@"FOUR"]];
  270. NSArray *stateArray = @[dic[@"ONESTATUS"],dic[@"TWOSTATUS"],dic[@"THREESTATUS"],dic[@"FOURSTATUS"]];
  271. NSArray *sendArray = @[dic[@"ONESEND"],dic[@"TWOSEND"],dic[@"THREESEND"],dic[@"FOURSEND"]];
  272. for (int i = 0; i < subjectArray.count; i ++) {
  273. //阶段
  274. label = [[UILabel alloc] initWithFrame:CGRectMake(x, y + 1 + i*25, w, 24)];
  275. [label setText:subjectArray[i] Font:Font16 TextColor:newSubTitleColor Alignment:NSTextAlignmentCenter];
  276. [scroll addSubview:label];
  277. //学时
  278. label = [[UILabel alloc] initWithFrame:CGRectMake(x + w, y + 1 + i*25, w, 24)];
  279. int time = [trainTimeArray[i] intValue];
  280. int hour = time/60;
  281. int min = time%60;
  282. NSString *timeString = @"";
  283. if (hour == 0) {
  284. timeString = [NSString stringWithFormat:@"%d分钟",min];
  285. }else{
  286. timeString = [NSString stringWithFormat:@"%d时%d分",hour,min];
  287. }
  288. [label setText:timeString Font:Font16 TextColor:newSubTitleColor Alignment:NSTextAlignmentCenter];
  289. [scroll addSubview:label];
  290. //审核状态
  291. label = [[UILabel alloc] initWithFrame:CGRectMake(x + 2*w, y + 1 + i*25, w, 24)];
  292. NSString *stateString = stateArray[i];
  293. switch ([stateString intValue]) {
  294. case 0:
  295. stateString = @"不允许送审";
  296. break;
  297. case 1:
  298. stateString = @"允许送审";
  299. break;
  300. case 2:
  301. stateString = @"审核通过";
  302. break;
  303. case 3:
  304. stateString = @"退回";
  305. break;
  306. case 4:
  307. stateString = @"待审核";
  308. break;
  309. default:
  310. stateString = @"";
  311. break;
  312. }
  313. [label setText:stateString Font:Font16 TextColor:newSubTitleColor Alignment:NSTextAlignmentCenter];
  314. [scroll addSubview:label];
  315. //是否传至交警
  316. label = [[UILabel alloc] initWithFrame:CGRectMake(x + 3*w, y + 1 + i*25, w, 24)];
  317. NSString *sendString = sendArray[i];
  318. switch ([sendString intValue]) {
  319. case 0:
  320. sendString = @"未传输";
  321. break;
  322. case 1:
  323. sendString = @"已传至运管";
  324. break;
  325. case 2:
  326. sendString = @"已传至交警";
  327. break;
  328. default:
  329. sendString = @"";
  330. break;
  331. }
  332. [label setText:sendString Font:Font16 TextColor:newSubTitleColor Alignment:NSTextAlignmentCenter];
  333. [scroll addSubview:label];
  334. }
  335. x = 15;
  336. y += 100 + 20;
  337. w = kSize.width - 2*x;
  338. h = 30;
  339. label = [[UILabel alloc] setxywh];
  340. [label setText:@"当前培训信息" Font:Font18 TextColor:newTitleColor Alignment:NSTextAlignmentCenter];
  341. [scroll addSubview:label];
  342. btn = [UIButton buttonWithType:UIButtonTypeSystem];
  343. btn.backgroundColor = [UIColor brownColor];
  344. btn.frame = CGRectMake(kSize.width-120-x, y, 120, h);
  345. btn.backgroundColor = [UIColor colorWithWhite:.7 alpha:.2];
  346. [btn setTitle:@"查看分钟学时" textColor:defGreen font:Font18 fotState:UIControlStateNormal];
  347. // [btn borderColor:defGreen width:1 cornorRadios:5];
  348. [btn target:self Tag:100];
  349. [scroll addSubview:btn];
  350. y += h+5;
  351. [label addViewWithRect:CGRectMake(x, y, w, 1) Color:newSubTitleColor];
  352. [label addViewWithRect:CGRectMake(x, y + 59, w, 1) Color:newSubTitleColor];
  353. [label addViewWithRect:CGRectMake(x, y, 1, 60) Color:newSubTitleColor];
  354. [label addViewWithRect:CGRectMake(x + w, y, 1, 60) Color:newSubTitleColor];
  355. w = w/4.0;
  356. h = 30;
  357. NSArray *titles = @[@"总时长",@"有效时长",@"无效时长",@"待审核"];
  358. NSArray *textArray = @[dic[@"totalTime"],dic[@"vaildTime"],dic[@"noVaildTime"],dic[@"notAuditTime"]];
  359. NSArray *colors = @[newTitleColor,[UIColor greenColor],[UIColor redColor],defGreen];
  360. NSMutableArray *labels = [NSMutableArray arrayWithCapacity:4];
  361. for (int i = 0; i < titles.count; i ++) {
  362. label = [[UILabel alloc] initWithFrame:CGRectMake(x + i*w, y, w, h)];
  363. label.backgroundColor = [UIColor colorWithWhite:.7 alpha:.2];
  364. [label setText:titles[i] Font:Font16 TextColor:newTitleColor Alignment:NSTextAlignmentCenter];
  365. [scroll addSubview:label];
  366. label = [[UILabel alloc] initWithFrame:CGRectMake(x + i*w, y + h, w, h)];
  367. [label setText:[NSString stringWithFormat:@"%@分钟",textArray[i]] Font:Font16 TextColor:colors[i] Alignment:NSTextAlignmentCenter];
  368. [scroll addSubview:label];
  369. [labels addObject:label];
  370. if (i != 0) {
  371. [label addViewWithRect:CGRectMake(x + i*w, y, 1, 2*h) Color:newSubTitleColor];
  372. }
  373. }
  374. allTimeLabel = labels[0];
  375. valueTimeLabel = labels[1];
  376. invalidTimeLabel = labels[2];
  377. waitTimeLabel = labels[3];
  378. x = 20;
  379. y += 70;
  380. w = kSize.width - 2*x;
  381. h = 60;
  382. label = [[UILabel alloc] setxywh];
  383. [label setText:[NSString stringWithFormat:@"当前培训过程中,车辆平均速度为%.2fKm/h,行驶总里程为%.2fKm,有效学时占比为%.1f%%",[dic[@"AVGSPEED"] floatValue],[dic[@"TOTALMILE"] floatValue], ([dic[@"vaildTime"] floatValue] == 0 || [dic[@"totalTime"] floatValue] == 0)? 0 : [dic[@"vaildTime"] floatValue]/[dic[@"totalTime"] floatValue]*100] Font:Font17 TextColor:newTitleColor];
  384. label.numberOfLines = 0;
  385. [scroll addSubview:label];
  386. mileAndSpeedLabel = label;
  387. [scroll setContentSize:CGSizeMake(stuInfoView.width, CGRectGetMaxY(mileAndSpeedLabel.frame) + 50)];
  388. }
  389. - (void)setStudentInfoWithDic:(NSDictionary *)dic {
  390. //这里已经有展示学员信息的控件了 直接填入数据
  391. allTimeLabel.text = [NSString stringWithFormat:@"%@分钟",dic[@"totalTime"]];
  392. valueTimeLabel.text = [NSString stringWithFormat:@"%@分钟",dic[@"vaildTime"]];
  393. invalidTimeLabel.text = [NSString stringWithFormat:@"%@分钟",dic[@"noVaildTime"]];
  394. waitTimeLabel.text = [NSString stringWithFormat:@"%@分钟",dic[@"notAuditTime"]];
  395. mileAndSpeedLabel.text = [NSString stringWithFormat:@"当前培训过程中,车辆平均速度为%.2fKm/h,行驶总里程为%.2fKm,有效学时占比为%.1f%%",[dic[@"AVGSPEED"] floatValue],[dic[@"TOTALMILE"] floatValue],([dic[@"vaildTime"] floatValue] == 0 || [dic[@"totalTime"] floatValue] == 0)? 0 : [dic[@"vaildTime"] floatValue]/[dic[@"totalTime"] floatValue]*100];
  396. }
  397. - (void)btnClick:(UIButton *)sender {
  398. if (sender.tag == -1) {
  399. //正在调接口 现在还不能请求
  400. ShowMsg(@"数据加载中,请稍后!");
  401. return;
  402. }
  403. if (sender.tag == -2) {
  404. //正在带教学员 不能更改价格信息
  405. ShowMsg(@"终端正在带教学员,不能更改培训信息!");
  406. return;
  407. }
  408. if (sender.tag == 1) {
  409. setTrainInfoView.hidden = !setTrainInfoView.isHidden;
  410. stuInfoView.hidden = !stuInfoView.isHidden;
  411. if (setTrainInfoView.isHidden) {//点击完成按钮 设置价格科目
  412. [setTrainInfoBtn setTitle:@"设置" forState:UIControlStateNormal];
  413. [self setDevTrainSubjectAndMoney];
  414. }else {
  415. [setTrainInfoBtn setTitle:@"完成" forState:UIControlStateNormal];
  416. }
  417. return;
  418. }
  419. if (sender.tag == 2) {
  420. if (keSanBtn.isSelected == YES) {
  421. keSanBtn.selected = NO;
  422. }
  423. keErBtn.selected = YES;
  424. keMuString = @"2";
  425. subjectLabel.text = @"带教科目:科目二";
  426. return;
  427. }
  428. if (sender.tag == 3) {
  429. if (keErBtn.isSelected == YES) {
  430. keErBtn.selected = NO;
  431. }
  432. keSanBtn.selected = YES;
  433. keMuString = @"3";
  434. subjectLabel.text = @"带教科目:科目三";
  435. return;
  436. }
  437. //查看分钟学时
  438. if (sender.tag == 100) {
  439. MinRescord *vc = [[MinRescord alloc]init];
  440. vc.stuID = dataDic[@"stuId"];
  441. vc.classId = dataDic[@"classId"];
  442. [self.navigationController pushViewController:vc animated:YES];
  443. }
  444. //查看训练照片
  445. if (sender.tag == 101) {
  446. SelectImgVC *vc = [[SelectImgVC alloc] init];
  447. vc.stuDic = dataDic;
  448. [self.navigationController pushViewController:vc animated:YES];
  449. }
  450. }
  451. #pragma mark tableView
  452. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  453. {
  454. return moneyArr.count + 1;
  455. }
  456. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  457. {
  458. //表示是价格选择的表
  459. PriceCell *cell = [tableView dequeueReusableCellWithIdentifier:@"priceCell"];
  460. if (cell == nil) {
  461. cell = [[[NSBundle mainBundle] loadNibNamed:@"PriceCell" owner:nil options:nil] firstObject];
  462. cell.backgroundColor = [UIColor clearColor];
  463. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  464. }
  465. NSDictionary *dic;
  466. if (indexPath.row == 0) {
  467. NSString *carType = @"";
  468. if (moneyArr.count > 0) {
  469. carType = [[moneyArr firstObject] objectForKey:@"CSI_VEHICLETYPE"];
  470. }
  471. dic = @{@"CSI_PRICE":@"免费",@"CSI_VEHICLETYPE":carType,@"CSI_TRAINNINGTIME":@"0"};
  472. }else{
  473. dic = moneyArr[indexPath.row - 1];
  474. }
  475. [cell.indexLabel setText:[NSString stringWithFormat:@"%d、",(int)indexPath.row + 1] Font:Font16 TextColor:newTitleColor Alignment:NSTextAlignmentRight];
  476. cell.priceDic = dic;
  477. return cell;
  478. }
  479. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  480. {
  481. if (indexPath.row == 0) {
  482. priceString = @"免费";
  483. }else{
  484. NSDictionary *dic = moneyArr[indexPath.row - 1];
  485. priceString = dic[@"CSI_PRICE"];
  486. }
  487. priceLabel.text = [NSString stringWithFormat:@"带教价格:%@",priceString];
  488. UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
  489. [cell.textLabel setTextColor:defGreen];
  490. if (priceCell) {
  491. [priceCell.textLabel setTextColor:newTitleColor];
  492. }
  493. priceCell = cell;
  494. }
  495. -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  496. {
  497. return 0.1;
  498. }
  499. -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
  500. {
  501. return 0.1;
  502. }
  503. #pragma mark 数据请求
  504. - (void)getStudentTrainInfos
  505. {
  506. [LoadingView showHUD];
  507. if (![Util connectedToNetWork]) {
  508. showMsgUnconnect();
  509. setTrainInfoBtn.tag = 1;
  510. return;
  511. }
  512. //查询学员签到列表 科目传空 查全部
  513. NSMutableArray *arr = [NSMutableArray array];
  514. [arr addPro:@"coachId" Value:defUser.userDict[@"outId"]];
  515. [arr addPro:@"dqbh" Value:defUser.userDict[@"cityId"]];
  516. NSString* method = @"getStudentTrainInfos";
  517. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary *root) {
  518. RemoveHUD();
  519. setTrainInfoBtn.tag = 1;
  520. if (!root) {
  521. return ;
  522. }
  523. if ([root[@"code"] isEqualToString:@"1"]) {
  524. //没有带教学员0.0
  525. for (UIView *view in stuInfoView.subviews) {
  526. [view removeFromSuperview];
  527. }
  528. UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(20, 10, kSize.width - 40, 50)];
  529. [label setText:@"暂未查询到正在带教学员!" Font:Font18 TextColor:newTitleColor];
  530. [stuInfoView addSubview:label];
  531. if (preTimer == nil) {
  532. preTimer = [NSTimer scheduledTimerWithTimeInterval:7 target:self selector:@selector(getStudentTrainInfos) userInfo:nil repeats:YES];
  533. }
  534. if (timer) {
  535. [timer invalidate];
  536. timer = nil;
  537. }
  538. return;
  539. }
  540. dataDic = root[@"body"];
  541. //生成学员信息
  542. setTrainInfoBtn.tag = -2;
  543. if (stuInfoView.subviews.count < 2) {
  544. [self loadStudentInfoWithDic:root[@"body"]];
  545. }else{
  546. if (![[root[@"body"] objectForKey:@"STUNAME"] isEqualToString:stuNamelabel.text]) {
  547. [self loadStudentInfoWithDic:root[@"body"]];
  548. }else {
  549. [self setStudentInfoWithDic:root[@"body"]];
  550. }
  551. }
  552. if (preTimer) {
  553. [preTimer invalidate];
  554. preTimer = nil;
  555. }
  556. if (timer == nil) {
  557. timer = [NSTimer scheduledTimerWithTimeInterval:70 target:self selector:@selector(getStudentTrainInfos) userInfo:nil repeats:YES];
  558. }
  559. }];
  560. }
  561. //获取价格
  562. -(void)getTrainPrice
  563. {
  564. [priceTableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:NO scrollPosition:UITableViewScrollPositionTop];
  565. NSMutableArray *arr=[NSMutableArray array];
  566. [arr addPro:@"schoolId" Value:defUser.userDict[@"jxbh"]];
  567. [arr addPro:@"dqbh" Value:defUser.userDict[@"cityId"]];
  568. NSString* method = @"getPrice";
  569. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * dict) {
  570. //NSLog(@"获取价格-->%@->%@",arr,dict);
  571. if (!dict) {
  572. return ;
  573. }
  574. if ( [dict[@"code"] isEqualToString:@"1"]) {
  575. return ;
  576. }
  577. moneyArr = dict[@"body"];
  578. [priceTableView reloadData];
  579. [priceTableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:NO scrollPosition:UITableViewScrollPositionTop];
  580. }];
  581. }
  582. //设置价格
  583. -(void)setDevTrainSubjectAndMoney
  584. {
  585. NSMutableArray *arr=[NSMutableArray array];
  586. [arr addPro:@"coachId" Value:defUser.userDict[@"jxbh"]];
  587. [arr addPro:@"dqbh" Value:defUser.userDict[@"cityId"]];
  588. [arr addPro:@"isPay" Value:[priceString isEqualToString:@"免费"]?@"0":@"1"];
  589. [arr addPro:@"money" Value:priceString];
  590. NSString* method = @"setDevTrainSubjectAndMoney";
  591. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * dict) {
  592. if (!dict) {
  593. ShowMsg(@"设置培训信息失败,请重试!");
  594. subjectLabel.text = @"带教科目:未设置";
  595. priceLabel.text = @"带教价格:未设置";
  596. return ;
  597. }
  598. if ( [dict[@"code"] isEqualToString:@"1"]) {
  599. ShowMsg(dict[@"body"]);
  600. subjectLabel.text = @"带教科目:未设置";
  601. priceLabel.text = @"带教价格:未设置";
  602. return ;
  603. }
  604. ShowMsg(@"培训信息设置成功!");
  605. }];
  606. }
  607. - (void)didReceiveMemoryWarning {
  608. [super didReceiveMemoryWarning];
  609. // Dispose of any resources that can be recreated.
  610. }
  611. @end