// // KDPAccountVC.m // KuDianProject // // Created by 学丽 on 2019/7/8. // Copyright © 2019 KDP. All rights reserved. // #import "KDPAccountVC.h" #import "KDPAccountListCell.h" @interface KDPAccountVC () { UILabel *_accountMoneyLabel; UILabel *_tipeLabel; NSInteger page_num; } @property(nonatomic,strong)UITableView *accountView; @property(nonatomic,strong)NSMutableArray *dataArray; @end @implementation KDPAccountVC - (void)viewDidLoad { [super viewDidLoad]; [self setNavUI]; page_num = 1; [self getAccountBalance]; [self getBalanceList]; } -(void)getBalanceList { [LoadingView show]; [KDPNetworkRequestHTTP postURL:BalancelistURL params:@{@"page":@(page_num)} success:^(id _Nonnull json) { [LoadingView dismiss]; NSArray *array =[NSArray yy_modelArrayWithClass:[KDPBalanceModel class] json:json[@"balanceList"]]; if (page_num ==1) { [self.dataArray removeAllObjects]; } [self.accountView.mj_header endRefreshing]; [self.accountView.mj_footer endRefreshing]; if (array.count == 0) { [self.accountView.mj_footer endRefreshingWithNoMoreData]; } [self.dataArray addObjectsFromArray:array]; [self.accountView reloadData]; } failure:^(NSError * _Nonnull error) { [LoadingView dismiss]; }]; } -(void)getAccountBalance { [LoadingView show]; [KDPNetworkRequestHTTP postURL:balanceURL params:nil success:^(id _Nonnull json) { [LoadingView dismiss]; _tipeLabel.text=json[@"data"][@"alert"]; NSString *contents = [NSString stringWithFormat:@"¥%@",json[@"data"][@"notEnd"]]; NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:contents]; [str addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:18] range:NSMakeRange(0,1)]; //设置字体字号和字体类别 _accountMoneyLabel.attributedText = str; } 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.accountView]; } -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { KDPAccountListCell *listC=[tableView dequeueReusableCellWithIdentifier:@"account"]; if (!listC) { listC=[[KDPAccountListCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"account"]; 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 80; } -(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; } -(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 *)accountView { if (!_accountView) { _accountView=[[UITableView alloc]initWithFrame:CGRectMake(0, KDNavBarHeight, SCREEN_WIDTH, self.view.height)]; _accountView.backgroundColor=[UIColor clearColor]; _accountView.separatorStyle=UITableViewCellSeparatorStyleNone; _accountView.emptyDataSetDelegate = self; _accountView.emptyDataSetSource = self; _accountView.delegate=self; _accountView.dataSource=self; _accountView.mj_header=[MJRefreshNormalHeader headerWithRefreshingBlock:^{ page_num = 1; [self getBalanceList]; }]; _accountView.mj_footer=[MJRefreshBackNormalFooter footerWithRefreshingBlock:^{ page_num++; [self getBalanceList]; }]; [self addAccountviews]; } return _accountView; } -(void)addAccountviews { UIView *headV=[[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 134)]; UIView *backV=[[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 104)]; backV.backgroundColor=[UIColor gradientOneColor:[UIColor colorWithHexString:@"#FF235F"] toColor:[UIColor colorWithHexString:@"#FF7676"] Width:SCREEN_WIDTH]; self.accountView.tableHeaderView=headV; [headV addSubview:backV]; _accountMoneyLabel=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, backV.height)]; _accountMoneyLabel.center=backV.center; _accountMoneyLabel.font=[UIFont systemFontOfSize:48]; _accountMoneyLabel.textAlignment=NSTextAlignmentCenter; _accountMoneyLabel.textColor=[UIColor whiteColor]; NSString *title = @"¥---.--"; NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:title]; [str addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:18] range:NSMakeRange(0,1)]; //设置字体字号和字体类别 _accountMoneyLabel.attributedText = str; [backV addSubview:_accountMoneyLabel]; _tipeLabel=[[UILabel alloc]initWithFrame:CGRectMake(10, backV.bottom, SCREEN_WIDTH-20, 30)]; _tipeLabel.font=[UIFont systemFontOfSize:12]; _tipeLabel.textColor=[UIColor colorWithHexString:@"#999999"]; [headV addSubview:_tipeLabel]; } -(NSMutableArray *)dataArray { if (!_dataArray) { _dataArray=[NSMutableArray array]; } return _dataArray; } @end