ModelVC.m 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678
  1. //
  2. // ModelVC.m
  3. // JSJPCoach
  4. //
  5. // Created by apple on 2017/3/22.
  6. // Copyright © 2017年 Danson. All rights reserved.
  7. //
  8. #import "ModelVC.h"
  9. #import "ModelLeftCell.h"
  10. #import "ModelRightCell.h"
  11. #import "ModelTVHeaderView.h"
  12. #import "PriceCell.h"
  13. @interface ModelVC ()<UIScrollViewDelegate,UITableViewDelegate,UITableViewDataSource,UIAlertViewDelegate>
  14. {
  15. UIScrollView *mainScroll;
  16. //实时
  17. UIButton *keErBtn, *keSanBtn;
  18. UITableView *priceTableView;
  19. UITableViewCell *priceCell;
  20. NSArray *moneyArr;
  21. NSString *keMuString;
  22. NSString *priceString;
  23. //预约
  24. UITableView *leftTableView;
  25. UITableView *rightTableView;
  26. NSArray *planArray;
  27. NSDictionary *planDic;
  28. BOOL _isScrollDown;
  29. NSInteger _selectIndex;
  30. NSInteger rightIndex;
  31. NSMutableArray *_btnArray;
  32. NSInteger btnIndex;
  33. NSString *RO_STATUS;
  34. }
  35. @end
  36. @implementation ModelVC
  37. - (void)viewDidLoad {
  38. [super viewDidLoad];
  39. self.view.backgroundColor = [UIColor whiteColor];
  40. planArray = [NSArray array];
  41. _selectIndex = 0;
  42. rightIndex = -1;
  43. //默认选择实时0元
  44. btnIndex = 2;
  45. priceString = @"免费";
  46. UIImageView *backImageView = [[UIImageView alloc] initWithFrame:kFrame];
  47. backImageView.image = [UIImage imageNamed:@"bgImage"];
  48. [self.view addSubview:backImageView];
  49. CGFloat x,y,w,h;
  50. //完成按钮
  51. x = 20;
  52. y = kSize.height - kSize.height/6.0;
  53. h = kSize.height/6.0 - 20;
  54. if (h > 80) {
  55. h = 80;
  56. y += (kSize.height/6.0 - 100)/2.0;
  57. }
  58. w = h/1.46;
  59. y += (h - w)/2 + 5;
  60. h = w;
  61. UIButton *modelBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  62. modelBtn.frame = setDIYFrame;
  63. [modelBtn setRound];
  64. modelBtn.backgroundColor = RGB_COLOR(145, 160, 175);
  65. [modelBtn setTitle:@"完成" textColor:[UIColor blackColor] font:Font16 fotState:UIControlStateNormal];
  66. [modelBtn target:self Tag:1];
  67. [self.view addSubview:modelBtn];
  68. //
  69. w = kSize.width - 2*x;
  70. h = y - kNavOffSet;
  71. y = kSegmentHeight;
  72. UIImageView *bgImage = [[UIImageView alloc] setxywh];
  73. bgImage.backgroundColor = [UIColor colorWithWhite:.7 alpha:.2];
  74. [self.view addSubview:bgImage];
  75. h = 40;
  76. UILabel *label = [[UILabel alloc] setxywh];
  77. [label setText:@"带教类型" Font:Font17 TextColor:[UIColor whiteColor] Alignment:NSTextAlignmentCenter];
  78. [self.view addSubview:label];
  79. [label addViewWithRect:CGRectMake(x + 30, y + 19, w/2.0 - 80, 1) Color:[UIColor colorWithWhite:.7 alpha:.5]];
  80. [label addViewWithRect:CGRectMake(kSize.width/2.0 + 50, y + 19, w/2.0 - 80, 1) Color:[UIColor colorWithWhite:.7 alpha:.5]];
  81. //
  82. x += 30;
  83. y += h;
  84. h = h*1.3;
  85. w = kSize.width - 2*x;
  86. UIView *btnBar = [[UIView alloc] setxywh];//16 24 50
  87. btnBar.backgroundColor = RGB_COLOR(16, 24, 50);
  88. [btnBar borderColor:[UIColor colorWithWhite:.7 alpha:.2] width:1 cornorRadios:h/2.0];
  89. [self.view addSubview:btnBar];
  90. NSArray *titleArray = @[@"实时",@"预约",@"模拟"];
  91. w = w/(titleArray.count);
  92. _btnArray = [NSMutableArray arrayWithCapacity:titleArray.count];
  93. for (int i = 0; i<3; i ++)
  94. {
  95. UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(w*i,5,w,h - 10)];
  96. [button borderColor:RGB_COLOR(16, 24, 50) width:1 cornorRadios:h/2.0 - 5];
  97. [button setTitle:[titleArray objectAtIndex:i] textColor:[UIColor whiteColor] font:Font18 fotState:UIControlStateNormal];
  98. [button target:self Tag:i + 2];
  99. [btnBar addSubview:button];
  100. [_btnArray addObject:button];
  101. if (i == 0) {
  102. button.selected = YES;
  103. button.backgroundColor = defGreen;
  104. btnIndex = button.tag;
  105. }
  106. }
  107. //
  108. x = 20;
  109. w = kSize.width - 2*x;
  110. y += h + 20;
  111. h = modelBtn.y - y - kStatusHeight;
  112. mainScroll = [[UIScrollView alloc] setxywh];
  113. mainScroll.contentSize = CGSizeMake(3*w, h);
  114. [mainScroll setShowsHorizontalScrollIndicator:NO];
  115. [mainScroll setPagingEnabled:YES];
  116. [mainScroll setDecelerationRate:.2];
  117. mainScroll.delegate = self;
  118. [self.view addSubview:mainScroll];
  119. UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, w, h)];
  120. [mainScroll addSubview:view];
  121. UIView *scrollView1 = view;
  122. view = [[UIView alloc] initWithFrame:CGRectMake(w, 0, w, h)];
  123. [mainScroll addSubview:view];
  124. UIView *scrollView2 = view;
  125. view = [[UIView alloc] initWithFrame:CGRectMake(2*w, 0, w, h)];
  126. [mainScroll addSubview:view];
  127. // UIView *scrollView3 = view;
  128. //实时
  129. x = 10;
  130. y = 20;
  131. w = (w-20)/3.0;
  132. h = 30;
  133. label = [[UILabel alloc] setxywh];
  134. [label setText:@"培训科目:" Font:Font17 TextColor:newTitleColor Alignment:NSTextAlignmentLeft];
  135. [scrollView1 addSubview:label];
  136. x += w;
  137. keMuString = @"2";
  138. UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
  139. button.frame = setDIYFrame;
  140. [button setImage:[UIImage imageNamed:@"selectAll"] Tit:@"科目二" Font:Font16 State:UIControlStateNormal];
  141. [button setImage:[UIImage imageNamed:@"selectedAll"] forState:UIControlStateSelected];
  142. [button setTitleColor:newTitleColor forState:UIControlStateNormal];
  143. [button setTitleColor:defGreen forState:UIControlStateSelected];
  144. [button target:self Tag:5];
  145. [scrollView1 addSubview:button];
  146. button.selected = YES;
  147. keErBtn = button;
  148. x += w;
  149. button = [UIButton buttonWithType:UIButtonTypeCustom];
  150. button.frame = setDIYFrame;
  151. [button setImage:[UIImage imageNamed:@"selectAll"] Tit:@"科目三" Font:Font16 State:UIControlStateNormal];
  152. [button setImage:[UIImage imageNamed:@"selectedAll"] forState:UIControlStateSelected];
  153. [button setTitleColor:newTitleColor forState:UIControlStateNormal];
  154. [button setTitleColor:defGreen forState:UIControlStateSelected];
  155. [button target:self Tag:6];
  156. [scrollView1 addSubview:button];
  157. keSanBtn = button;
  158. x = 10;
  159. y += h + 20;
  160. w = scrollView1.width - 2*x;
  161. label = [[UILabel alloc] setxywh];
  162. [label setText:@"培训价格:" Font:Font17 TextColor:newTitleColor Alignment:NSTextAlignmentLeft];
  163. [scrollView1 addSubview:label];
  164. [label addViewWithRect:CGRectMake(x, y+h, w, 1) Color:backGroundColor];
  165. y += h + 1;
  166. h = scrollView1.height - y;
  167. UITableView *tableView = [[UITableView alloc] initWithFrame:setDIYFrame style:UITableViewStyleGrouped];
  168. tableView.backgroundColor = [UIColor clearColor];
  169. tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLineEtched;
  170. tableView.delegate = self;
  171. tableView.dataSource = self;
  172. [scrollView1 addSubview:tableView];
  173. priceTableView = tableView;
  174. //预约
  175. x = y = 0;
  176. w = 90;
  177. if (kSize.width > 320.0) {
  178. w = 110;
  179. }
  180. h = scrollView2.height;
  181. leftTableView = [[UITableView alloc] initWithFrame:setDIYFrame style:UITableViewStylePlain];
  182. leftTableView.backgroundColor = [UIColor clearColor];
  183. leftTableView.delegate = self;
  184. leftTableView.dataSource = self;
  185. leftTableView.rowHeight = 60;
  186. leftTableView.tableFooterView = [UIView new];
  187. leftTableView.showsVerticalScrollIndicator = NO;
  188. [scrollView2 addSubview:leftTableView];
  189. x += w;
  190. w = scrollView1.width - w;
  191. rightTableView = [[UITableView alloc] initWithFrame:setDIYFrame style:UITableViewStyleGrouped];
  192. rightTableView.backgroundColor = [UIColor clearColor];
  193. rightTableView.delegate = self;
  194. rightTableView.dataSource = self;
  195. rightTableView.rowHeight = 80;
  196. rightTableView.showsVerticalScrollIndicator = NO;
  197. rightTableView.separatorColor = [UIColor clearColor];
  198. [scrollView2 addSubview:rightTableView];
  199. //模拟
  200. //数据获取
  201. [self getTrainPrice];
  202. [self getPlanInfos];
  203. }
  204. - (void)btnClick:(UIButton *)sender
  205. {
  206. if (sender.tag == 1) {
  207. //如果没有有效的选择 就提示是否确定 234 "实时",@"预约",@"模拟"
  208. NSString *audioString = @"您已选择模拟带教";
  209. if (btnIndex == 2) {
  210. if (priceString.length < 1) {
  211. //未选择价格
  212. UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"请选择实时带教价格,否则将无法开始带教" delegate:nil cancelButtonTitle:@"确认" otherButtonTitles:nil, nil];
  213. [alert show];
  214. return;
  215. }
  216. NSDictionary *dic = @{@"subject":keMuString,@"price":priceString,@"periodType":@"1"};
  217. _superVC.periodType = 1;
  218. _superVC.periodDic = dic;
  219. audioString = [NSString stringWithFormat:@"您已选择%@实时带教",[keMuString isEqualToString:@"2"] ? @"科目二":@"科目三"];
  220. }
  221. if (btnIndex == 3) {
  222. if (![planDic isKindOfClass:[NSDictionary class]] || planDic.count < 1) {
  223. UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"请选择将要带教的学员,否则将无法开始带教" delegate:nil cancelButtonTitle:@"确认" otherButtonTitles:nil, nil];
  224. [alert show];
  225. return;
  226. }
  227. if (RO_STATUS) {
  228. if (RO_STATUS.length > 0) {
  229. ShowMsg(@"您已带教该预约!");
  230. [Tools playAudioWithString:@"您已带教该预约!"];
  231. return;
  232. }
  233. }
  234. _superVC.periodType = 2;
  235. _superVC.periodDic = planDic;
  236. audioString = [NSString stringWithFormat:@"您已选择预约模式,带教学员为%@",planDic[@"userName"]];
  237. //userName
  238. }
  239. if (btnIndex == 4) {
  240. _superVC.periodType = 3;
  241. }
  242. [self dismissViewControllerAnimated:NO completion:^{
  243. [Tools playAudioWithString:audioString];
  244. }];
  245. return;
  246. }
  247. // 234 "实时",@"预约",@"模拟"
  248. if (sender.tag > 1 && sender.tag < 5) {
  249. if (sender.tag == btnIndex) {
  250. return;
  251. }
  252. //UI 改变
  253. UIButton *btn = (UIButton *)_btnArray[btnIndex - 2];
  254. btn.backgroundColor = [UIColor clearColor];
  255. btnIndex = sender.tag;
  256. btn = (UIButton *)_btnArray[btnIndex - 2];
  257. btn.backgroundColor = defGreen;
  258. //改变显示的内容
  259. [mainScroll setContentOffset:CGPointMake(mainScroll.width * (btnIndex - 2), mainScroll.contentOffset.y) animated:NO];
  260. }
  261. if (sender.tag == 5) {
  262. if (keSanBtn.isSelected == YES) {
  263. keSanBtn.selected = NO;
  264. }
  265. keErBtn.selected = YES;
  266. keMuString = @"2";
  267. }
  268. if (sender.tag == 6) {
  269. if (keErBtn.isSelected == YES) {
  270. keErBtn.selected = NO;
  271. }
  272. keSanBtn.selected = YES;
  273. keMuString = @"3";
  274. }
  275. }
  276. #pragma mark tableView
  277. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  278. {
  279. // if (rightTableView == tableView) {
  280. //
  281. // return planArray.count;
  282. // }
  283. if (priceTableView == tableView) {
  284. return 1;
  285. }
  286. if (planArray.count == 0) {
  287. return 0;
  288. }
  289. return 1;
  290. }
  291. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  292. {
  293. if (priceTableView == tableView) {
  294. return moneyArr.count + 1;
  295. }
  296. if (leftTableView == tableView) {
  297. return planArray.count;
  298. }
  299. if (rightTableView == tableView) {
  300. if (planArray.count > _selectIndex) {
  301. NSArray *stuArray = [planArray[_selectIndex] objectForKey:@"reserveInfoList"];
  302. if (stuArray) {
  303. return stuArray.count;
  304. }
  305. }
  306. // if (planArray.count > 0) {
  307. // NSArray *stuArray = [planArray[section] objectForKey:@"reserveInfoList"];
  308. // if (stuArray) {
  309. // return stuArray.count;
  310. // }
  311. // }
  312. }
  313. return 0;
  314. }
  315. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  316. {
  317. //左边表
  318. if (leftTableView == tableView) {
  319. ModelLeftCell *cell = [tableView dequeueReusableCellWithIdentifier:@"leftCell"];
  320. if (cell == nil) {
  321. cell = [[ModelLeftCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"leftCell"];
  322. }
  323. NSDictionary *dic = planArray[indexPath.row];
  324. cell.timeLabel.text = dic[@"PI_TIMES"];
  325. cell.priceLabel.text = [NSString stringWithFormat:@"¥%@元/时",dic[@"PI_MONEY"]];
  326. return cell;
  327. }
  328. //右边表
  329. if (rightTableView == tableView) {
  330. ModelRightCell *cell = [tableView dequeueReusableCellWithIdentifier:@"rightCell"];
  331. if (cell == nil) {
  332. cell = [[ModelRightCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"rightCell"];
  333. }
  334. NSDictionary *dic = [[planArray[_selectIndex] objectForKey:@"reserveInfoList"] objectAtIndex:indexPath.row];
  335. cell.dataDic = dic;
  336. return cell;
  337. }
  338. //表示是价格选择的表
  339. PriceCell *cell = [tableView dequeueReusableCellWithIdentifier:@"priceCell"];
  340. if (cell == nil) {
  341. cell = [[[NSBundle mainBundle] loadNibNamed:@"PriceCell" owner:nil options:nil] firstObject];
  342. cell.backgroundColor = [UIColor clearColor];
  343. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  344. }
  345. NSDictionary *dic;
  346. if (indexPath.row == 0) {
  347. NSString *carType = @"";
  348. if (moneyArr.count > 0) {
  349. carType = [[moneyArr firstObject] objectForKey:@"CSI_VEHICLETYPE"];
  350. }
  351. dic = @{@"CSI_PRICE":@"免费",@"CSI_VEHICLETYPE":carType,@"CSI_TRAINNINGTIME":@"0"};
  352. }else{
  353. dic = moneyArr[indexPath.row - 1];
  354. }
  355. [cell.indexLabel setText:[NSString stringWithFormat:@"%d、",(int)indexPath.row + 1] Font:Font16 TextColor:newTitleColor Alignment:NSTextAlignmentRight];
  356. cell.priceDic = dic;
  357. return cell;
  358. }
  359. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  360. {
  361. if (priceTableView == tableView) {
  362. if (indexPath.row == 0) {
  363. priceString = @"免费";
  364. }else{
  365. NSDictionary *dic = moneyArr[indexPath.row - 1];
  366. priceString = dic[@"CSI_PRICE"];
  367. }
  368. UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
  369. [cell.textLabel setTextColor:defGreen];
  370. if (priceCell) {
  371. [priceCell.textLabel setTextColor:newTitleColor];
  372. }
  373. priceCell = cell;
  374. }
  375. if (leftTableView == tableView)
  376. {
  377. if (_selectIndex == indexPath.row) {
  378. return;
  379. }
  380. _selectIndex = indexPath.row;
  381. [leftTableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:_selectIndex inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:YES];
  382. // [rightTableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:_selectIndex] atScrollPosition:UITableViewScrollPositionTop animated:YES];
  383. //去掉右边的选中效果
  384. planDic = nil;
  385. [rightTableView reloadData];
  386. // if (rightIndex != -1) {
  387. // NSIndexPath *rightSelectIndex = [NSIndexPath indexPathForRow:rightIndex inSection:0];
  388. // ModelRightCell *cell = [rightTableView cellForRowAtIndexPath:rightSelectIndex];
  389. // [cell setSelected:NO animated:NO];
  390. // }
  391. }
  392. if (rightTableView == tableView) {
  393. rightIndex = indexPath.row;
  394. NSDictionary *planDict = planArray[_selectIndex];
  395. NSDictionary *stuDic = [[planDict objectForKey:@"reserveInfoList"] objectAtIndex:indexPath.row];
  396. RO_STATUS = stuDic[@"RO_STATUS"];
  397. planDic = @{@"subject":planDict[@"PI_KM"],@"price":planDict[@"PI_MONEY"],@"userId":stuDic[@"RI_USER"],@"rid":stuDic[@"RI_ID"],@"periodType":@"2",@"userName":stuDic[@"RI_USER_NAME"]};
  398. }
  399. }
  400. //-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
  401. //{
  402. // if (rightTableView == tableView) {
  403. // ModelTVHeaderView *headView = [tableView dequeueReusableHeaderFooterViewWithIdentifier:@"headView"];
  404. // if (headView == nil) {
  405. // headView = [[ModelTVHeaderView alloc] initWithReuseIdentifier:@"headView"];
  406. // headView.contentView.backgroundColor = newBackGroundColor;
  407. // }
  408. //
  409. // NSDictionary *dic = planArray[section];
  410. // headView.textLabel.text = dic[@"PI_TIMES"];
  411. // return headView;
  412. // }
  413. //
  414. // return nil;
  415. //}
  416. -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  417. {
  418. // if (rightTableView == tableView) {
  419. // return 25;
  420. // }
  421. return 0.1;
  422. }
  423. -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
  424. {
  425. return 0.1;
  426. }
  427. /* 哈哈哈哈 这些瓜皮
  428. // TableView分区标题即将展示
  429. - (void)tableView:(UITableView *)tableView willDisplayHeaderView:(nonnull UIView *)view forSection:(NSInteger)section
  430. {
  431. // 当前的tableView是RightTableView,RightTableView滚动的方向向上,RightTableView是用户拖拽而产生滚动的((主要判断RightTableView用户拖拽而滚动的,还是点击LeftTableView而滚动的)
  432. if ((rightTableView == tableView) && !_isScrollDown && rightTableView.dragging)
  433. {
  434. [self selectRowAtIndexPath:section];
  435. }
  436. }
  437. // TableView分区标题展示结束
  438. - (void)tableView:(UITableView *)tableView didEndDisplayingHeaderView:(UIView *)view forSection:(NSInteger)section
  439. {
  440. // 当前的tableView是RightTableView,RightTableView滚动的方向向下,RightTableView是用户拖拽而产生滚动的((主要判断RightTableView用户拖拽而滚动的,还是点击LeftTableView而滚动的)
  441. if ((rightTableView == tableView) && _isScrollDown && rightTableView.dragging)
  442. {
  443. [self selectRowAtIndexPath:section + 1];
  444. }
  445. }
  446. // 当拖动右边TableView的时候,处理左边TableView
  447. - (void)selectRowAtIndexPath:(NSInteger)index
  448. {
  449. if (index > planArray.count - 1) {
  450. return;
  451. }
  452. [leftTableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:index inSection:0] animated:YES scrollPosition:UITableViewScrollPositionTop];
  453. }
  454. */
  455. #pragma mark UISrcollViewDelegate
  456. // 标记一下RightTableView的滚动方向,是向上还是向下
  457. //- (void)scrollViewDidScroll:(UIScrollView *)scrollView
  458. //{
  459. // static CGFloat lastOffsetY = 0;
  460. //
  461. // UITableView *tableView = (UITableView *) scrollView;
  462. // if (rightTableView == tableView)
  463. // {
  464. // _isScrollDown = lastOffsetY < scrollView.contentOffset.y;
  465. // lastOffsetY = scrollView.contentOffset.y;
  466. // }
  467. //}
  468. -(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
  469. if (mainScroll == scrollView) {
  470. NSInteger pInd = (int)(scrollView.contentOffset.x / scrollView.width);
  471. if (pInd == btnIndex) {
  472. return;//滑动不足切换页面
  473. }
  474. UIButton *btn = (UIButton *)_btnArray[btnIndex - 2];
  475. btn.backgroundColor = [UIColor clearColor];
  476. btnIndex = pInd + 2;
  477. btn = (UIButton *)_btnArray[btnIndex - 2];
  478. btn.backgroundColor = defGreen;
  479. }
  480. }
  481. #pragma mark 数据请求
  482. //获取价格
  483. -(void)getTrainPrice
  484. {
  485. [priceTableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:NO scrollPosition:UITableViewScrollPositionTop];
  486. NSMutableArray *arr=[NSMutableArray array];
  487. [arr addPro:@"schoolId" Value:defUser.userDict[@"jxbh"]];
  488. [arr addPro:@"dqbh" Value:defUser.userDict[@"cityId"]];
  489. NSString* method = @"getPrice";
  490. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * dict) {
  491. //NSLog(@"获取价格-->%@->%@",arr,dict);
  492. if (!dict) {
  493. return ;
  494. }
  495. if ( [dict[@"code"] isEqualToString:@"1"]) {
  496. return ;
  497. }
  498. moneyArr = dict[@"body"];
  499. [priceTableView reloadData];
  500. [priceTableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:NO scrollPosition:UITableViewScrollPositionTop];
  501. }];
  502. }
  503. //获取计划订单信息
  504. - (void)getPlanInfos
  505. {
  506. if (![Util connectedToNetWork]) {
  507. showMsgUnconnect();
  508. return;
  509. }
  510. NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
  511. [formatter setDateFormat:@"yyyy-MM-dd"];
  512. NSString *dateString = [formatter stringFromDate:[NSDate date]];
  513. NSMutableArray *arr=[NSMutableArray array];
  514. [arr addPro:@"userId" Value:defUser.sfzmhm];
  515. [arr addPro:@"time" Value:dateString];
  516. [arr addPro:@"isPage" Value:@""];
  517. [arr addPro:@"pageSize" Value:@""];
  518. [arr addPro:@"currentPage" Value:@""];
  519. [arr addPro:@"status" Value:@"1"];
  520. NSString* method = @"getCoachReserveInfos";
  521. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
  522. //NSLog(@"我的预约-->%@---->%@",arr,root);
  523. if (!root) {
  524. return ;
  525. }
  526. if ([root[@"code"] isEqualToString:@"1"]) {
  527. ShowMsg(root[@"body"]);
  528. return;
  529. }
  530. planArray = root[@"body"];
  531. [leftTableView reloadData];
  532. //默认选择第一行
  533. if (planArray.count > 0) {
  534. [leftTableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:YES scrollPosition:UITableViewScrollPositionTop];
  535. }
  536. [rightTableView reloadData];
  537. }];
  538. }
  539. - (void)didReceiveMemoryWarning {
  540. [super didReceiveMemoryWarning];
  541. }
  542. @end