dkahgld

ZBEstimatedViewController.m 4.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. //
  2. // ZBEstimatedViewController.m
  3. // ZBProject
  4. //
  5. // Created by 学丽 on 2019/4/9.
  6. // Copyright © 2019 ZB. All rights reserved.
  7. //
  8. #import "ZBEstimatedViewController.h"
  9. #import "ZBIncomeMonthOrderListCell.h"
  10. @interface ZBEstimatedViewController ()<UITableViewDelegate,UITableViewDataSource>
  11. @property(nonatomic,strong)UITableView *tableViews;
  12. @property(nonatomic,strong)NSMutableArray *listArray;
  13. @property(nonatomic,strong)UILabel *titleL;
  14. @end
  15. @implementation ZBEstimatedViewController
  16. - (void)viewDidLoad {
  17. [super viewDidLoad];
  18. [self initTableview];
  19. [self getMonthWithtype:self.types];
  20. }
  21. #pragma mark---每月预估
  22. -(void)getMonthWithtype:(NSString *)type
  23. {//预估1,结算2
  24. if (![AccountTool isLogin]) {
  25. return;
  26. }
  27. NSDictionary *dic =@{@"type":type};
  28. [LoadingView showInView:self.view];
  29. [ZBHTTP post:getEarnEveryMonthURL params:dic success:^(id _Nonnull json) {
  30. [LoadingView dismiss];
  31. NSArray *array =[NSArray yy_modelArrayWithClass:[ZBEarnModel class] json:json[@"all_month"]];
  32. [self.listArray removeAllObjects];
  33. [self.listArray addObjectsFromArray:array];
  34. if (self.types.integerValue == 1) {
  35. self.titleL.text=[NSString stringWithFormat:@"预估订单:%@ 收益:%@元",json[@"total_count"],json[@"total_rebate"]];
  36. }else{
  37. self.titleL.text=[NSString stringWithFormat:@"结算订单:%@ 收益:%@元",json[@"total_count"],json[@"total_rebate"]];
  38. }
  39. [self.tableViews reloadData];
  40. NSLog(@"%@",json);
  41. } failure:^(NSError * _Nonnull error) {
  42. [LoadingView dismiss];
  43. }];
  44. }
  45. -(void)initTableview
  46. {
  47. UIView *headV =[[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 50)];
  48. headV.backgroundColor=[UIColor whiteColor];
  49. self.titleL =[[UILabel alloc]initWithFrame:CGRectMake(19, 0, 200, 50)];
  50. self.titleL.font=[UIFont systemFontOfSize:14];
  51. self.titleL.textColor=[UIColor YHColorWithHex:0x000000];
  52. self.titleL.text=@"预估订单:- 收益:---元";
  53. [headV addSubview:self.titleL];
  54. [self.view addSubview:self.tableViews];
  55. [self.tableViews mas_makeConstraints:^(MASConstraintMaker *make) {
  56. make.top.mas_equalTo(0);
  57. make.bottom.mas_equalTo(self.view.mas_bottom);
  58. make.left.right.mas_equalTo(0);
  59. }];
  60. self.tableViews.tableHeaderView=headV;
  61. }
  62. #pragma mark---TableViewDelegate&&DataSource
  63. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  64. {
  65. ZBIncomeMonthOrderListCell *listC =[tableView dequeueReusableCellWithIdentifier:@"list"];
  66. if (!listC) {
  67. listC=[[ZBIncomeMonthOrderListCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"list"];
  68. listC.selectionStyle=UITableViewCellSelectionStyleNone;
  69. }
  70. listC.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
  71. if (indexPath.row == self.listArray.count-1) {
  72. listC.lineV.hidden = YES;
  73. }else{
  74. listC.lineV.hidden=NO;
  75. }
  76. listC.yearLabel.hidden=NO;
  77. [listC.timeLabel mas_updateConstraints:^(MASConstraintMaker *make) {
  78. make.height.mas_equalTo(25);
  79. make.top.mas_equalTo(5);
  80. }];
  81. listC.model = self.listArray[indexPath.row];
  82. return listC;
  83. }
  84. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  85. {
  86. return self.listArray.count;
  87. }
  88. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  89. {
  90. return 1;
  91. }
  92. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  93. {
  94. return 52;
  95. }
  96. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  97. {
  98. ZBIncomeViewController *incomV =[[ZBIncomeViewController alloc]init];
  99. ZBEarnModel *model=self.listArray[indexPath.row];
  100. incomV.isDay =0;//按月
  101. incomV.yearMonthDay=model.yearAndMonth;
  102. incomV.type=self.types;//1:预估收入 2:结算收入
  103. [self.navigationController pushViewController:incomV animated:YES];
  104. }
  105. -(UITableView *)tableViews
  106. {
  107. if (!_tableViews) {
  108. _tableViews =[[UITableView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT) style:UITableViewStylePlain];
  109. _tableViews.delegate=self;
  110. _tableViews.dataSource=self;
  111. _tableViews.backgroundColor=[UIColor YHColorWithHex:0xF4F4F4];
  112. _tableViews.separatorStyle=UITableViewCellSeparatorStyleNone;
  113. _tableViews.sectionHeaderHeight=0;
  114. _tableViews.showsHorizontalScrollIndicator=NO;
  115. _tableViews.showsVerticalScrollIndicator=NO;
  116. }
  117. return _tableViews;
  118. }
  119. -(NSMutableArray *)listArray
  120. {
  121. if (!_listArray) {
  122. _listArray=[NSMutableArray array];
  123. }
  124. return _listArray;
  125. }
  126. #pragma mark---常见问题
  127. -(void)accclickBtn
  128. {
  129. }
  130. @end