123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772 |
- //
- // ModelVC.m
- // JSJPCoach
- //
- // Created by apple on 2017/3/22.
- // Copyright © 2017年 Danson. All rights reserved.
- //
- #import "ModelVC.h"
- #import "ModelLeftCell.h"
- #import "ModelRightCell.h"
- #import "ModelTVHeaderView.h"
- #import "PriceCell.h"
- static BOOL isOpen = YES;//@lee-mark:实操是否开放
- @interface ModelVC ()<UIScrollViewDelegate,UITableViewDelegate,UITableViewDataSource,UIAlertViewDelegate>
- {
- UIScrollView *mainScroll;
-
- //实时
- UIButton *keErBtn, *keSanBtn;
- UITableView *priceTableView;
- UITableViewCell *priceCell;
- NSArray *moneyArr;
- NSString *keMuString;
- NSString *priceString;
- NSString *coachOrderIdStr;
-
-
- //预约
- UITableView *leftTableView;
- UITableView *rightTableView;
- NSArray *planArray;
- NSDictionary *planDic;
- BOOL _isScrollDown;
- NSInteger _selectIndex;
- NSInteger rightIndex;
-
-
- NSMutableArray *_btnArray;
- NSInteger btnIndex;
- NSString *RO_STATUS;
- }
- @end
- @implementation ModelVC
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.view.backgroundColor = [UIColor whiteColor];
-
-
- planArray = [NSArray array];
- _selectIndex = 0;
- rightIndex = -1;
- //默认选择实时0元
- btnIndex = 2;
- priceString = @"免费";
-
- UIImageView *backImageView = [[UIImageView alloc] initWithFrame:kFrame];
- backImageView.image = [UIImage imageNamed:@"bgImage"];
- [self.view addSubview:backImageView];
-
-
- CGFloat x,y,w,h;
- //完成按钮
- x = 20;
- y = kSize.height - kSize.height/6.0;
- h = kSize.height/6.0 - 20;
- if (h > 80) {
- h = 80;
- y += (kSize.height/6.0 - 100)/2.0;
- }
-
- w = h/1.46;
- y += (h - w)/2 + 5;
- h = w;
-
- UIButton *modelBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- modelBtn.frame = setDIYFrame;
- [modelBtn setRound];
- modelBtn.backgroundColor = RGB_COLOR(145, 160, 175);
- [modelBtn setTitle:@"完成" textColor:[UIColor blackColor] font:Font16 fotState:UIControlStateNormal];
- [modelBtn target:self Tag:1];
- [self.view addSubview:modelBtn];
-
- //返回按钮
- UIButton *backlBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- backlBtn.backgroundColor = RGB_COLOR(145, 160, 175);
- [backlBtn setTitle:@"返回" textColor:[UIColor blackColor] font:Font16 fotState:UIControlStateNormal];
- [backlBtn target:self Tag:0];
- [self.view addSubview:backlBtn];
- [backlBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.mas_equalTo(self.view).mas_offset(-20);
- make.bottom.mas_equalTo(self.view).mas_offset(- (kSize.height - (modelBtn.y + modelBtn.height)));
- make.size.mas_equalTo(modelBtn.size);
- backlBtn.layer.cornerRadius = modelBtn.width / 2.0;
- backlBtn.layer.masksToBounds = YES;
- }];
-
-
- //
- w = kSize.width - 2*x;
- h = y - kNavOffSet;
- y = kSegmentHeight;
-
- UIImageView *bgImage = [[UIImageView alloc] setxywh];
- bgImage.backgroundColor = [UIColor colorWithWhite:.7 alpha:.2];
- [self.view addSubview:bgImage];
-
- h = 40;
- UILabel *label = [[UILabel alloc] setxywh];
- [label setText:@"带教类型" Font:Font17 TextColor:[UIColor whiteColor] Alignment:NSTextAlignmentCenter];
- [self.view addSubview:label];
-
- [label addViewWithRect:CGRectMake(x + 30, y + 19, w/2.0 - 80, 1) Color:[UIColor colorWithWhite:.7 alpha:.5]];
- [label addViewWithRect:CGRectMake(kSize.width/2.0 + 50, y + 19, w/2.0 - 80, 1) Color:[UIColor colorWithWhite:.7 alpha:.5]];
-
- //
- x += 30;
- y += h;
- h = h*1.3;
- w = kSize.width - 2*x;
-
- UIView *btnBar = [[UIView alloc] setxywh];//16 24 50
- btnBar.backgroundColor = RGB_COLOR(16, 24, 50);
- [btnBar borderColor:[UIColor colorWithWhite:.7 alpha:.2] width:1 cornorRadios:h/2.0];
- [self.view addSubview:btnBar];
-
- // NSArray *titleArray = @[@"实时",@"预约",@"模拟"];
- NSArray *titleArray = (self.modelPageType == RQModelPageTypeSubscribe)? @[@"预约"] : @[@"预约",@"模拟"];
- w = w/(titleArray.count);
-
- _btnArray = [NSMutableArray arrayWithCapacity:titleArray.count];
- for (int i = 0; i < titleArray.count; i ++)
- {
- UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(w*i,5,w,h - 10)];
-
- [button borderColor:RGB_COLOR(16, 24, 50) width:1 cornorRadios:h/2.0 - 5];
-
- [button setTitle:[titleArray objectAtIndex:i] textColor:[UIColor whiteColor] font:Font18 fotState:UIControlStateNormal];
-
- [button target:self Tag:i + 2];
- [btnBar addSubview:button];
- [_btnArray addObject:button];
-
- button.backgroundColor = (i == 0 && !isOpen)? [UIColor grayColor] : [UIColor clearColor];
-
- button.enabled = !(i == 0 && !isOpen);
-
- if (i == !isOpen? 1 : 0) {
- button.selected = YES;
- button.backgroundColor = defGreen;
- btnIndex = button.tag;
- }
- }
-
- //
- x = 20;
- w = kSize.width - 2*x;
- y += h + 20;
- h = modelBtn.y - y - kStatusHeight;
-
- mainScroll = [[UIScrollView alloc] setxywh];
- mainScroll.contentSize = CGSizeMake(titleArray.count*w, h);
- [mainScroll setShowsHorizontalScrollIndicator:NO];
- [mainScroll setPagingEnabled:YES];
- [mainScroll setDecelerationRate:.2];
- mainScroll.delegate = self;
- [self.view addSubview:mainScroll];
-
-
- UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, w, h)];
- if (isOpen) {
- // [mainScroll addSubview:view];
- }
- UIView *scrollView1 = view;
-
- view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, w, h)];
- [mainScroll addSubview:view];
- UIView *scrollView2 = view;
-
- view = [[UIView alloc] initWithFrame:CGRectMake(w, 0, w, h)];
- [mainScroll addSubview:view];
- //UIView *scrollView3 = view;
-
- //实时
- x = 10;
- y = 20;
- w = (w-20)/3.0;
- h = 30;
- label = [[UILabel alloc] setxywh];
- [label setText:@"培训科目:" Font:Font17 TextColor:newTitleColor Alignment:NSTextAlignmentLeft];
- [scrollView1 addSubview:label];
-
- x += w;
-
- keMuString = @"2";
- UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
- button.frame = setDIYFrame;
- [button setImage:[UIImage imageNamed:@"selectAll"] Tit:@"科目二" Font:Font16 State:UIControlStateNormal];
- [button setImage:[UIImage imageNamed:@"selectedAll"] forState:UIControlStateSelected];
- [button setTitleColor:newTitleColor forState:UIControlStateNormal];
- [button setTitleColor:defGreen forState:UIControlStateSelected];
- [button target:self Tag:5];
- [scrollView1 addSubview:button];
- button.selected = YES;
- keErBtn = button;
-
- x += w;
- button = [UIButton buttonWithType:UIButtonTypeCustom];
- button.frame = setDIYFrame;
- [button setImage:[UIImage imageNamed:@"selectAll"] Tit:@"科目三" Font:Font16 State:UIControlStateNormal];
- [button setImage:[UIImage imageNamed:@"selectedAll"] forState:UIControlStateSelected];
- [button setTitleColor:newTitleColor forState:UIControlStateNormal];
- [button setTitleColor:defGreen forState:UIControlStateSelected];
- [button target:self Tag:6];
- [scrollView1 addSubview:button];
- keSanBtn = button;
-
-
- x = 10;
- y += h + 20;
- w = scrollView1.width - 2*x;
- label = [[UILabel alloc] setxywh];
- [label setText:@"培训价格:" Font:Font17 TextColor:newTitleColor Alignment:NSTextAlignmentLeft];
- [scrollView1 addSubview:label];
- [label addViewWithRect:CGRectMake(x, y+h, w, 1) Color:backGroundColor];
-
- y += h + 1;
- h = scrollView1.height - y;
-
- UITableView *tableView = [[UITableView alloc] initWithFrame:setDIYFrame style:UITableViewStyleGrouped];
- tableView.backgroundColor = [UIColor clearColor];
- tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLineEtched;
- tableView.delegate = self;
- tableView.dataSource = self;
- tableView.estimatedSectionHeaderHeight = 0;
- tableView.estimatedSectionFooterHeight = 0;
- [scrollView1 addSubview:tableView];
- priceTableView = tableView;
-
-
- //预约
- x = y = 0;
- w = 90;
- if (kSize.width > 320.0) {
- w = 110;
- }
- h = scrollView2.height;
- leftTableView = [[UITableView alloc] initWithFrame:setDIYFrame style:UITableViewStylePlain];
- leftTableView.backgroundColor = [UIColor clearColor];
- leftTableView.delegate = self;
- leftTableView.dataSource = self;
- leftTableView.rowHeight = 60;
- leftTableView.estimatedSectionHeaderHeight = 0;
- leftTableView.estimatedSectionFooterHeight = 0;
- leftTableView.showsVerticalScrollIndicator = NO;
- leftTableView.tableFooterView = [UIView new];
- [scrollView2 addSubview:leftTableView];
-
- x += w;
- w = scrollView1.width - w;
- rightTableView = [[UITableView alloc] initWithFrame:setDIYFrame style:UITableViewStyleGrouped];
- rightTableView.backgroundColor = [UIColor clearColor];
- rightTableView.delegate = self;
- rightTableView.dataSource = self;
- rightTableView.rowHeight = 80;
- rightTableView.estimatedSectionHeaderHeight = 0;
- rightTableView.estimatedSectionFooterHeight = 0;
- rightTableView.showsVerticalScrollIndicator = NO;
- rightTableView.separatorColor = [UIColor clearColor];
- [scrollView2 addSubview:rightTableView];
- //模拟
-
-
-
- //数据获取
- [self getTrainPrice];
- [self getPlanInfos];
- }
- - (void)btnClick:(UIButton *)sender
- {
- if (sender.tag == 0) {
- [self dismissViewControllerAnimated:YES completion:nil];
- return;
- }
-
- if (sender.tag == 1) {
-
- //如果没有有效的选择 就提示是否确定 123 "实时",@"预约",@"模拟"
- NSString *audioString = @"您已选择模拟带教";
- if (btnIndex == 1) {
- if (priceString.length < 1) {
- //未选择价格
- UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"请选择实时带教价格,否则将无法开始带教" delegate:nil cancelButtonTitle:@"确认" otherButtonTitles:nil, nil];
- [alert show];
- return;
- }
-
- NSDictionary *dic = @{@"subject":keMuString,@"price":priceString,@"periodType":@"1"};
- _superVC.periodType = 1;
- _superVC.periodDic = dic;
-
- audioString = [NSString stringWithFormat:@"您已选择%@实时带教",[keMuString isEqualToString:@"2"] ? @"科目二":@"科目三"];
- }
-
- if (btnIndex == 2) {
-
- if (![planDic isKindOfClass:[NSDictionary class]] || planDic.count < 1) {
- UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:self.modelPageType == RQModelPageTypeSubscribe? @"请选择将要签退的学员,否则将无法签退" : @"请选择将要带教的学员,否则将无法开始带教" delegate:nil cancelButtonTitle:@"确认" otherButtonTitles:nil, nil];
- [alert show];
- return;
- }
-
- if (RO_STATUS) {
- if (RO_STATUS.length > 0 && self.modelPageType == RQModelPageTypeDefault) {
- ShowMsg(@"您已带教该预约!");
- [Tools playAudioWithString:@"您已带教该预约!"];
- return;
- }else if (self.modelPageType == RQModelPageTypeSubscribe) {
- if ([RO_STATUS isEqualToString:@"0"]) {
- if (_coachOrderBlock) {
- _coachOrderBlock(planDic);
- }
- }else if ([RO_STATUS isEqualToString:@"1"]) {
- [Tools playAudioWithString:@"该学员已签退"];
- }
-
- }
- }
-
- _superVC.periodType = 2;
- _superVC.periodDic = planDic;
-
- audioString = self.modelPageType == RQModelPageTypeSubscribe? [NSString stringWithFormat:@"您已选择签退学员为%@",planDic[@"userName"]] : [NSString stringWithFormat:@"您已选择预约模式,带教学员为%@",planDic[@"userName"]];
- //userName
- }
-
- if (btnIndex == 3) {
- _superVC.periodType = 3;
- }
-
-
- [self dismissViewControllerAnimated:NO completion:^{
- [Tools playAudioWithString:audioString];
- }];
- return;
- }
-
- // 123 "实时",@"预约",@"模拟"
- if (sender.tag > 0 && sender.tag < 4) {
- if (sender.tag == btnIndex) {
- return;
- }
-
- //UI 改变
- UIButton *btn = (UIButton *)_btnArray[btnIndex - 2];
- btn.backgroundColor = [UIColor clearColor];
-
- btnIndex = sender.tag;
- btn = (UIButton *)_btnArray[btnIndex - 2];
- btn.backgroundColor = defGreen;
-
- //改变显示的内容
- [mainScroll setContentOffset:CGPointMake(mainScroll.width * (btnIndex - 2), mainScroll.contentOffset.y) animated:NO];
- }
-
- if (sender.tag == 5) {
- if (keSanBtn.isSelected == YES) {
- keSanBtn.selected = NO;
- }
- keErBtn.selected = YES;
- keMuString = @"2";
- }
- if (sender.tag == 6) {
- if (keErBtn.isSelected == YES) {
- keErBtn.selected = NO;
- }
- keSanBtn.selected = YES;
- keMuString = @"3";
- }
-
-
-
- }
- #pragma mark tableView
- -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
- {
- // if (rightTableView == tableView) {
- //
- // return planArray.count;
- // }
- if (priceTableView == tableView) {
- return 1;
- }
- if (planArray.count == 0) {
- return 0;
- }
- return 1;
- }
- -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- if (priceTableView == tableView) {
- return moneyArr.count + 1;
- }
-
- if (leftTableView == tableView) {
- return planArray.count;
- }
-
- if (rightTableView == tableView) {
-
- if (planArray.count > _selectIndex) {
- NSArray *stuArray = [planArray[_selectIndex] objectForKey:@"reserveInfoList"];
- if (stuArray) {
- return stuArray.count;
- }
- }
-
- // if (planArray.count > 0) {
- // NSArray *stuArray = [planArray[section] objectForKey:@"reserveInfoList"];
- // if (stuArray) {
- // return stuArray.count;
- // }
- // }
- }
-
- return 0;
- }
- -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- //左边表
- if (leftTableView == tableView) {
-
- ModelLeftCell *cell = [tableView dequeueReusableCellWithIdentifier:@"leftCell"];
- if (cell == nil) {
- cell = [[ModelLeftCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"leftCell"];
- }
-
- NSDictionary *dic = planArray[indexPath.row];
- cell.timeLabel.text = dic[@"PI_TIMES"];
- cell.priceLabel.text = [NSString stringWithFormat:@"¥%@元/时",dic[@"PI_MONEY"]];
- return cell;
- }
-
-
- //右边表
- if (rightTableView == tableView) {
-
- ModelRightCell *cell = [tableView dequeueReusableCellWithIdentifier:@"rightCell"];
- if (cell == nil) {
- cell = [[ModelRightCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"rightCell"];
- }
-
- NSDictionary *dic = [[planArray[_selectIndex] objectForKey:@"reserveInfoList"] objectAtIndex:indexPath.row];
- cell.dataDic = dic;
- return cell;
- }
-
-
- //表示是价格选择的表
-
-
- PriceCell *cell = [tableView dequeueReusableCellWithIdentifier:@"priceCell"];
- if (cell == nil) {
- cell = [[[NSBundle mainBundle] loadNibNamed:@"PriceCell" owner:nil options:nil] firstObject];
- cell.backgroundColor = [UIColor clearColor];
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- }
-
- NSDictionary *dic;
- if (indexPath.row == 0) {
- NSString *carType = @"";
- if (moneyArr.count > 0) {
- carType = [[moneyArr firstObject] objectForKey:@"CSI_VEHICLETYPE"];
- }
- dic = @{@"CSI_PRICE":@"免费",@"CSI_VEHICLETYPE":carType,@"CSI_TRAINNINGTIME":@"0"};
- }else{
- dic = moneyArr[indexPath.row - 1];
- }
-
- [cell.indexLabel setText:[NSString stringWithFormat:@"%d、",(int)indexPath.row + 1] Font:Font16 TextColor:newTitleColor Alignment:NSTextAlignmentRight];
- cell.priceDic = dic;
-
- return cell;
- }
- -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- if (priceTableView == tableView) {
-
- if (indexPath.row == 0) {
- priceString = @"免费";
- }else{
- NSDictionary *dic = moneyArr[indexPath.row - 1];
- priceString = dic[@"CSI_PRICE"];
- }
-
- UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
- [cell.textLabel setTextColor:defGreen];
-
- if (priceCell) {
- [priceCell.textLabel setTextColor:newTitleColor];
- }
-
- priceCell = cell;
- }
-
- if (leftTableView == tableView)
- {
- if (_selectIndex == indexPath.row) {
- return;
- }
- _selectIndex = indexPath.row;
-
- [leftTableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:_selectIndex inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:YES];
-
- // [rightTableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:_selectIndex] atScrollPosition:UITableViewScrollPositionTop animated:YES];
-
- //去掉右边的选中效果
- planDic = nil;
- [rightTableView reloadData];
-
- // if (rightIndex != -1) {
- // NSIndexPath *rightSelectIndex = [NSIndexPath indexPathForRow:rightIndex inSection:0];
- // ModelRightCell *cell = [rightTableView cellForRowAtIndexPath:rightSelectIndex];
- // [cell setSelected:NO animated:NO];
- // }
- }
-
- if (rightTableView == tableView) {
-
- rightIndex = indexPath.row;
-
- NSDictionary *planDict = planArray[_selectIndex];
- NSDictionary *stuDic = [[planDict objectForKey:@"reserveInfoList"] objectAtIndex:indexPath.row];
-
- RO_STATUS = stuDic[@"RO_STATUS"];
- coachOrderIdStr = stuDic[@"RO_ID"];
-
- 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"]};
- }
- }
- //-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
- //{
- // if (rightTableView == tableView) {
- // ModelTVHeaderView *headView = [tableView dequeueReusableHeaderFooterViewWithIdentifier:@"headView"];
- // if (headView == nil) {
- // headView = [[ModelTVHeaderView alloc] initWithReuseIdentifier:@"headView"];
- // headView.contentView.backgroundColor = newBackGroundColor;
- // }
- //
- // NSDictionary *dic = planArray[section];
- // headView.textLabel.text = dic[@"PI_TIMES"];
- // return headView;
- // }
- //
- // return nil;
- //}
- -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
- {
- // if (rightTableView == tableView) {
- // return 25;
- // }
- return 0.1;
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
- {
- return 0.1;
- }
- /* 哈哈哈哈 这些瓜皮
- // TableView分区标题即将展示
- - (void)tableView:(UITableView *)tableView willDisplayHeaderView:(nonnull UIView *)view forSection:(NSInteger)section
- {
- // 当前的tableView是RightTableView,RightTableView滚动的方向向上,RightTableView是用户拖拽而产生滚动的((主要判断RightTableView用户拖拽而滚动的,还是点击LeftTableView而滚动的)
- if ((rightTableView == tableView) && !_isScrollDown && rightTableView.dragging)
- {
- [self selectRowAtIndexPath:section];
- }
- }
- // TableView分区标题展示结束
- - (void)tableView:(UITableView *)tableView didEndDisplayingHeaderView:(UIView *)view forSection:(NSInteger)section
- {
- // 当前的tableView是RightTableView,RightTableView滚动的方向向下,RightTableView是用户拖拽而产生滚动的((主要判断RightTableView用户拖拽而滚动的,还是点击LeftTableView而滚动的)
- if ((rightTableView == tableView) && _isScrollDown && rightTableView.dragging)
- {
- [self selectRowAtIndexPath:section + 1];
- }
- }
- // 当拖动右边TableView的时候,处理左边TableView
- - (void)selectRowAtIndexPath:(NSInteger)index
- {
- if (index > planArray.count - 1) {
- return;
- }
- [leftTableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:index inSection:0] animated:YES scrollPosition:UITableViewScrollPositionTop];
- }
- */
- #pragma mark UISrcollViewDelegate
- // 标记一下RightTableView的滚动方向,是向上还是向下
- //- (void)scrollViewDidScroll:(UIScrollView *)scrollView
- //{
- // static CGFloat lastOffsetY = 0;
- //
- // UITableView *tableView = (UITableView *) scrollView;
- // if (rightTableView == tableView)
- // {
- // _isScrollDown = lastOffsetY < scrollView.contentOffset.y;
- // lastOffsetY = scrollView.contentOffset.y;
- // }
- //}
- -(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
-
- if (mainScroll == scrollView) {
- NSInteger pInd = (int)(scrollView.contentOffset.x / scrollView.width);
- NSLog(@"%ld %ld",(long)pInd,(long)btnIndex);
- if (pInd == btnIndex) {
- return;//滑动不足切换页面
- }else if (pInd == 0 && btnIndex == 3 && !isOpen) {
- return;
- }
-
- UIButton *btn = (UIButton *)_btnArray[btnIndex - 2];
- btn.backgroundColor = [UIColor clearColor];
-
- btnIndex = pInd + 2;
- btn = (UIButton *)_btnArray[btnIndex - 2];
- btn.backgroundColor = defGreen;
- }
-
- }
- #pragma mark 数据请求
- //获取价格
- -(void)getTrainPrice
- {
- [priceTableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:NO scrollPosition:UITableViewScrollPositionTop];
-
- NSMutableArray *arr=[NSMutableArray array];
- [arr addPro:@"schoolId" Value:defUser.userDict[@"jxbh"]];
- [arr addPro:@"dqbh" Value:defUser.userDict[@"cityId"]];
- NSString* method = @"getPrice";
- [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * dict) {
-
- //NSLog(@"获取价格-->%@->%@",arr,dict);
- if (!dict) {
- return ;
- }
- if ( [dict[@"code"] isEqualToString:@"1"]) {
- return ;
- }
-
- moneyArr = dict[@"body"];
- [priceTableView reloadData];
-
- [priceTableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:NO scrollPosition:UITableViewScrollPositionTop];
- }];
- }
- //获取计划订单信息
- - (void)getPlanInfos
- {
- [LoadingView showHUD];
- if (![Util connectedToNetWork]) {
- showMsgUnconnect();
- return;
- }
-
- NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
- [formatter setDateFormat:@"yyyy-MM-dd"];
- NSString *dateString = [formatter stringFromDate:[NSDate date]];
-
- NSMutableArray *arr=[NSMutableArray array];
- [arr addPro:@"userId" Value:defUser.sfzmhm];
- [arr addPro:@"time" Value:dateString];
- [arr addPro:@"isPage" Value:@""];
- [arr addPro:@"pageSize" Value:@""];
- [arr addPro:@"currentPage" Value:@""];
- [arr addPro:@"status" Value:@"1"];
-
- NSString* method = @"getCoachReserveInfos";
- [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
-
- //NSLog(@"我的预约-->%@---->%@",arr,root);
- if (!root) {
- [LoadingView removeHUD];
- return ;
- }
- if ([root[@"code"] isEqualToString:@"1"]) {
- [LoadingView removeHUD];
- ShowMsg(root[@"body"]);
- return;
- }
- planArray = root[@"body"];
- if (self.modelPageType == RQModelPageTypeSubscribe) {
- NSMutableArray *plansArray = [NSMutableArray array];
- [planArray.rac_sequence.signal subscribeNext:^(NSMutableDictionary *dic) {
- NSArray *reserveInfoListArr = dic[@"reserveInfoList"];
- NSMutableArray *arr = [NSMutableArray array];
- [[reserveInfoListArr.rac_sequence.signal filter:^BOOL(NSDictionary *dic0) {
- return [dic0[@"RO_STATUS"] isEqualToString:@"0"];
- }] subscribeNext:^(NSDictionary *dic1) {
- [arr addObject:dic1];
- } completed:^{
- [dic setObject:arr forKey:@"reserveInfoList"];
- if (arr.count > 0) {
- [plansArray addObject:dic];
- }
- }];
- } completed:^{
- dispatch_async(dispatch_get_main_queue(), ^{
- planArray = plansArray;
- [leftTableView reloadData];
- //默认选择第一行
- if (planArray.count > 0) {
- [leftTableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:YES scrollPosition:UITableViewScrollPositionTop];
- }
- [rightTableView reloadData];
- [LoadingView removeHUD];
- });
- }];
- }else {
- [leftTableView reloadData];
- //默认选择第一行
- if (planArray.count > 0) {
- [leftTableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:YES scrollPosition:UITableViewScrollPositionTop];
- }
-
- [rightTableView reloadData];
- [LoadingView removeHUD];
- }
-
-
-
- }];
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- }
- - (RQModelPageType)modelPageType {
- if (!_modelPageType) {
- _modelPageType = RQModelPageTypeDefault;
- }
- return _modelPageType;
- }
- - (void)initWithCoachOrderBlock:(CoachOrderBlock)coachOrderBlock {
- _coachOrderBlock = coachOrderBlock;
- }
- @end
|