123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278 |
- //
- // ImitateOrderVC.m
- // jiaPei
- //
- // Created by apple on 2017/5/5.
- // Copyright © 2017年 JCZ. All rights reserved.
- //
- #import "ImitateOrderVC.h"
- #import "STSegView.h"
- #import "HolderView.h"
- #import "DateView.h"
- #import "ImitateOrderCell.h"
- #import "MengBanView.h"
- @interface ImitateOrderVC ()<UIScrollViewDelegate,UITableViewDataSource,UITableViewDelegate>
- {
- STSegView *seg;
- UIScrollView *scroll;
- UITableView *mainTableView;
- UIBarButtonItem *item;
- UIView *backView;
-
- HolderView *holder;
- NSMutableArray *dataArray;;
-
- NSInteger currentPage;
- NSString *orderState;
-
- //
- MengBanView * _mengBanView;
- NSString * _pxkemu;
- NSString * _pxDate;
- NSString * _pxOrderId;
- }
- @end
- @implementation ImitateOrderVC
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- [self initView];
-
- //
- _pxkemu = @"";
- _pxDate = @"";
- _pxOrderId = @"";
- }
- -(void)viewWillDisappear:(BOOL)animated
- {
- [super viewWillDisappear:animated];
- [LoadingView removeHUD];
- }
- -(void)viewWillAppear:(BOOL)animated{
- [super viewWillAppear:animated];
- currentPage = 1;
- [self getReserveMnList];
- }
- -(void)setMengbanView{
-
- if (_mengBanView) {
- [_mengBanView showView];
- return;
- }
-
- NSArray * btnarr = @[@"科目二模拟",@"科目三模拟"];
-
- NSString * Date = @"选择培训时间";
-
- UITextField * tf = [[UITextField alloc] initWithFrame:CGRectZero];
- tf.keyboardType = UIKeyboardTypeNumberPad;
- tf.placeholder = @"输入订单号查询";
-
- NSArray * buttonsArray = @[@[@"1",btnarr],
- @[@"2",Date],
- @[@"3",tf]];
-
- _mengBanView = [[MengBanView alloc]initWithTitileStr:nil buttonsArray:buttonsArray isAllbtn:NO block:^(NSArray *array) {
- NSLog(@"%@",array);
- _pxOrderId = array[2];
-
- if (![array[1] isEqualToString:Date]) {
- _pxDate = array[1];
- }
- NSInteger index = [btnarr indexOfObject:array[0]];
- _pxkemu = [NSString stringWithFormat:@"%d",(int)index+2];
- [self clickToSearch];
- }];
- [_mengBanView showView];
- }
- - (void)initView {
-
- [self.view setBackgroundColor:backGroundColor];
- [self setTitle:@"模拟课程订单"];
- [self configNavigationBar];
-
- currentPage = 1;
- orderState = @"1";
- dataArray = [NSMutableArray array];
-
- item = [[UIBarButtonItem alloc] initWithTitle:@"筛选" style:UIBarButtonItemStyleDone target:self action:@selector(setMengbanView)];
- [self.navigationItem setRightBarButtonItem:item];
-
- CGFloat x,y,w,h;
- x = y = 0;
- w = kSize.width;
- h = 50;
- seg = [[STSegView alloc] initWithFrame:CGRectMake(x, y, w, h)];
- [seg setTitles:@[@"待支付",@"有效单",@"已完成",@"已取消",@"退款单"]];
- seg.backgroundColor = backGroundColor;
- seg.selectedIndex = 0;
- [self.view addSubview:seg];
-
- y += h;
- h = kSize.height - y - kNavOffSet;
- mainTableView = [[UITableView alloc] initWithFrame:CGRectMake(x, y, w, h) style:UITableViewStyleGrouped];
- mainTableView.delegate = self;
- mainTableView.dataSource = self;
- mainTableView.rowHeight = 120;
- [self.view addSubview:mainTableView];
-
- [seg click:^(NSString *sInd) {
-
- currentPage = 1;
- orderState = [NSString stringWithFormat:@"%d",[sInd intValue] + 1];
- _pxkemu = @"";
- _pxDate = @"";
- _pxOrderId = @"";
- [self getReserveMnList];
- }];
-
-
- holder = [[HolderView alloc] initWithFrame:mainTableView.frame];
- [holder freshBlock:^{
- currentPage = 1;
- [self getReserveMnList];
- }];
- [self.view addSubview:holder];
- }
- - (void)clickToSearch {
-
- currentPage = 1;
- [self getReserveMnList];
- }
- #pragma mark tableView
- -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
- {
- return dataArray.count;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- return 1;
- }
- -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- ImitateOrderCell *cell = [ImitateOrderCell cellForTabelView:tableView block:^(NSString *re_id) {
- for (NSDictionary *dic in dataArray) {
- if ([[NSString stringWithFormat:@"%@",dic[@"reserveId"]] isEqualToString:re_id]) {
- [dataArray removeObject:dic];
- dispatch_sync(dispatch_get_main_queue(), ^{
- [mainTableView reloadData];
- });
- }
- }
- }];
- [cell setDataDic:dataArray[indexPath.section]];
- cell.type = [orderState integerValue];
- cell.skipVC = self;
-
- return cell;
- }
- -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
- {
- UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kSize.width, 15)];
- // view.backgroundColor = RQlineColor;
- return view;
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
- {
- return 15;
- }
- -(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
- {
- UIView *view = [UIView new];
- return view;
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
- {
- return .1;
- }
- -(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
- {
- CGPoint off = scrollView.contentOffset;
- if (scrollView.contentSize.height - off.y - scrollView.frame.size.height < 1) {
- [scrollView setContentOffset:CGPointMake(off.x, off.y - 10) animated:YES];
- [self getReserveMnList];
- }
- }
- #pragma mark 数据请求
- - (void)getReserveMnList {
-
- [LoadingView showHUD];
- if (![Util connectedToNetWork]) {
- showMsgUnconnect();
- return;
- }
-
- NSMutableArray *arr=[NSMutableArray array];
- [arr addPro:@"dqbh" Value:RQ_USER_MANAGER.currentUser.city];
- [arr addPro:@"userId" Value:RQ_USER_MANAGER.currentUser._id];
- [arr addPro:@"status" Value:orderState];
- [arr addPro:@"pxsj" Value:_pxDate];
- [arr addPro:@"orderNo" Value:_pxOrderId];
- [arr addPro:@"subject" Value:_pxkemu];
- [arr addPro:@"isPage" Value:@"1"];
- [arr addPro:@"pageSize" Value:@"15"];
- [arr addPro:@"currentPage" Value:[NSString stringWithFormat:@"%d",(int)currentPage]];
-
- NSString* method = @"getReserveMnList";
- [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary *root) {
-
- RemoveHUD();
-
- if (currentPage == 1) {
- holder.hidden = NO;
- [dataArray removeAllObjects];
- }
-
- if (!root) {
- return;
- }
-
- if ([root[@"code"] intValue] == 1) {
- ShowMsg(root[@"body"]);
- return;
- }
-
- NSArray *array = root[@"body"];
- if ([array count] < 1) {
- ShowMsg(@"已加载全部");
- [mainTableView reloadData];
- return;
- }
-
- [dataArray addObjectsFromArray:array];
-
- currentPage += 1;
- holder.hidden = YES;
- [mainTableView reloadData];
-
- }];
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- }
- @end
|