123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 |
- //
- // KDPForecastVC.m
- // KuDianProject
- //
- // Created by 学丽 on 2019/7/8.
- // Copyright © 2019 KDP. All rights reserved.
- //
- #import "KDPForecastVC.h"
- #import "KDPForecastListCell.h"
- @interface KDPForecastVC ()<UITableViewDelegate,UITableViewDataSource,DZNEmptyDataSetDelegate,DZNEmptyDataSetSource>
- {
- UILabel *_orderNumMoneyLabel;
-
- }
- @property(nonatomic,strong)NSMutableArray *dataArray;
- @property(nonatomic,strong)UITableView *forecastView;
- @end
- @implementation KDPForecastVC
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self setNavUI];
- [self getForecastEarn];
-
- }
- -(void)getForecastEarn
- {
- [LoadingView show];
- [KDPNetworkRequestHTTP postURL:foreastURL params:@{@"type":@"1"} success:^(id _Nonnull json) {
- _orderNumMoneyLabel.text=[NSString stringWithFormat:@"预估订单:%@ 收益:%@元",json[@"total_count"],json[@"total_rebate"]];
- [self.dataArray removeAllObjects];
- [self.dataArray addObjectsFromArray:[NSArray yy_modelArrayWithClass:[KDPBalanceModel class] json:json[@"all_month"]]];
- [self.forecastView reloadData];
- [LoadingView dismiss];
- } failure:^(NSError * _Nonnull error) {
- [LoadingView dismiss];
- }];
- }
- -(void)setNavUI
- {
- self.view.backgroundColor=[UIColor whiteColor];
- [self.navBar addleftReturnButton:self selector:@selector(returnClickBtn)];
- self.navBar.navTitleLabel.text=@"预估收益";
-
- [self.view addSubview:self.forecastView];
-
- }
- -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- KDPForecastListCell *listC=[tableView dequeueReusableCellWithIdentifier:@"fore"];
- if (!listC) {
- listC=[[KDPForecastListCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"fore"];
- listC.selectionStyle=UITableViewCellSelectionStyleNone;
- }
- listC.model=self.dataArray[indexPath.row]; listC.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
- return listC;
- }
- -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- return self.dataArray.count;
- }
- -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- KDPForecastOrderListVC *orderV=[[KDPForecastOrderListVC alloc]init];
- KDPBalanceModel *model=self.dataArray[indexPath.row];
- orderV.yearMonthDay=model.yearAndMonth;
- orderV.isDay =@"0";
- [self.navigationController pushViewController:orderV animated:YES];
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- return 50;
- }
- -(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 30;
- }
- -(void)returnClickBtn
- {
- [self.navigationController popViewControllerAnimated:YES];
-
- }
- -(void)viewWillAppear:(BOOL)animated
- {
- [super viewWillAppear:animated];
- self.navigationController.navigationBar.hidden=YES;
- self.tabBarController.tabBar.hidden=YES;
- }
- -(void)viewWillDisappear:(BOOL)animated
- {
- [super viewWillDisappear:animated];
- self.tabBarController.tabBar.hidden=NO;
- }
- -(UITableView *)forecastView
- {
- if (!_forecastView) {
- _forecastView=[[UITableView alloc]initWithFrame:CGRectMake(0, KDNavBarHeight, SCREEN_WIDTH, self.view.height)];
- _forecastView.backgroundColor=[UIColor clearColor];
- _forecastView.emptyDataSetDelegate = self;
- _forecastView.emptyDataSetSource = self; _forecastView.separatorStyle=UITableViewCellSeparatorStyleNone;
- if (@available(iOS 11.0, *)) {
- _forecastView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
- } else {
- self.automaticallyAdjustsScrollViewInsets = NO;
- }
- _forecastView.delegate=self;
- _forecastView.dataSource=self;
- [self addtabheader];
- }
- return _forecastView;
- }
- -(void)addtabheader
- {
- UIView *backV=[[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 47)];
- backV.backgroundColor=[UIColor clearColor];
- self.forecastView.tableHeaderView=backV;
-
- _orderNumMoneyLabel=[[UILabel alloc]initWithFrame:CGRectMake(15, 0, SCREEN_WIDTH-30, 46)];
- _orderNumMoneyLabel.text=@"预估订单:-- 收益:---元";
- _orderNumMoneyLabel.font=[UIFont systemFontOfSize:14];
- _orderNumMoneyLabel.textColor=[UIColor blackColor];
- [backV addSubview:_orderNumMoneyLabel];
-
- UIView *lineV=[[UIView alloc]initWithFrame:CGRectMake(10, 46, SCREEN_WIDTH-20, 1)];
- lineV.backgroundColor=[UIColor colorWithHexString:LineColor];
- [backV addSubview:lineV];
- }
- -(NSMutableArray *)dataArray
- {
- if (!_dataArray) {
- _dataArray=[NSMutableArray array];
- }
- return _dataArray;
- }
- @end
|