酷店

KDPForecastOrderListVC.m 5.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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 50;
  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. _forecastView.emptyDataSetDelegate = self;
  120. _forecastView.emptyDataSetSource = self;
  121. _forecastView.mj_footer=[MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
  122. page_num++;
  123. [self getMonthOrderList];
  124. }];
  125. [self addtabheader];
  126. }
  127. return _forecastView;
  128. }
  129. -(void)addtabheader
  130. {
  131. UIView *backV=[[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 46)];
  132. backV.backgroundColor=[UIColor clearColor];
  133. self.forecastView.tableHeaderView=backV;
  134. _orderLabel=[[UILabel alloc]initWithFrame:CGRectMake(15, 0, SCREEN_WIDTH-30, 41)];
  135. _orderLabel.text=@"----- 订单:-- 收益:---元";
  136. _orderLabel.font=[UIFont systemFontOfSize:14];
  137. _orderLabel.textColor=[UIColor blackColor];
  138. [backV addSubview:_orderLabel];
  139. UIView *lineV=[[UIView alloc]initWithFrame:CGRectMake(10, 41, SCREEN_WIDTH-20, 5)];
  140. lineV.backgroundColor=[UIColor colorWithHexString:LineColor];
  141. [backV addSubview:lineV];
  142. }
  143. -(NSMutableArray *)dataArray
  144. {
  145. if (!_dataArray) {
  146. _dataArray=[NSMutableArray array];
  147. }
  148. return _dataArray;
  149. }
  150. @end