酷店

KDPForecastVC.m 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. //
  2. // KDPForecastVC.m
  3. // KuDianProject
  4. //
  5. // Created by 学丽 on 2019/7/8.
  6. // Copyright © 2019 KDP. All rights reserved.
  7. //
  8. #import "KDPForecastVC.h"
  9. #import "KDPForecastListCell.h"
  10. @interface KDPForecastVC ()<UITableViewDelegate,UITableViewDataSource,DZNEmptyDataSetDelegate,DZNEmptyDataSetSource>
  11. {
  12. UILabel *_orderNumMoneyLabel;
  13. }
  14. @property(nonatomic,strong)NSMutableArray *dataArray;
  15. @property(nonatomic,strong)UITableView *forecastView;
  16. @end
  17. @implementation KDPForecastVC
  18. - (void)viewDidLoad {
  19. [super viewDidLoad];
  20. [self setNavUI];
  21. [self getForecastEarn];
  22. }
  23. -(void)getForecastEarn
  24. {
  25. [LoadingView show];
  26. [KDPNetworkRequestHTTP postURL:foreastURL params:@{@"type":@"1"} success:^(id _Nonnull json) {
  27. _orderNumMoneyLabel.text=[NSString stringWithFormat:@"预估订单:%@ 收益:%@元",json[@"total_count"],json[@"total_rebate"]];
  28. [self.dataArray removeAllObjects];
  29. [self.dataArray addObjectsFromArray:[NSArray yy_modelArrayWithClass:[KDPBalanceModel class] json:json[@"all_month"]]];
  30. [self.forecastView reloadData];
  31. [LoadingView dismiss];
  32. } failure:^(NSError * _Nonnull error) {
  33. [LoadingView dismiss];
  34. }];
  35. }
  36. -(void)setNavUI
  37. {
  38. self.view.backgroundColor=[UIColor whiteColor];
  39. [self.navBar addleftReturnButton:self selector:@selector(returnClickBtn)];
  40. self.navBar.navTitleLabel.text=@"预估收益";
  41. [self.view addSubview:self.forecastView];
  42. }
  43. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  44. {
  45. KDPForecastListCell *listC=[tableView dequeueReusableCellWithIdentifier:@"fore"];
  46. if (!listC) {
  47. listC=[[KDPForecastListCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"fore"];
  48. listC.selectionStyle=UITableViewCellSelectionStyleNone;
  49. }
  50. listC.model=self.dataArray[indexPath.row]; listC.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
  51. return listC;
  52. }
  53. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  54. {
  55. return self.dataArray.count;
  56. }
  57. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  58. {
  59. KDPForecastOrderListVC *orderV=[[KDPForecastOrderListVC alloc]init];
  60. KDPBalanceModel *model=self.dataArray[indexPath.row];
  61. orderV.yearMonthDay=model.yearAndMonth;
  62. orderV.isDay =@"0";
  63. [self.navigationController pushViewController:orderV animated:YES];
  64. }
  65. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  66. {
  67. return 50;
  68. }
  69. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  70. {
  71. return 1;
  72. }
  73. - (UIImage *)imageForEmptyDataSet:(UIScrollView *)scrollView{
  74. return [UIImage imageNamed:@"no_order"];
  75. }
  76. - (BOOL)emptyDataSetShouldAllowScroll:(UIScrollView *)scrollView{
  77. return YES;
  78. }
  79. - (NSAttributedString *)titleForEmptyDataSet:(UIScrollView *)scrollView{
  80. return [[NSAttributedString alloc] initWithString:@"还没有记录" attributes:@{NSForegroundColorAttributeName:[UIColor colorWithHex:0x333333],NSFontAttributeName:FONT_SYS(12)}];
  81. }
  82. - (CGFloat )spaceHeightForEmptyDataSet:(UIScrollView *)scrollView{
  83. return 50;
  84. }
  85. -(void)returnClickBtn
  86. {
  87. [self.navigationController popViewControllerAnimated:YES];
  88. }
  89. -(void)viewWillAppear:(BOOL)animated
  90. {
  91. [super viewWillAppear:animated];
  92. self.navigationController.navigationBar.hidden=YES;
  93. self.tabBarController.tabBar.hidden=YES;
  94. }
  95. -(void)viewWillDisappear:(BOOL)animated
  96. {
  97. [super viewWillDisappear:animated];
  98. self.tabBarController.tabBar.hidden=NO;
  99. }
  100. -(UITableView *)forecastView
  101. {
  102. if (!_forecastView) {
  103. _forecastView=[[UITableView alloc]initWithFrame:CGRectMake(0, KDNavBarHeight, SCREEN_WIDTH, self.view.height)];
  104. _forecastView.backgroundColor=[UIColor clearColor];
  105. _forecastView.emptyDataSetDelegate = self;
  106. _forecastView.emptyDataSetSource = self; _forecastView.separatorStyle=UITableViewCellSeparatorStyleNone;
  107. _forecastView.delegate=self;
  108. _forecastView.dataSource=self;
  109. [self addtabheader];
  110. }
  111. return _forecastView;
  112. }
  113. -(void)addtabheader
  114. {
  115. UIView *backV=[[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 47)];
  116. backV.backgroundColor=[UIColor clearColor];
  117. self.forecastView.tableHeaderView=backV;
  118. _orderNumMoneyLabel=[[UILabel alloc]initWithFrame:CGRectMake(15, 0, SCREEN_WIDTH-30, 46)];
  119. _orderNumMoneyLabel.text=@"预估订单:-- 收益:---元";
  120. _orderNumMoneyLabel.font=[UIFont systemFontOfSize:14];
  121. _orderNumMoneyLabel.textColor=[UIColor blackColor];
  122. [backV addSubview:_orderNumMoneyLabel];
  123. UIView *lineV=[[UIView alloc]initWithFrame:CGRectMake(10, 46, SCREEN_WIDTH-20, 1)];
  124. lineV.backgroundColor=[UIColor colorWithHexString:LineColor];
  125. [backV addSubview:lineV];
  126. }
  127. -(NSMutableArray *)dataArray
  128. {
  129. if (!_dataArray) {
  130. _dataArray=[NSMutableArray array];
  131. }
  132. return _dataArray;
  133. }
  134. @end