酷店

KDPOrderDetailListNewVC.m 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. //
  2. // KDPOrderDetailListNewVC.m
  3. // KuDianProject
  4. //
  5. // Created by 学丽 on 2019/7/12.
  6. // Copyright © 2019 KDP. All rights reserved.
  7. //
  8. #import "KDPOrderDetailListNewVC.h"
  9. #import "KDPForecastOrderCell.h"
  10. @interface KDPOrderDetailListNewVC ()<UITableViewDelegate,UITableViewDataSource,DZNEmptyDataSetDelegate,DZNEmptyDataSetSource>
  11. {
  12. NSInteger page_num;
  13. }
  14. @property(nonatomic,strong)UITableView *forecastView;
  15. @property(nonatomic,strong)NSMutableArray *dataArray;
  16. @end
  17. @implementation KDPOrderDetailListNewVC
  18. - (void)viewDidLoad {
  19. [super viewDidLoad];
  20. self.navBar.hidden=YES;
  21. self.view.backgroundColor=[UIColor whiteColor];
  22. page_num = 1;
  23. [self.view addSubview:self.forecastView];
  24. [self ordeListData];
  25. }
  26. -(void)ordeListData
  27. {
  28. [LoadingView show];
  29. NSInteger type=[self.typeDic[@"type"] integerValue];
  30. NSDictionary *dic=@{@"type":@(type),@"page":@(page_num)} ;
  31. [KDPNetworkRequestHTTP postURL:orderDetailListURL params:dic success:^(id _Nonnull json) {
  32. [LoadingView dismiss];
  33. if (page_num == 1) {
  34. self.dataArray =[NSMutableArray array];
  35. }
  36. NSArray *arr = [NSArray yy_modelArrayWithClass:[KDPOrderModel class] json:json];
  37. if (arr.count>0) {
  38. [self.dataArray addObjectsFromArray:arr];
  39. }else{
  40. [self.forecastView.mj_footer endRefreshingWithNoMoreData];
  41. }
  42. [self.forecastView.mj_footer endRefreshing];
  43. [self.forecastView.mj_header endRefreshing];
  44. [self.forecastView reloadData];
  45. } failure:^(NSError * _Nonnull error) {
  46. [LoadingView dismiss];
  47. }];
  48. }
  49. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  50. {
  51. KDPForecastOrderCell *listC=[tableView dequeueReusableCellWithIdentifier:@"foreorder"];
  52. if (!listC) {
  53. listC=[[KDPForecastOrderCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"foreorder"];
  54. listC.selectionStyle=UITableViewCellSelectionStyleNone;
  55. }
  56. listC.model=self.dataArray[indexPath.row];
  57. return listC;
  58. }
  59. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  60. {
  61. return self.dataArray.count;
  62. }
  63. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  64. {
  65. }
  66. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  67. {
  68. return 110;
  69. }
  70. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  71. {
  72. return 1;
  73. }
  74. - (UIImage *)imageForEmptyDataSet:(UIScrollView *)scrollView{
  75. return [UIImage imageNamed:@"no_order"];
  76. }
  77. - (BOOL)emptyDataSetShouldAllowScroll:(UIScrollView *)scrollView{
  78. return YES;
  79. }
  80. - (NSAttributedString *)titleForEmptyDataSet:(UIScrollView *)scrollView{
  81. return [[NSAttributedString alloc] initWithString:@"还没有记录" attributes:@{NSForegroundColorAttributeName:[UIColor colorWithHex:0x333333],NSFontAttributeName:FONT_SYS(12)}];
  82. }
  83. - (CGFloat )spaceHeightForEmptyDataSet:(UIScrollView *)scrollView{
  84. return 50;
  85. }
  86. -(UITableView *)forecastView
  87. {
  88. if (!_forecastView) {
  89. _forecastView=[[UITableView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, self.view.height-KDNavBarHeight-120)];
  90. _forecastView.backgroundColor=[UIColor clearColor];
  91. _forecastView.separatorStyle=UITableViewCellSeparatorStyleNone;
  92. _forecastView.delegate=self;
  93. _forecastView.dataSource=self;
  94. _forecastView.showsVerticalScrollIndicator=NO;
  95. _forecastView.mj_header=[MJRefreshNormalHeader headerWithRefreshingBlock:^{
  96. page_num = 1;
  97. [self ordeListData];
  98. }];
  99. _forecastView.emptyDataSetDelegate = self;
  100. _forecastView.emptyDataSetSource = self;
  101. _forecastView.mj_footer=[MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
  102. page_num++;
  103. [self ordeListData];
  104. }];
  105. }
  106. return _forecastView;
  107. }
  108. /*
  109. #pragma mark - Navigation
  110. // In a storyboard-based application, you will often want to do a little preparation before navigation
  111. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  112. // Get the new view controller using [segue destinationViewController].
  113. // Pass the selected object to the new view controller.
  114. }
  115. */
  116. @end