dkahgld

ZBChildOrderViewController.m 5.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. //
  2. // ZBChildOrderViewController.m
  3. // ZBProject
  4. //
  5. // Created by 学丽 on 2019/4/3.
  6. // Copyright © 2019 ZB. All rights reserved.
  7. //
  8. #import "ZBChildOrderViewController.h"
  9. @interface ZBChildOrderViewController ()<UITableViewDelegate, UITableViewDataSource,LDChildCommissionCellDelegate>
  10. @property (nonatomic, strong) NSMutableArray *dataArr;
  11. @property (nonatomic, assign) NSInteger page;
  12. @end
  13. @implementation ZBChildOrderViewController
  14. - (void)viewDidLoad {
  15. [super viewDidLoad];
  16. [self configTableView];
  17. [self requestAndRefresh:YES];
  18. }
  19. - (void)configTableView {
  20. self.page = 1;
  21. [self.view addSubview:self.tableView];
  22. [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  23. make.left.top.right.mas_equalTo(0);
  24. make.bottom.mas_equalTo(self.view.mas_bottom);
  25. }];
  26. }
  27. #pragma mark -------- UITableView Delegate -----
  28. - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
  29. if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
  30. [cell setSeparatorInset:UIEdgeInsetsMake(0, 15, 0, 15)];
  31. }
  32. }
  33. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  34. return self.dataArr.count;
  35. }
  36. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  37. return 110;
  38. }
  39. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
  40. return 0.1;
  41. }
  42. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
  43. return 0.1;
  44. }
  45. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  46. LDChildCommissionCell *cell = [LDChildCommissionCell cellWithTableView:tableView];
  47. LDChildCommissionModel *model=self.dataArr[indexPath.row];
  48. cell.model=model;
  49. cell.delegatre =self;
  50. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  51. return cell;
  52. }
  53. #pragma mark ------ scrollView delegate -----
  54. //- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
  55. //
  56. // if (!self.childCanScroll) {
  57. // scrollView.contentOffset = CGPointZero;
  58. // }
  59. // if (scrollView.contentOffset.y <= 0) {
  60. // self.childCanScroll = NO;
  61. // scrollView.contentOffset = CGPointZero;
  62. // [[NSNotificationCenter defaultCenter] postNotificationName:@"leaveTop" object:nil];//到顶通知父视图改变状态
  63. // }
  64. //}
  65. #pragma mark -网络请求
  66. #pragma mark - request
  67. - (void)requestAndRefresh:(BOOL)refresh {
  68. if (![AccountTool isLogin]) {
  69. return;
  70. }
  71. if (![self.tableView.mj_footer isRefreshing]) {
  72. [LoadingView showInView:self.view];
  73. }
  74. NSString *url=[NSString stringWithFormat:@"%@api/order/orderList",BASEURL];
  75. NSDictionary *dic=@{
  76. @"type":@(self.type),
  77. @"page":@(self.page),
  78. };
  79. [ZBHTTP post:url params:dic success:^(id json) {
  80. if (refresh) {
  81. [self.dataArr removeAllObjects];
  82. }
  83. NSArray *arr = [NSArray yy_modelArrayWithClass:[LDChildCommissionModel class] json:json];
  84. if (arr.count>0) {
  85. [self.dataArr addObjectsFromArray:arr];
  86. [self.tableView.mj_footer endRefreshing];
  87. }else {
  88. [self setUpNoDataView];
  89. [self noMoreDataWithArray:arr];
  90. }
  91. if (self.dataArr.count == 0) {
  92. [self setUpNoDataView];
  93. }
  94. [self.tableView reloadData];
  95. [LoadingView dismiss];
  96. } failure:^(NSError *error) {
  97. [LoadingView dismiss];
  98. [self.tableView.mj_footer endRefreshing];
  99. }];
  100. }
  101. - (void)setUpNoDataView {
  102. self.tableView.showNoDataView = YES;
  103. self.tableView.noDataImageOffsetY = -70;
  104. self.tableView.defaultNoDataText = @"还没有记录";
  105. self.tableView.defaultNoDataImage = [UIImage imageNamed:@"no_order"];
  106. }
  107. - (void)noMoreDataWithArray:(NSArray *)array {
  108. if (array==nil || array.count <= 0) {
  109. [self.tableView.mj_footer endRefreshingWithNoMoreData];
  110. }
  111. }
  112. #pragma mark ------- layzer ------
  113. - (UITableView *)tableView {
  114. if (!_tableView) {
  115. _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-NavBarHeight-70) style:UITableViewStyleGrouped];
  116. _tableView.estimatedSectionHeaderHeight = 0;
  117. _tableView.estimatedSectionFooterHeight = 0;
  118. _tableView.sectionFooterHeight = 0;
  119. _tableView.sectionHeaderHeight = 0;
  120. _tableView.estimatedRowHeight = 0;
  121. _tableView.delegate = self;
  122. _tableView.dataSource = self;
  123. _tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
  124. _tableView.backgroundColor = [UIColor yhGrayColor];
  125. _tableView.bounces = YES;
  126. _tableView.showsVerticalScrollIndicator = NO;
  127. _tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
  128. _tableView.separatorColor = [UIColor YHColorWithHex:0xEEEEEE];
  129. _tableView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
  130. self.page ++;
  131. [self requestAndRefresh:NO];
  132. }];
  133. }
  134. return _tableView;
  135. }
  136. -(NSMutableArray *)dataArr{
  137. if (!_dataArr) {
  138. _dataArr=[NSMutableArray array];
  139. }
  140. return _dataArr;
  141. }
  142. - (void)didReceiveMemoryWarning {
  143. [super didReceiveMemoryWarning];
  144. // Dispose of any resources that can be recreated.
  145. }
  146. -(void)ClickModel:(LDChildCommissionModel *)model
  147. {
  148. // LDAdWebViewController *web = [[LDAdWebViewController alloc] init];
  149. // web.url = model.red_url;
  150. // [self.navigationController pushViewController:web animated:YES];
  151. }
  152. @end