123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212 |
- //
- // ZBWithDrawalViewController.m
- // ZBProject
- //
- // Created by 学丽 on 2019/3/28.
- // Copyright © 2019 ZB. All rights reserved.
- //
- #import "ZBWithDrawalViewController.h"
- #import "ZBWithDrawalListCell.h"
- @interface ZBWithDrawalViewController ()<UITableViewDelegate,UITableViewDataSource>
- {
- UILabel *totalL;
- UILabel *messagelabel;
- }
- @property(nonatomic,strong)UITableView *tableViews;
- @property(nonatomic,assign)NSInteger page;
- @property(nonatomic,strong)NSMutableArray *listArray;
- @end
- @implementation ZBWithDrawalViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self initNav];
- [self getBlance];
- [self getWithDrawList];
- }
- -(void)getBlance
- {
- if (![AccountTool isLogin]) {
- return;
- }
- [ZBHTTP post:getaccountPriceURL params:nil success:^(id _Nonnull json) {
- messagelabel.text=json[@"data"][@"alert"];
- NSString *title = [NSString stringWithFormat:@"¥%@",json[@"data"][@"notEnd"]];
- NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:title];
-
- [str addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:18] range:NSMakeRange(0,1)]; //设置字体字号和字体类别
- totalL.attributedText = str;
- } failure:^(NSError * _Nonnull error) {
- // [MBProgressHUD showMessage:@"网络错误"];
- }];
- }
- - (void)setUpNoDataView {
- self.tableViews.showNoDataView = YES;
- self.tableViews.noDataImageOffsetY = -70;
- self.tableViews.defaultNoDataText = @"还没有余额";
- self.tableViews.defaultNoDataImage = [UIImage imageNamed:@"no_order"];
- }
- #pragma mark---获取余额列表
- -(void)getWithDrawList
- {
- if (![AccountTool isLogin]) {
- return;
- }
- NSDictionary *dic =@{@"page":@(self.page)};
- [LoadingView showInView:self.view];
- [ZBHTTP post:getBalancelistURL params:dic success:^(id _Nonnull json) {
- [LoadingView dismiss];
- NSArray *array =[NSArray yy_modelArrayWithClass:[ZBWithDrawalModel class] json:json[@"balanceList"]];
- [self.tableViews.mj_header endRefreshing];
- [self.tableViews.mj_footer endRefreshing];
- if (array.count >0) {
- if (self.page == 1) {
- [self.listArray removeAllObjects];
- }
- [self.listArray addObjectsFromArray:array];
- }else{
- [self.tableViews.mj_footer endRefreshingWithNoMoreData];
- }
- if (self.listArray.count == 0) {
- [self setUpNoDataView];
- }
-
- [self.tableViews reloadData];
- NSLog(@"%@",json);
- } failure:^(NSError * _Nonnull error) {
- [LoadingView dismiss];
- }];
- }
- -(void)initNav
- {
- self.backView.hidden=YES;
- self.navBar.navTitleLabel.text=@"我的账户";
- self.page = 1;
-
- UIView *backV =[[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 203-NavBarHeight)];
- backV.backgroundColor=[UIColor YHColorWithHex:0xF4F4F4];
- UIView *headV =[[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 168-NavBarHeight)];
- headV.backgroundColor=[UIColor gradientWidthFromColor:[UIColor YHColorWithHex:0xFF9600] toColor:[UIColor YHColorWithHex:0xFF7200] withWidth:SCREEN_WIDTH];
-
- messagelabel =[[UILabel alloc]initWithFrame:CGRectMake(15, headV.bottom, SCREEN_WIDTH, 35)];
- messagelabel.text=@"每月25号结算上个月订单,收益会自动转入";
- messagelabel.textColor=[UIColor YHColorWithHex:0x333333];
- messagelabel.font=[UIFont systemFontOfSize:FITSIZE(12)];
- [backV addSubview:headV];
- [backV addSubview:messagelabel];
-
- self.tableViews.tableHeaderView=backV;
-
- totalL =[[UILabel alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, headV.height)];
- totalL.textAlignment=NSTextAlignmentCenter;
- totalL.textColor=[UIColor whiteColor];
- totalL.font=[UIFont boldSystemFontOfSize:48];
-
- NSString *title = @"¥---.--";
- NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:title];
- [str addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:18] range:NSMakeRange(0,1)]; //设置字体字号和字体类别
- totalL.attributedText = str;
- [headV addSubview:totalL];
-
-
- UIButton *returnBtn =[[UIButton alloc]initWithFrame:CGRectMake(0, 0, 30, 20)];
- [returnBtn addTarget:self action:@selector(returnClickBtn) forControlEvents:UIControlEventTouchUpInside];
- [returnBtn setImage:[UIImage imageNamed:@"return_white"] forState:UIControlStateNormal];
- returnBtn.adjustsImageWhenHighlighted = NO;
- [self.navBar setCustomLeftButtons:@[returnBtn]];
-
- //添加tableview
- [self.view addSubview:self.tableViews];
- [self.tableViews mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(NavBarHeight);
- make.height.mas_equalTo(SCREEN_HEIGHT);
- make.left.right.mas_equalTo(0);
- }];
- self.tableViews.mj_header =[MJRefreshNormalHeader headerWithRefreshingBlock:^{
- self.page = 1;
- [self getWithDrawList];
- }];
- self.tableViews.mj_footer =[MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
- self.page++;
- [self getWithDrawList];
- }];
-
- }
- -(void)returnClickBtn
- {
- [self.navigationController popViewControllerAnimated:YES];
- }
- #pragma mark---TableViewDelegate&&DataSource
- -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- ZBWithDrawalListCell *listC =[tableView dequeueReusableCellWithIdentifier:@"draw"];
- if (!listC) {
- listC=[[ZBWithDrawalListCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"draw"];
- listC.selectionStyle=UITableViewCellSelectionStyleNone;
- }
- listC.model=self.listArray[indexPath.row];
- return listC;
- }
- -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- return self.listArray.count;
- }
- -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
- {
- return 1;
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- return FITSIZE(80);
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
- {
- return 10;
- }
- -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
- {
- UIView *back =[[UIView alloc]init];
- back.backgroundColor=[UIColor YHColorWithHex:0xF4F4F4];
- return back;
- }
- -(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
- {
- UIView *back =[[UIView alloc]init];
- back.backgroundColor=[UIColor YHColorWithHex:0xF4F4F4];
- return back;
- }
- -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
-
- }
- -(UITableView *)tableViews
- {
- if (!_tableViews) {
- _tableViews =[[UITableView alloc]initWithFrame:CGRectMake(0, 0, 0, 0) style:UITableViewStylePlain];
- _tableViews.delegate=self;
- _tableViews.dataSource=self;
- _tableViews.backgroundColor=[UIColor YHColorWithHex:0xF4F4F4];
- _tableViews.separatorStyle=UITableViewCellSeparatorStyleSingleLine;
- _tableViews.sectionHeaderHeight=10;
- _tableViews.showsHorizontalScrollIndicator=NO;
- _tableViews.showsVerticalScrollIndicator=NO;
-
- }
- return _tableViews;
- }
- -(NSMutableArray *)listArray
- {
- if (!_listArray) {
- _listArray=[NSMutableArray array];
-
- }
- return _listArray;
- }
- @end
|