口袋优选

KBToMoneyViewController.m 6.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. //
  2. // KBToMoneyViewController.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/6/11.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "KBToMoneyViewController.h"
  9. #import "KBChildCommissionCell.h"
  10. #import "KBAccountHeader.h"
  11. #import "KBChildOrderCell.h"
  12. #import "KBChildOrderModel.h"
  13. @interface KBToMoneyViewController ()
  14. <
  15. UITableViewDelegate,
  16. UITableViewDataSource
  17. >
  18. {
  19. UIView *_sectionHeader;
  20. CGFloat rebate_account;//累计成功提现
  21. }
  22. @property (nonatomic, assign) NSInteger page;
  23. @property (nonatomic, strong) UITableView *tableView;
  24. @property (nonatomic, strong) NSMutableArray *dataArr;
  25. @end
  26. @implementation KBToMoneyViewController
  27. - (void)viewDidAppear:(BOOL)animated {
  28. [super viewDidAppear:animated];
  29. [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
  30. }
  31. - (void)viewDidLoad {
  32. [super viewDidLoad];
  33. [self configNavigationBar];
  34. [self configTableView];
  35. [self request];
  36. }
  37. - (void)configTableView {
  38. [self.view addSubview:self.tableView];
  39. }
  40. - (void)configNavigationBar {
  41. [self.navigationBar setNavTitle:@"提现记录"];
  42. self.navigationBar.backgroundColor = [UIColor changeColor];
  43. self.navigationBar.navTitleLabel.textColor = [UIColor whiteColor];
  44. UIButton *leftBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
  45. [leftBtn setImage:[UIImage imageNamed:@"back_white"] forState:UIControlStateNormal];
  46. [leftBtn addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
  47. [self.navigationBar setCustomLeftButtons:@[leftBtn]];
  48. }
  49. - (void)backAction {
  50. [self.navigationController popViewControllerAnimated:YES];
  51. }
  52. - (void)request {
  53. NSString *url=[NSString stringWithFormat:@"%@/api/v2/adzoneCreate/commissionList",BaseURL];
  54. NSDictionary *dic=@{
  55. @"type":@(2),
  56. @"page":@(self.page)
  57. };
  58. [KBHttp post:url params:dic success:^(id json) {
  59. rebate_account = [json[@"rebate_account"] floatValue];
  60. NSArray *arr = [NSArray yy_modelArrayWithClass:[KBChildOrderModel class] json:json[@"data"]];
  61. if (arr.count>0) {
  62. [self.dataArr addObjectsFromArray:arr];
  63. self.tableView.footRefreshState = MJTableFooterRefreshStateLoadMore;
  64. self.tableView.bounces = YES;
  65. [self.tableView reloadData];
  66. }else {
  67. [self setUpNoDataView];
  68. [self noMoreDataWithArray:arr];
  69. // self.tableView.footRefreshState = MJTableFooterRefreshStateNoMore;
  70. if (self.page==1) {
  71. [self.tableView reloadData];
  72. }
  73. self.tableView.bounces = NO;
  74. }
  75. [self.tableView.mj_footer endRefreshing];
  76. } failure:^(NSError *error) {
  77. [self.tableView.mj_footer endRefreshing];
  78. }];
  79. }
  80. - (void)noMoreDataWithArray:(NSArray *)array {
  81. if (array==nil || array.count <= 0) {
  82. MJRefreshBackNormalFooter *foot = (MJRefreshBackNormalFooter *)self.tableView.mj_footer;
  83. [foot setTitle:@"到底啦" forState:MJRefreshStateIdle];
  84. }
  85. }
  86. - (void)setUpNoDataView {
  87. self.tableView.showNoDataView = YES;
  88. self.tableView.defaultNoDataText = @"您还没有任何记录";
  89. self.tableView.defaultNoDataImage = [UIImage imageNamed:@"noData"];
  90. }
  91. #pragma mark -------- UITableView Delegate -----
  92. - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
  93. if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
  94. [cell setSeparatorInset:UIEdgeInsetsMake(0, 15, 0, 15)];
  95. }
  96. }
  97. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  98. return self.dataArr.count;
  99. }
  100. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  101. return 67;
  102. }
  103. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
  104. return 37;
  105. }
  106. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
  107. return 0.1;
  108. }
  109. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  110. KBChildOrderCell *cell = [KBChildOrderCell cellWithTableView:tableView];
  111. KBChildOrderModel *model = self.dataArr[indexPath.row];
  112. cell.model=model;
  113. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  114. return cell;
  115. }
  116. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
  117. _sectionHeader = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 37)];
  118. _sectionHeader.backgroundColor = [UIColor YHColorWithHex:0xF4F4F4];
  119. UILabel *priceLabel = [[UILabel alloc] initWithFrame:CGRectMake(25, 0, 200, 37)];
  120. priceLabel.textColor = [UIColor YHColorWithHex:0x141414];
  121. priceLabel.font = [UIFont systemFontOfSize:14];
  122. priceLabel.text = [NSString stringWithFormat:@"累计成功提现:¥%.2f",rebate_account];
  123. [_sectionHeader addSubview:priceLabel];
  124. return _sectionHeader;
  125. }
  126. #pragma mark ------- layzer ------
  127. - (UITableView *)tableView {
  128. if (!_tableView) {
  129. _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, NavBarHeight, SCREEN_WIDTH, SCREEN_HEIGHT-NavBarHeight) style:UITableViewStylePlain];
  130. _tableView.estimatedSectionHeaderHeight = 0;
  131. _tableView.estimatedSectionFooterHeight = 0;
  132. _tableView.sectionFooterHeight = 0;
  133. _tableView.sectionHeaderHeight = 0;
  134. _tableView.estimatedRowHeight = 0;
  135. _tableView.delegate = self;
  136. _tableView.dataSource = self;
  137. _tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
  138. _tableView.backgroundColor = [UIColor yhGrayColor];
  139. _tableView.bounces = YES;
  140. _tableView.showsVerticalScrollIndicator = NO;
  141. _tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
  142. _tableView.separatorColor = [UIColor YHColorWithHex:0xEEEEEE];
  143. _tableView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
  144. self.page ++;
  145. [self request];
  146. }];
  147. _tableView.footRefreshState = MJTableFooterRefreshStateNormal;
  148. }
  149. return _tableView;
  150. }
  151. - (NSMutableArray *)dataArr {
  152. if (!_dataArr) {
  153. _dataArr = [NSMutableArray array];
  154. }
  155. return _dataArr;
  156. }
  157. - (void)didReceiveMemoryWarning {
  158. [super didReceiveMemoryWarning];
  159. // Dispose of any resources that can be recreated.
  160. }
  161. /*
  162. #pragma mark - Navigation
  163. // In a storyboard-based application, you will often want to do a little preparation before navigation
  164. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  165. // Get the new view controller using [segue destinationViewController].
  166. // Pass the selected object to the new view controller.
  167. }
  168. */
  169. @end