酷店

KDPForecastOrderListVC.m 5.7KB

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