BusinesswaterDetaiViewController.m 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. //
  2. // BusinesswaterDetaiViewController.m
  3. // jitao
  4. //
  5. // Created by 罗云飞 on 2017/12/28.
  6. // Copyright © 2017年 罗云飞. All rights reserved.
  7. //
  8. #import "BusinesswaterDetaiViewController.h"
  9. #import "BusinesswaterDetailCell.h"
  10. #import "BusinesswaterModel.h"
  11. @interface BusinesswaterDetaiViewController ()<UITableViewDelegate,UITableViewDataSource>{
  12. UITableView *newtableView;
  13. NSMutableArray *dataArray;
  14. int pageIndex;
  15. int pageSize;
  16. int pageNumber;
  17. UIView *showView;
  18. }
  19. @end
  20. @implementation BusinesswaterDetaiViewController
  21. - (void)viewDidLoad {
  22. [super viewDidLoad];
  23. [self setNavTitle:@"业务流水"];
  24. [self dataInitialization];
  25. [self loadsView];
  26. [self networkRequest:nil];
  27. [self addRefreshing];
  28. // Do any additional setup after loading the view.
  29. }
  30. - (void)networkRequest:(id)object{
  31. int pageNumberIndex=1;
  32. if (!object) {
  33. [MBProgressHUD showLoadToView:self.view title:@"请稍后..."];
  34. }else if ([object isKindOfClass:[MJRefreshNormalHeader class]]) {
  35. pageNumberIndex = 1;
  36. }else if ([object isKindOfClass:[MJRefreshBackNormalFooter class]]) {
  37. pageNumberIndex = pageNumber+1;
  38. }
  39. NSMutableDictionary *dic = NewMutableDictionaryInit;
  40. [dic safeSetObject:_orderID forKey:@"orderNo"];
  41. [dic safeSetObject:@(pageSize) forKey:@"pageSize"];
  42. [dic safeSetObject:@(pageNumberIndex) forKey:@"pageNo"];
  43. [NetworkRequestManager requestPostWithInterfacePrefix:JT_fundingHistory parameters:dic onSuccess:^(id requestData) {
  44. [self dismiss:object];
  45. NSLog(@"服务器返回数据 :%@",requestData);
  46. if ([requestData[@"error"] count] !=0) {
  47. for (NSDictionary *dic in requestData[@"error"]) {
  48. [MBProgressHUD showError:dic[@"message"] toView:self.view];
  49. }
  50. }else{
  51. pageNumber = pageNumberIndex;
  52. if ([object isKindOfClass:[MJRefreshNormalHeader class]] || pageNumber==1) {
  53. [dataArray removeAllObjects];
  54. }else if ([object isKindOfClass:[MJRefreshBackNormalFooter class]]) {
  55. NSMutableArray *arr = requestData[@"data"][@"list"];
  56. if ([arr count]<=0) {
  57. [self.view makeToast:NewConnectServerNoMoreDataTitle duration:1.0 position:CSToastPositionBottom];
  58. return ;
  59. }
  60. }
  61. for (NSDictionary *dic in requestData[@"data"][@"list"]) {
  62. BusinesswaterModel *model = [[BusinesswaterModel alloc] initWithDictionary:dic error:nil];
  63. [dataArray addObject:model];
  64. }
  65. //查询不到类型底图
  66. if (dataArray.count<=0) {
  67. [self addErrorLoadingFrame:CGRectMake(0, NavHeader, newtableView.width, newtableView.height) title:@"您还没有订单~" buttonTitle:nil imageString:NewNoDataErrorImage];
  68. }else {
  69. [self hideReloadingview];
  70. [newtableView reloadData];
  71. }
  72. }
  73. } onFailure:^{
  74. [self dismiss:object];
  75. }];
  76. }
  77. #pragma mark - 数据初始化
  78. - (void)dataInitialization{
  79. dataArray = NewMutableArrayInit;
  80. pageIndex = 1;
  81. pageSize = 10;
  82. pageNumber = 1;
  83. }
  84. #pragma mark ----加载界面
  85. - (void)loadsView{
  86. [self.view addSubview:newtableView = [NewControlPackage tableViewInitWithFrame:CGRectMake(0, NavHeader, SCREEN_WIDTH, SCREEN_HEIGHT-(NavHeader)) backgroundColor:NewGroupTableViewBackgroundColor style:1 delegate:self dataSource:self showsHorizontalScrollIndicator:NO showsVerticalScrollIndicator:NO hidden:NO tag:100 userInteractionEnabled:YES]];
  87. newtableView.separatorStyle = NO;
  88. }
  89. #pragma mark-------------------------UITableView------------------------------------
  90. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  91. {
  92. return 1;
  93. }
  94. //返回每段行数
  95. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  96. {
  97. return dataArray.count;
  98. }
  99. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  100. {
  101. static NSString *Cell = @"Cell";
  102. BusinesswaterDetailCell * cell = [tableView dequeueReusableCellWithIdentifier:Cell];
  103. if (cell == nil) {
  104. cell = [[BusinesswaterDetailCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:Cell];
  105. }
  106. [cell setSelectionStyle:UITableViewCellSelectionStyleNone];//(这种是没有点击后的阴影效果)
  107. cell.accessoryType = UITableViewCellAccessoryNone;
  108. if (dataArray.count>0) {
  109. [cell assignment:dataArray[indexPath.row]];
  110. }
  111. return cell;
  112. }
  113. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  114. {
  115. return fitScreenWidth(98);
  116. }
  117. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  118. }
  119. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
  120. return CGFLOAT_MIN;
  121. }
  122. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
  123. return CGFLOAT_MIN;
  124. }
  125. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
  126. return [[UIView alloc] init];
  127. }
  128. - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
  129. return [[UIView alloc] init];
  130. }
  131. #pragma mark - 上拉下拉初始化
  132. - (void)addRefreshing
  133. {
  134. __weak typeof(self) weakSelf = self;
  135. __weak UITableView *tableView = newtableView;
  136. tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
  137. if ([NetworkRequestManager connectedToNetwork]) {
  138. [weakSelf networkRequest:tableView.mj_header];
  139. }else{
  140. [tableView.mj_header endRefreshing];
  141. }
  142. }];
  143. tableView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
  144. if ([NetworkRequestManager connectedToNetwork]) {
  145. [weakSelf networkRequest:tableView.mj_footer];
  146. }else{
  147. [tableView.mj_footer endRefreshing];
  148. }
  149. }];
  150. }
  151. - (void)dismiss:(id)object
  152. {
  153. if ([object isKindOfClass:[MJRefreshNormalHeader class]]) {
  154. __weak UITableView *newvc = newtableView;
  155. [newvc.mj_header endRefreshing];
  156. }else if ([object isKindOfClass:[MJRefreshBackNormalFooter class]]){
  157. __weak UITableView *newvc = newtableView;
  158. [newvc.mj_footer endRefreshing];
  159. }else {
  160. [MBProgressHUD hideHUDForView:self.view];
  161. }
  162. }
  163. - (void)didReceiveMemoryWarning {
  164. [super didReceiveMemoryWarning];
  165. // Dispose of any resources that can be recreated.
  166. }
  167. /*
  168. #pragma mark - Navigation
  169. // In a storyboard-based application, you will often want to do a little preparation before navigation
  170. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  171. // Get the new view controller using [segue destinationViewController].
  172. // Pass the selected object to the new view controller.
  173. }
  174. */
  175. @end