123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283 |
- //
- // YOUPAILZProfitListVC.m
- // VQU
- //
- // Created by CY on 2021/7/30.
- // Copyright © 2021 leo. All rights reserved.
- //
- #import "YOUPAIHRBillSubDetailVC.h"
- #import "YOUPAILZBillDetailCell.h"
- #import "PGDatePickManager.h"
- #import "UIViewController+TFPresent.h"
- #import "YOUPAILZBillSectionModel.h"
- @interface YOUPAIHRBillSubDetailVC ()<UITableViewDelegate,UITableViewDataSource,PGDatePickerDelegate>
- @property(nonatomic,assign)NSInteger youpaipcurrentPage;
- @property(nonatomic,assign)NSInteger youpaiptotalPage;
- @property(nonatomic,strong)NSMutableArray* youpaipbillArray;
- @property (nonatomic,strong)UITableView *youpaiptableView;
- @property(nonatomic,strong)NSString *youpaipdate;
- @end
- @implementation YOUPAIHRBillSubDetailVC
- -(void)dealloc{
- [[NSNotificationCenter defaultCenter]removeObserver:self];
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.youpaipdate = @"";
- self.youpaipbillArray = [NSMutableArray array];
- self.view.backgroundColor = [UIColor whiteColor];
- [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(youpaifchangSelectDate:) name:@"changSelectDate" object:nil];
- [self youpaifinitUI];
- [self.youpaiptableView.mj_header beginRefreshing];
- }
- -(void)youpaifchangSelectDate:(NSNotification*)notic{
- NSDictionary *dict = notic.userInfo;
- NSString *date =dict[@"date"];
- self.youpaipdate = date;
- [self.youpaiptableView.mj_header beginRefreshing];
-
- }
- - (void)youpaifinitUI{
-
-
- self.youpaiptableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
- [self.view addSubview:self.youpaiptableView];
- [self.youpaiptableView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(0);
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(0);
- make.bottom.mas_equalTo(0);
- }];
- self.youpaiptableView.backgroundColor = [UIColor clearColor];
- self.youpaiptableView.showsVerticalScrollIndicator = NO;
- self.youpaiptableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- self.youpaiptableView.estimatedRowHeight = 78.0f;
- self.youpaiptableView.rowHeight = 78.0f;
-
- self.youpaiptableView.delegate = self;
- self.youpaiptableView.dataSource= self;
- if (@available(iOS 15.0, *)) {
- self.youpaiptableView.sectionHeaderTopPadding = 0;
- }
-
-
-
- self.youpaiptableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(youpaifloadNewData)];
- MJRefreshAutoNormalFooter* normalFooter = [MJRefreshAutoNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(youpaifloadMoreData)];
- [normalFooter setTitle:@"正在加载..." forState:(MJRefreshStateRefreshing)];
- [normalFooter setTitle:@"" forState:(MJRefreshStateNoMoreData)];
- self.youpaiptableView.mj_footer = normalFooter;
- self.youpaiptableView.mj_footer.automaticallyHidden = YES;
- }
- #pragma mark - tableView代理
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
- return self.youpaipbillArray.count;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
- YOUPAILZBillSectionModel *model = self.youpaipbillArray[section];
- return model.youpaiplist.count;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
- YOUPAILZBillSectionModel *sectionModel = self.youpaipbillArray[indexPath.section];
- YOUPAILZBillDetailCell* cell = [tableView dequeueReusableCellWithIdentifier:@"YOUPAILZBillDetailCell"];
- if (cell == nil) {
- cell = [[YOUPAILZBillDetailCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"YOUPAILZBillDetailCell"];
- }
- YOUPAILCBillDetailModel* model = [YOUPAILCBillDetailModel mj_objectWithKeyValues:sectionModel.youpaiplist[indexPath.row]];
- model.newtype = self.newtype;
- cell.youpaipbillModel = model;
- return cell;
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
-
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
- return 52.0f;
- }
- - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
- YOUPAILZBillSectionModel *sectionModel = self.youpaipbillArray[section];
- UIView *bgV = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 52.0f)];
- bgV.backgroundColor = [UIColor whiteColor];
-
- NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
- [formatter setDateFormat:@"yyyy-MM"];//yyyy年MM月dd日
- NSString *dateString = sectionModel.youpaipdate;
- NSDate *date = [formatter dateFromString:dateString];
- [formatter setDateFormat:@"yyyy年MM月"];
-
- UILabel *dayL = [[UILabel alloc] init];
- dayL.text = [formatter stringFromDate:date];//@"2020年12月";
- dayL.font = LCFont12;
- dayL.textColor = LZA3AABEColor;
- [bgV addSubview:dayL];
- [dayL mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.offset(14.0f);
- make.centerY.mas_equalTo(0.0f);
- }];
- // UILabel *enterL = [[UILabel alloc] init];
- // enterL.font = LCFont12;
- // enterL.textColor = [UIColor whiteColor];
- // enterL.text = [NSString stringWithFormat:@"收入 %@钻石",sectionModel.income];
- // [bgV addSubview:enterL];
- // [enterL mas_makeConstraints:^(MASConstraintMaker *make) {
- // make.left.offset(14.0f);
- // make.bottom.offset(-10.0f);
- // }];
- //
- // UILabel *outL = [[UILabel alloc] init];
- // outL.font = LCFont12;
- // outL.textColor = [UIColor whiteColor];
- // outL.text = [NSString stringWithFormat:@"支出 %@钻石",sectionModel.expend];
- // [bgV addSubview:outL];
- // [outL mas_makeConstraints:^(MASConstraintMaker *make) {
- // make.left.equalTo(enterL.mas_right).offset(15.0f);
- // make.bottom.offset(-10.0f);
- // }];
-
- return bgV;
- }
- - (void)youpaiffilterAction{
- PGDatePickManager *datePickManager = [[PGDatePickManager alloc]init];
- datePickManager.isShadeBackground = true;
- datePickManager.cancelButtonFont = LCFont(15);
- datePickManager.confirmButtonFont = LCFont(15);
- datePickManager.cancelButtonTextColor = LZA3AABEColor;
- datePickManager.confirmButtonTextColor = LZ273145Color;
- datePickManager.headerViewBackgroundColor = [UIColor whiteColor];
- datePickManager.headerHeight = 50;
- PGDatePicker *datePicker = datePickManager.datePicker;
- datePicker.backgroundColor = [UIColor whiteColor];
- datePicker.rowHeight = 35;
- datePicker.middleTextColor = LZ273145Color;
- datePicker.textColorOfSelectedRow = LZ273145Color;
- datePicker.textColorOfOtherRow = LZD3D1D7Color;
- datePicker.textFontOfSelectedRow = LCFont(17);
- datePicker.textFontOfOtherRow = LCFont(17);
- datePicker.lineBackgroundColor = [UIColor clearColor];
-
-
- NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
- NSDate* currentDate = [NSDate date];
- [dateFormatter setDateFormat:@"yyyy"];
- NSString* currentYear=[dateFormatter stringFromDate:currentDate] ;
- [dateFormatter setDateFormat:@"MM"];
- NSString* currentMonth=[dateFormatter stringFromDate:currentDate];
-
- NSString* maxDateStr = [NSString stringWithFormat:@"%zd-%@",[currentYear integerValue],currentMonth];
- NSString* minDateStr = [NSString stringWithFormat:@"%zd-%@",[currentYear integerValue]-50,currentMonth];
- [dateFormatter setDateFormat:@"yyyy-MM"];
- NSString* defaultDateStr;
- NSDate *date = [dateFormatter dateFromString:defaultDateStr];//上次设置的日期
-
- [datePicker setDate:date];
- datePicker.maximumDate = [dateFormatter dateFromString:maxDateStr];
- datePicker.minimumDate = [dateFormatter dateFromString:minDateStr];
- datePicker.delegate = self;
- datePicker.datePickerType = PGDatePickerTypeLine;
- datePicker.isHiddenMiddleText = false;
- datePicker.datePickerMode = PGDatePickerModeYearAndMonth;
- [self presentViewController:datePickManager animated:false completion:nil];
- }
- - (void)datePicker:(PGDatePicker *)datePicker didSelectDate:(NSDateComponents *)dateComponents{
- NSLog(@"dateComponents = %@", dateComponents);
- NSInteger year=[dateComponents year];
- NSInteger month=[dateComponents month];
- self.youpaipdate = [NSString stringWithFormat:@"%ld-%ld",year,month];
- [self.youpaiptableView.mj_header beginRefreshing];
- }
- - (void)youpaifloadNewData{
-
- self.youpaiptableView.mj_footer.hidden = YES;
- [self.youpaiptableView.mj_footer endRefreshing];//先结束上拉,假如有的话
- self.youpaipcurrentPage = 1;
- [LCHttpHelper requestWithURLString:WalletBill parameters:@{@"page":@(self.youpaipcurrentPage),@"date":self.youpaipdate,@"category":self.youpaiptype,@"cate_id":@"",@"new_type":self.newtype} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code==0) {//成功
- [self.youpaipbillArray removeAllObjects];
- NSArray* array = [[dict objectForKey:@"data"]objectForKey:@"new_list"];
- NSMutableArray* modelArray = [YOUPAILZBillSectionModel mj_objectArrayWithKeyValuesArray:array];
- [self.youpaipbillArray addObjectsFromArray:modelArray];
- self.youpaiptotalPage = [[[dict objectForKey:@"data"]objectForKey:@"total_page"]integerValue];
- self.youpaipcurrentPage = [[[dict objectForKey:@"data"]objectForKey:@"page"]integerValue];
- [self.youpaiptableView reloadData];
- if (self.youpaipcurrentPage>=self.youpaiptotalPage) {
- [self.youpaiptableView.mj_footer endRefreshingWithNoMoreData];
- self.youpaiptableView.mj_footer.hidden = YES;
- }
- [self.youpaiptableView lz_hideEmptyView];
- if (self.youpaipbillArray.count == 0) {
- [self.youpaiptableView lz_showEmptyViewWithImage:[UIImage imageNamed:@"vqu_images_not_home_data"] content:@"暂无记录"];
- }
- [self.youpaiptableView.mj_header endRefreshing];
- }else{
- [self.youpaiptableView.mj_header endRefreshing];
- }
- } failure:^(NSError *error) {
- [self.youpaiptableView.mj_header endRefreshing];
- }];
- }
- - (void)youpaifloadMoreData{
- [self.youpaiptableView.mj_header endRefreshing];
- self.youpaiptableView.mj_footer.hidden = YES;
- [self.youpaiptableView.mj_footer endRefreshing];
- self.youpaipcurrentPage+=1;
- [LCHttpHelper requestWithURLString:WalletBill parameters:@{@"page":@(self.youpaipcurrentPage),@"date":self.youpaipdate,@"category":self.youpaiptype,@"cate_id":@"",@"new_type":self.newtype} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code==0) {//成功
- NSArray* array = [[dict objectForKey:@"data"]objectForKey:@"new_list"];
- NSMutableArray* modelArray = [YOUPAILZBillSectionModel mj_objectArrayWithKeyValuesArray:array];
-
- if (modelArray.count != 0) {
- YOUPAILZBillSectionModel *firstModel = modelArray.firstObject;
- YOUPAILZBillSectionModel *lastModel = self.youpaipbillArray.lastObject;
- if ([firstModel.youpaipdate isEqual:lastModel.youpaipdate]) {
- [lastModel.youpaiplist addObjectsFromArray:firstModel.youpaiplist];
- }else{
- [self.youpaipbillArray addObject:firstModel];
- }
- for (NSInteger i = 1; i < modelArray.count; i ++) {
- [self.youpaipbillArray addObject:modelArray[i]];
- }
- }
-
-
- // [self.billArray addObjectsFromArray:modelArray];
- self.youpaiptotalPage = [[[dict objectForKey:@"data"]objectForKey:@"total_page"]integerValue];
- self.youpaipcurrentPage = [[[dict objectForKey:@"data"]objectForKey:@"page"]integerValue];
- [self.youpaiptableView reloadData];
- if (self.youpaipcurrentPage>=self.youpaiptotalPage) {
- [self.youpaiptableView.mj_footer endRefreshingWithNoMoreData];
- self.youpaiptableView.mj_footer.hidden = YES;
- }
- [self.youpaiptableView.mj_header endRefreshing];
- }else{
- [self.youpaiptableView.mj_header endRefreshing];
- }
- } failure:^(NSError *error) {
- [self.youpaiptableView.mj_header endRefreshing];
- }];
- }
- #pragma mark - JXCategoryListContainerView
- - (UIView *)listView{
- return self.view;
- }
- @end
|