// // KDPOrderDetailListNewVC.m // KuDianProject // // Created by 学丽 on 2019/7/12. // Copyright © 2019 KDP. All rights reserved. // #import "KDPOrderDetailListNewVC.h" #import "KDPForecastOrderCell.h" @interface KDPOrderDetailListNewVC () { NSInteger page_num; } @property(nonatomic,strong)UITableView *forecastView; @property(nonatomic,strong)NSMutableArray *dataArray; @end @implementation KDPOrderDetailListNewVC - (void)viewDidLoad { [super viewDidLoad]; self.navBar.hidden=YES; self.view.backgroundColor=[UIColor whiteColor]; page_num = 1; [self.view addSubview:self.forecastView]; [self ordeListData]; } -(void)ordeListData { [LoadingView show]; NSInteger type=[self.typeDic[@"type"] integerValue]; NSDictionary *dic=@{@"type":@(type),@"page":@(page_num)} ; [KDPNetworkRequestHTTP postURL:orderDetailListURL params:dic success:^(id _Nonnull json) { [LoadingView dismiss]; if (page_num == 1) { self.dataArray =[NSMutableArray array]; } NSArray *arr = [NSArray yy_modelArrayWithClass:[KDPOrderModel class] json:json]; if (arr.count>0) { [self.dataArray addObjectsFromArray:arr]; }else{ [self.forecastView.mj_footer endRefreshingWithNoMoreData]; } [self.forecastView.mj_footer endRefreshing]; [self.forecastView.mj_header endRefreshing]; [self.forecastView reloadData]; } failure:^(NSError * _Nonnull error) { [LoadingView dismiss]; }]; } -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { KDPForecastOrderCell *listC=[tableView dequeueReusableCellWithIdentifier:@"foreorder"]; if (!listC) { listC=[[KDPForecastOrderCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"foreorder"]; listC.selectionStyle=UITableViewCellSelectionStyleNone; } listC.model=self.dataArray[indexPath.row]; return listC; } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return self.dataArray.count; } -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { } -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return 110; } -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } - (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 50; } -(UITableView *)forecastView { if (!_forecastView) { _forecastView=[[UITableView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, self.view.height-KDNavBarHeight-120)]; _forecastView.backgroundColor=[UIColor clearColor]; _forecastView.separatorStyle=UITableViewCellSeparatorStyleNone; _forecastView.delegate=self; _forecastView.dataSource=self; _forecastView.showsVerticalScrollIndicator=NO; _forecastView.mj_header=[MJRefreshNormalHeader headerWithRefreshingBlock:^{ page_num = 1; [self ordeListData]; }]; _forecastView.emptyDataSetDelegate = self; _forecastView.emptyDataSetSource = self; _forecastView.mj_footer=[MJRefreshBackNormalFooter footerWithRefreshingBlock:^{ page_num++; [self ordeListData]; }]; } return _forecastView; } /* #pragma mark - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller. } */ @end