酷店

KDPOrderDetailViewController.m 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. //
  2. // KDPOrderDetailViewController.m
  3. // KuDianProject
  4. //
  5. // Created by admin on 2019/7/9.
  6. // Copyright © 2019 KDP. All rights reserved.
  7. //
  8. #import "KDPOrderDetailViewController.h"
  9. #import "KDPOrderDetailTableViewCell.h"
  10. #import "KDPLiveDetailModel.h"
  11. @interface KDPOrderDetailViewController ()<UITableViewDelegate,UITableViewDataSource,DZNEmptyDataSetDelegate,DZNEmptyDataSetSource>
  12. @property (nonatomic, strong) UITableView *tableview;
  13. @property (nonatomic, assign) NSInteger page;
  14. @property (nonatomic, strong) NSMutableArray *dataSource;
  15. @end
  16. @implementation KDPOrderDetailViewController
  17. - (void)viewDidLoad {
  18. [super viewDidLoad];
  19. // Do any additional setup after loading the view.
  20. self.view.backgroundColor = [UIColor colorWithHex:0xF9F9F9];
  21. self.navBar.navTitleLabel.text = @"直播订单明细";
  22. [self.view addSubview:self.tableview];
  23. [self.navBar addleftReturnButton:self selector:@selector(popAction)];
  24. }
  25. - (void)requestDetailDataWithPage:(NSInteger )page{
  26. NSString *detailUrl = [NSString stringWithFormat:@"%@api/onlive/liveDetail",KDURL];
  27. self.live_stream_id = self.live_stream_id.length ? self.live_stream_id : @"";
  28. [LoadingView show];
  29. [KDPNetworkRequestHTTP postURL:detailUrl params:@{@"page":@(self.page),@"live_stream_id":self.live_stream_id} success:^(id _Nonnull json) {
  30. [LoadingView dismiss];
  31. NSArray *liveDataArr = [NSArray yy_modelArrayWithClass:[KDPLiveDetailModel class] json:json[@"data"]];
  32. if (self.page == 1) {
  33. [self.dataSource removeAllObjects];
  34. }
  35. if (liveDataArr.count > 0) {
  36. [self.dataSource addObjectsFromArray:liveDataArr];
  37. } else{
  38. [self.tableview.mj_footer endRefreshingWithNoMoreData];
  39. }
  40. [self.tableview.mj_footer endRefreshing];
  41. [self.tableview.mj_header endRefreshing];
  42. [self.tableview reloadData];
  43. } failure:^(NSError * _Nonnull error) {
  44. [LoadingView dismiss];
  45. [self.tableview.mj_footer endRefreshing];
  46. [self.tableview.mj_header endRefreshing];
  47. }];
  48. }
  49. - (void)popAction{
  50. [self.navigationController popViewControllerAnimated:YES];
  51. }
  52. - (UITableView *)tableview{
  53. if (!_tableview) {
  54. _tableview = [[UITableView alloc] initWithFrame:CGRectMake(0, KDNavBarHeight+10, SCREEN_WIDTH, SCREEN_HEIGHT-KDNavBarHeight-10) style:UITableViewStylePlain];
  55. _tableview.dataSource = self;
  56. _tableview.delegate = self;
  57. _tableview.rowHeight = 136;
  58. _tableview.separatorStyle = UITableViewCellSeparatorStyleNone;
  59. _tableview.backgroundColor = [UIColor clearColor];
  60. [_tableview registerClass:[KDPOrderDetailTableViewCell class] forCellReuseIdentifier:NSStringFromClass([KDPOrderDetailTableViewCell class])];
  61. _tableview.showsVerticalScrollIndicator = NO;
  62. _tableview.showsHorizontalScrollIndicator = NO;
  63. _tableview.emptyDataSetDelegate = self;
  64. _tableview.emptyDataSetSource = self;
  65. _tableview.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
  66. self.page = 1;
  67. [self requestDetailDataWithPage:self.page];
  68. }];
  69. _tableview.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
  70. self.page ++;
  71. [self requestDetailDataWithPage:self.page];
  72. }];
  73. [_tableview.mj_header beginRefreshing];
  74. }
  75. return _tableview;
  76. }
  77. - (NSMutableArray *)dataSource{
  78. if (!_dataSource) {
  79. _dataSource = [NSMutableArray array];
  80. }
  81. return _dataSource;
  82. }
  83. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  84. KDPOrderDetailTableViewCell *detailCell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([KDPOrderDetailTableViewCell class])];
  85. detailCell.selectionStyle = UITableViewCellSelectionStyleNone;
  86. detailCell.liveTime = self.live_time;
  87. [detailCell configWithViewModel:self.dataSource[indexPath.row] indexpath:indexPath];
  88. return detailCell;
  89. }
  90. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  91. return 1;
  92. }
  93. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  94. return self.dataSource.count;
  95. }
  96. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  97. }
  98. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  99. if (indexPath.row == 0) {
  100. return 136;
  101. }
  102. return 96;
  103. }
  104. - (UIImage *)imageForEmptyDataSet:(UIScrollView *)scrollView{
  105. return [UIImage imageNamed:@"no_order"];
  106. }
  107. - (BOOL)emptyDataSetShouldAllowScroll:(UIScrollView *)scrollView{
  108. return YES;
  109. }
  110. - (NSAttributedString *)titleForEmptyDataSet:(UIScrollView *)scrollView{
  111. return [[NSAttributedString alloc] initWithString:@"还没有记录" attributes:@{NSForegroundColorAttributeName:[UIColor colorWithHex:0x333333],NSFontAttributeName:FONT_SYS(12)}];
  112. }
  113. - (CGFloat )spaceHeightForEmptyDataSet:(UIScrollView *)scrollView{
  114. return 30;
  115. }
  116. @end