123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- //
- // KDPOrderDetailViewController.m
- // KuDianProject
- //
- // Created by admin on 2019/7/9.
- // Copyright © 2019 KDP. All rights reserved.
- //
- #import "KDPOrderDetailViewController.h"
- #import "KDPOrderDetailTableViewCell.h"
- #import "KDPLiveDetailModel.h"
- @interface KDPOrderDetailViewController ()<UITableViewDelegate,UITableViewDataSource,DZNEmptyDataSetDelegate,DZNEmptyDataSetSource>
- @property (nonatomic, strong) UITableView *tableview;
- @property (nonatomic, assign) NSInteger page;
- @property (nonatomic, strong) NSMutableArray *dataSource;
- @end
- @implementation KDPOrderDetailViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
- self.view.backgroundColor = [UIColor colorWithHex:0xF9F9F9];
- self.navBar.navTitleLabel.text = @"直播订单明细";
- [self.view addSubview:self.tableview];
- [self.navBar addleftReturnButton:self selector:@selector(popAction)];
- }
- - (void)requestDetailDataWithPage:(NSInteger )page{
- NSString *detailUrl = [NSString stringWithFormat:@"%@api/onlive/liveDetail",KDURL];
- self.live_stream_id = self.live_stream_id.length ? self.live_stream_id : @"";
- [LoadingView show];
- [KDPNetworkRequestHTTP postURL:detailUrl params:@{@"page":@(self.page),@"live_stream_id":self.live_stream_id} success:^(id _Nonnull json) {
- [LoadingView dismiss];
- NSArray *liveDataArr = [NSArray yy_modelArrayWithClass:[KDPLiveDetailModel class] json:json[@"data"]];
- if (self.page == 1) {
- [self.dataSource removeAllObjects];
- }
- if (liveDataArr.count > 0) {
- [self.dataSource addObjectsFromArray:liveDataArr];
- } else{
- [self.tableview.mj_footer endRefreshingWithNoMoreData];
- }
- [self.tableview.mj_footer endRefreshing];
- [self.tableview.mj_header endRefreshing];
- [self.tableview reloadData];
- } failure:^(NSError * _Nonnull error) {
- [LoadingView dismiss];
- [self.tableview.mj_footer endRefreshing];
- [self.tableview.mj_header endRefreshing];
- }];
- }
- - (void)popAction{
- [self.navigationController popViewControllerAnimated:YES];
- }
- - (UITableView *)tableview{
- if (!_tableview) {
- _tableview = [[UITableView alloc] initWithFrame:CGRectMake(0, KDNavBarHeight+10, SCREEN_WIDTH, SCREEN_HEIGHT-KDNavBarHeight-10) style:UITableViewStylePlain];
- _tableview.dataSource = self;
- _tableview.delegate = self;
- _tableview.rowHeight = 136;
- _tableview.separatorStyle = UITableViewCellSeparatorStyleNone;
- _tableview.backgroundColor = [UIColor clearColor];
- [_tableview registerClass:[KDPOrderDetailTableViewCell class] forCellReuseIdentifier:NSStringFromClass([KDPOrderDetailTableViewCell class])];
- _tableview.showsVerticalScrollIndicator = NO;
- _tableview.showsHorizontalScrollIndicator = NO;
- _tableview.emptyDataSetDelegate = self;
- _tableview.emptyDataSetSource = self;
- _tableview.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
- self.page = 1;
- [self requestDetailDataWithPage:self.page];
- }];
- _tableview.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
- self.page ++;
- [self requestDetailDataWithPage:self.page];
- }];
- [_tableview.mj_header beginRefreshing];
- }
- return _tableview;
- }
- - (NSMutableArray *)dataSource{
- if (!_dataSource) {
- _dataSource = [NSMutableArray array];
- }
- return _dataSource;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
- KDPOrderDetailTableViewCell *detailCell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([KDPOrderDetailTableViewCell class])];
- detailCell.selectionStyle = UITableViewCellSelectionStyleNone;
- detailCell.liveTime = self.live_time;
- [detailCell configWithViewModel:self.dataSource[indexPath.row] indexpath:indexPath];
- return detailCell;
- }
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
- return 1;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
- return self.dataSource.count;
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
-
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
- if (indexPath.row == 0) {
- return 136;
- }
- return 96;
- }
- - (UIImage *)imageForEmptyDataSet:(UIScrollView *)scrollView{
- return [UIImage imageNamed:@"no_order"];
- }
- - (BOOL)emptyDataSetShouldAllowScroll:(UIScrollView *)scrollView{
- return YES;
- }
- - (NSAttributedString *)titleForEmptyDataSet:(UIScrollView *)scrollView{
- return [[NSAttributedString alloc] initWithString:@"还没有记录" attributes:@{NSForegroundColorAttributeName:[UIColor colorWithHex:0x333333],NSFontAttributeName:FONT_SYS(12)}];
- }
- - (CGFloat )spaceHeightForEmptyDataSet:(UIScrollView *)scrollView{
- return 30;
- }
- @end
|