省钱达人

DRAccountDetailController.m 7.5KB

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