123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227 |
- //
- // ZBIncomeViewController.m
- // ZBProject
- //
- // Created by 学丽 on 2019/3/28.
- // Copyright © 2019 ZB. All rights reserved.
- //
- #import "ZBIncomeViewController.h"
- #import "ZBIncomeListCell.h"
- #import "ZBIncomeDetailModel.h"
- @interface ZBIncomeViewController ()<UITableViewDelegate,UITableViewDataSource>
- {
- UILabel *totalL;
- }
- @property(nonatomic,strong)UITableView *tableViews;
- @property(nonatomic,assign)NSInteger page;
- @property(nonatomic,strong)NSMutableArray *listArray;
- @property (nonatomic, strong) LDCalendarView *calendarView ;
- @property (nonatomic, strong) CCAlertShowView *alertShowView;
- @end
- @implementation ZBIncomeViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self initNav];
- [self getIncomeList];
- if (self.isShow.integerValue==1) {
- [self showCalendar];
- }
- }
- - (void)showCalendar {
- if (self.alertShowView) {
- [self.alertShowView show];
- return;
- }
- CCAlertShowView *showView = [CCAlertShowView showAlertViewWithView:self.calendarView backgroundDismissEnable:YES];
- self.alertShowView = showView;
- [self.alertShowView show];
- }
- -(void)getIncomeList
- {
- if (![AccountTool isLogin]) {
- return;
- }
- [LoadingView show];
- NSDictionary *dic =@{@"yearMonthDay":_yearMonthDay,@"isDay":@(self.isDay),@"type":self.type,@"page":@(self.page)};
- [ZBHTTP post:getIncomeListURL params:dic success:^(id _Nonnull json) {
- NSLog(@"%@",json);
- [LoadingView dismiss];
-
- NSString *title=[NSString stringWithFormat:@"%@ 订单:%@笔 佣金:%@元",self.yearMonthDay,json[@"num"],json[@"allRebate"]];
- NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:title];
-
- [str addAttribute:NSForegroundColorAttributeName value:[UIColor baseColor] range:NSMakeRange(0,self.yearMonthDay.length)];
- [str addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:16] range:NSMakeRange(0,self.yearMonthDay.length)]; //设置字体字号和字体类别
-
- totalL.attributedText = str;
- [self.tableViews.mj_header endRefreshing];
- [self.tableViews.mj_footer endRefreshing];
-
- NSArray *array =[NSArray yy_modelArrayWithClass:[ZBIncomeDetailModel class] json:json[@"data"]];
- 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];
- } failure:^(NSError * _Nonnull error) {
- [LoadingView dismiss];
- // [MBProgressHUD showMessage:@"网络错误"];
- }];
- }
- -(void)initNav
- {
- self.backView.hidden=YES;
- self.page = 1;
- self.navBar.navTitleLabel.text=[NSString stringWithFormat:@"%@收入",self.yearMonthDay];
-
- 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]];
- UIView *headV =[[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 41)];
- headV.backgroundColor=[UIColor whiteColor];
- self.tableViews.tableHeaderView=headV;
-
- totalL =[[UILabel alloc]initWithFrame:CGRectMake(10, 0, SCREEN_WIDTH-20, 41)];
- totalL.textColor=[UIColor YHColorWithHex:0x4A4A4A];
- totalL.font=[UIFont systemFontOfSize:14];
- NSString *title=@"0000-00 订单:-笔 佣金:--.--元";
- NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:title];
- [str addAttribute:NSForegroundColorAttributeName value:[UIColor baseColor] range:NSMakeRange(0,7)];
- [str addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:16] range:NSMakeRange(0,7)]; //设置字体字号和字体类别
-
- totalL.attributedText = str;
- [headV addSubview:totalL];
-
- //添加tableview
- [self.view addSubview:self.tableViews];
- [self.tableViews mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(NavBarHeight);
- make.height.mas_equalTo(SCREEN_HEIGHT-NavBarHeight);
- make.left.right.mas_equalTo(0);
- }];
- // self.tableViews.mj_header=[MJRefreshNormalHeader headerWithRefreshingBlock:^{
- // self.page = 1;
- // [self getIncomeList];
- // }];
-
- _tableViews.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
- self.page++;
- [self getIncomeList];
- }];
-
- }
- -(void)returnClickBtn
- {
- [self.navigationController popViewControllerAnimated:YES];
- }
- #pragma mark---TableViewDelegate&&DataSource
- -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- ZBIncomeListCell *listC =[tableView dequeueReusableCellWithIdentifier:@"list"];
- if (!listC) {
- listC=[[ZBIncomeListCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"list"];
- 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 110;
- }
- -(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;
- }
- -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
-
- }
- -(UITableView *)tableViews
- {
- if (!_tableViews) {
- _tableViews =[[UITableView alloc]init];
- _tableViews.delegate=self;
- _tableViews.dataSource=self;
- _tableViews.backgroundColor=[UIColor YHColorWithHex:0xF4F4F4];
- _tableViews.separatorStyle=UITableViewCellSeparatorStyleSingleLine;
- _tableViews.sectionHeaderHeight=10;
- _tableViews.showsHorizontalScrollIndicator=NO;
- _tableViews.showsVerticalScrollIndicator=NO;
- UIView *view =[ [UIView alloc]init];
- view.backgroundColor = [UIColor clearColor];
- [_tableViews setTableFooterView:view];
- }
- return _tableViews;
- }
- -(NSMutableArray *)listArray
- {
- if (!_listArray) {
- _listArray=[NSMutableArray array];
-
- }
- return _listArray;
- }
- - (void)setUpNoDataView {
- self.tableViews.showNoDataView = YES;
- self.tableViews.noDataImageOffsetY = -70;
- self.tableViews.defaultNoDataText = @"还没有收入";
- self.tableViews.defaultNoDataImage = [UIImage imageNamed:@"no_order"];
- }
- - (LDCalendarView *)calendarView {
- if (!_calendarView) {
- __weak typeof(self) weakSelf = self;
- _calendarView = [[LDCalendarView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH-40, 0)];
- _calendarView.cancelBlock = ^{
- [weakSelf.alertShowView dismiss];
- };
- _calendarView.makeSureBlock = ^(NSString *dateStr) {
- if (dateStr) {
- weakSelf.yearMonthDay = dateStr;
-
- [weakSelf.navBar setNavTitle:dateStr];
- weakSelf.navBar.navTitleLabel.textColor = [UIColor whiteColor];
- weakSelf.page = 1;
- [weakSelf getIncomeList];
-
- [weakSelf.alertShowView dismiss];
- }else {
- [weakSelf.alertShowView dismiss];
- }
-
- };
- }
- return _calendarView;
- }
- @end
|