ImitateOrderVC.m 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. //
  2. // ImitateOrderVC.m
  3. // jiaPei
  4. //
  5. // Created by apple on 2017/5/5.
  6. // Copyright © 2017年 JCZ. All rights reserved.
  7. //
  8. #import "ImitateOrderVC.h"
  9. #import "STSegView.h"
  10. #import "HolderView.h"
  11. #import "DateView.h"
  12. #import "ImitateOrderCell.h"
  13. #import "MengBanView.h"
  14. @interface ImitateOrderVC ()<UIScrollViewDelegate,UITableViewDataSource,UITableViewDelegate>
  15. {
  16. STSegView *seg;
  17. UIScrollView *scroll;
  18. UITableView *mainTableView;
  19. UIBarButtonItem *item;
  20. UIView *backView;
  21. HolderView *holder;
  22. NSMutableArray *dataArray;;
  23. NSInteger currentPage;
  24. NSString *orderState;
  25. //
  26. MengBanView * _mengBanView;
  27. NSString * _pxkemu;
  28. NSString * _pxDate;
  29. NSString * _pxOrderId;
  30. }
  31. @end
  32. @implementation ImitateOrderVC
  33. - (void)viewDidLoad {
  34. [super viewDidLoad];
  35. [self initView];
  36. //
  37. _pxkemu = @"";
  38. _pxDate = @"";
  39. _pxOrderId = @"";
  40. }
  41. -(void)viewWillDisappear:(BOOL)animated
  42. {
  43. [super viewWillDisappear:animated];
  44. [LoadingView removeHUD];
  45. }
  46. -(void)viewWillAppear:(BOOL)animated{
  47. [super viewWillAppear:animated];
  48. currentPage = 1;
  49. [self getReserveMnList];
  50. }
  51. -(void)setMengbanView{
  52. if (_mengBanView) {
  53. [_mengBanView showView];
  54. return;
  55. }
  56. NSArray * btnarr = @[@"科目二模拟",@"科目三模拟"];
  57. NSString * Date = @"选择培训时间";
  58. UITextField * tf = [[UITextField alloc] initWithFrame:CGRectZero];
  59. tf.keyboardType = UIKeyboardTypeNumberPad;
  60. tf.placeholder = @"输入订单号查询";
  61. NSArray * buttonsArray = @[@[@"1",btnarr],
  62. @[@"2",Date],
  63. @[@"3",tf]];
  64. _mengBanView = [[MengBanView alloc]initWithTitileStr:nil buttonsArray:buttonsArray isAllbtn:NO block:^(NSArray *array) {
  65. NSLog(@"%@",array);
  66. _pxOrderId = array[2];
  67. if (![array[1] isEqualToString:Date]) {
  68. _pxDate = array[1];
  69. }
  70. NSInteger index = [btnarr indexOfObject:array[0]];
  71. _pxkemu = [NSString stringWithFormat:@"%d",(int)index+2];
  72. [self clickToSearch];
  73. }];
  74. [_mengBanView showView];
  75. }
  76. - (void)initView {
  77. [self.view setBackgroundColor:backGroundColor];
  78. [self setTitle:@"模拟课程订单"];
  79. [self configNavigationBar];
  80. currentPage = 1;
  81. orderState = @"1";
  82. dataArray = [NSMutableArray array];
  83. item = [[UIBarButtonItem alloc] initWithTitle:@"筛选" style:UIBarButtonItemStyleDone target:self action:@selector(setMengbanView)];
  84. [self.navigationItem setRightBarButtonItem:item];
  85. CGFloat x,y,w,h;
  86. x = y = 0;
  87. w = kSize.width;
  88. h = 50;
  89. seg = [[STSegView alloc] initWithFrame:CGRectMake(x, y, w, h)];
  90. [seg setTitles:@[@"待支付",@"有效单",@"已完成",@"已取消",@"退款单"]];
  91. seg.backgroundColor = backGroundColor;
  92. seg.selectedIndex = 0;
  93. [self.view addSubview:seg];
  94. y += h;
  95. h = kSize.height - y - kNavOffSet;
  96. mainTableView = [[UITableView alloc] initWithFrame:CGRectMake(x, y, w, h) style:UITableViewStyleGrouped];
  97. mainTableView.delegate = self;
  98. mainTableView.dataSource = self;
  99. mainTableView.rowHeight = 120;
  100. [self.view addSubview:mainTableView];
  101. [seg click:^(NSString *sInd) {
  102. currentPage = 1;
  103. orderState = [NSString stringWithFormat:@"%d",[sInd intValue] + 1];
  104. _pxkemu = @"";
  105. _pxDate = @"";
  106. _pxOrderId = @"";
  107. [self getReserveMnList];
  108. }];
  109. holder = [[HolderView alloc] initWithFrame:mainTableView.frame];
  110. [holder freshBlock:^{
  111. currentPage = 1;
  112. [self getReserveMnList];
  113. }];
  114. [self.view addSubview:holder];
  115. }
  116. - (void)clickToSearch {
  117. currentPage = 1;
  118. [self getReserveMnList];
  119. }
  120. #pragma mark tableView
  121. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  122. {
  123. return dataArray.count;
  124. }
  125. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  126. {
  127. return 1;
  128. }
  129. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  130. {
  131. ImitateOrderCell *cell = [ImitateOrderCell cellForTabelView:tableView block:^(NSString *re_id) {
  132. for (NSDictionary *dic in dataArray) {
  133. if ([[NSString stringWithFormat:@"%@",dic[@"reserveId"]] isEqualToString:re_id]) {
  134. [dataArray removeObject:dic];
  135. dispatch_sync(dispatch_get_main_queue(), ^{
  136. [mainTableView reloadData];
  137. });
  138. }
  139. }
  140. }];
  141. [cell setDataDic:dataArray[indexPath.section]];
  142. cell.type = [orderState integerValue];
  143. cell.skipVC = self;
  144. return cell;
  145. }
  146. -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
  147. {
  148. UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kSize.width, 15)];
  149. // view.backgroundColor = RQlineColor;
  150. return view;
  151. }
  152. -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  153. {
  154. return 15;
  155. }
  156. -(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
  157. {
  158. UIView *view = [UIView new];
  159. return view;
  160. }
  161. -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
  162. {
  163. return .1;
  164. }
  165. -(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
  166. {
  167. CGPoint off = scrollView.contentOffset;
  168. if (scrollView.contentSize.height - off.y - scrollView.frame.size.height < 1) {
  169. [scrollView setContentOffset:CGPointMake(off.x, off.y - 10) animated:YES];
  170. [self getReserveMnList];
  171. }
  172. }
  173. #pragma mark 数据请求
  174. - (void)getReserveMnList {
  175. [LoadingView showHUD];
  176. if (![Util connectedToNetWork]) {
  177. showMsgUnconnect();
  178. return;
  179. }
  180. NSMutableArray *arr=[NSMutableArray array];
  181. [arr addPro:@"dqbh" Value:RQ_USER_MANAGER.currentUser.city];
  182. [arr addPro:@"userId" Value:RQ_USER_MANAGER.currentUser._id];
  183. [arr addPro:@"status" Value:orderState];
  184. [arr addPro:@"pxsj" Value:_pxDate];
  185. [arr addPro:@"orderNo" Value:_pxOrderId];
  186. [arr addPro:@"subject" Value:_pxkemu];
  187. [arr addPro:@"isPage" Value:@"1"];
  188. [arr addPro:@"pageSize" Value:@"15"];
  189. [arr addPro:@"currentPage" Value:[NSString stringWithFormat:@"%d",(int)currentPage]];
  190. NSString* method = @"getReserveMnList";
  191. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary *root) {
  192. RemoveHUD();
  193. if (currentPage == 1) {
  194. holder.hidden = NO;
  195. [dataArray removeAllObjects];
  196. }
  197. if (!root) {
  198. return;
  199. }
  200. if ([root[@"code"] intValue] == 1) {
  201. ShowMsg(root[@"body"]);
  202. return;
  203. }
  204. NSArray *array = root[@"body"];
  205. if ([array count] < 1) {
  206. ShowMsg(@"已加载全部");
  207. [mainTableView reloadData];
  208. return;
  209. }
  210. [dataArray addObjectsFromArray:array];
  211. currentPage += 1;
  212. holder.hidden = YES;
  213. [mainTableView reloadData];
  214. }];
  215. }
  216. - (void)didReceiveMemoryWarning {
  217. [super didReceiveMemoryWarning];
  218. }
  219. @end