ModelVC.m 25 KB

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