// // YOUPAIFSVideoChoseVC.m // FoxSister // // Created by leo on 2019/11/19. // Copyright © 2019 fox. All rights reserved. // #import "YOUPAIFSVideoChoseVC.h" #import "YOUPAILCUserShowModel.h" @interface YOUPAIFSVideoChoseVC () @property(nonatomic,strong)YOUPAILCUserShowModel *showModel; @property(nonatomic,strong)UITableView *tableView; @property(nonatomic,strong)UIView *tableHeaderView,*tableFootView; @property(nonatomic,assign)NSInteger account_value; @property(nonatomic,strong)NSDictionary *dataDic; @end @implementation YOUPAIFSVideoChoseVC - (void)viewDidLoad { [super viewDidLoad]; // [self.view setFrame:CGRectMake(0, 0, _screenWidth, _screenHeight)]; // [self.view setBackgroundColor:[UIColor whiteColor]]; // // CAShapeLayer *maskLayer = [CAShapeLayer layer]; // UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:self.view.bounds cornerRadius:25]; // maskLayer.path = path.CGPath; // self.view.layer.mask = maskLayer; _tableView = [[UITableView alloc]initWithFrame:CGRectMake(40, 0, self.vWidth-80,self.vHeight) style:UITableViewStylePlain]; _tableView.separatorStyle = UITableViewCellSeparatorStyleNone; _tableView.backgroundColor = [UIColor whiteColor]; _tableView.tableFooterView =[[UIView alloc] initWithFrame:CGRectZero]; _tableView.rowHeight = 67; _tableView.estimatedRowHeight =0; _tableView.delegate = self; _tableView.dataSource = self; if (@available(iOS 15.0, *)) { _tableView.sectionHeaderTopPadding = 0; } [self.baseView addSubview:_tableView]; [self youpaifinitData]; UITapGestureRecognizer *tapGes = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(headerClick)]; tapGes.delegate = self; [self.baseView addGestureRecognizer:tapGes]; // Do any additional setup after loading the view. } -(void)refreshVC { _tableView.tableHeaderView = [self tableHeaderView]; _tableView.tableFooterView = [self tableFootView]; [_tableView reloadData]; } -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { } -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return 0; } -(UIView *)tableHeaderView { if(!_tableHeaderView) { _tableHeaderView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.vWidth-80, 135)]; } CGFloat tableWith = self.vWidth-80; [_tableHeaderView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)]; UIImageView *headerIcon = [[UIImageView alloc]initWithFrame:CGRectMake(tableWith/2-24, 15, 48, 48)]; [headerIcon sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@/%@",[LCSaveData getImageUrl]?[LCSaveData getImageUrl]:BaseImgUrl,self.dataDic[@"avatar"]]]]; headerIcon.layer.cornerRadius =24; headerIcon.layer.masksToBounds = YES; [_tableHeaderView addSubview:headerIcon]; UILabel *titleLab =[[UILabel alloc]initWithFrame:CGRectMake(0, 56+15, tableWith, 14)]; [titleLab setTextAlignment:NSTextAlignmentCenter]; [titleLab setTextColor:[UIColor blackColor]]; [titleLab setFont:[UIFont systemFontOfSize:14]]; [titleLab setText:self.dataDic[@"nickname"]]; [_tableHeaderView addSubview:titleLab]; UILabel *detialLab =[[UILabel alloc]initWithFrame:CGRectMake(0, 56+15+12+14, tableWith, 12)]; [detialLab setTextAlignment:NSTextAlignmentCenter]; [detialLab setTextColor:[UIColor blackColor]]; [detialLab setFont:[UIFont systemFontOfSize:12]]; [detialLab setText:[NSString stringWithFormat:@"%@ %ld岁 富豪值:%ld",self.dataDic[@"city"],[self.dataDic[@"age"]integerValue],[self.dataDic[@"wealth_value"]integerValue]]]; [_tableHeaderView addSubview:detialLab]; return _tableHeaderView; } - (void)youpaifinitData{ WeakSelf; [LCHttpHelper requestWithURLString:UserLite parameters:@{@"user_id":self.userId} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) { NSDictionary* dict = (NSDictionary*)responseObject; NSInteger code = [[dict objectForKey:@"code"] integerValue]; if (code==0) {//成功 weakSelf.dataDic = dict[@"data"]; weakSelf.account_value = [dict[@"data"][@"account_value"] integerValue]; [weakSelf refreshVC]; } } failure:^(NSError *error) { }]; } -(UIView *)tableFootView { if(!_tableFootView) { _tableFootView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.vWidth-80, 80)]; } CGFloat footWidth = (self.vWidth-80)/2; // CGFloat tableWith = self.vWidth-80; [_tableFootView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)]; NSArray *detailtitleArray = @[@"消费",@"财富"]; NSArray *titleArray = @[@(self.account_value),@([self.dataDic[@"wealth_value"]integerValue])]; for(int i=0;i<2;i++) { UILabel *titleLab =[[UILabel alloc]initWithFrame:CGRectMake(0+(footWidth)*i, 20, footWidth, 20)]; [titleLab setTextAlignment:NSTextAlignmentCenter]; [titleLab setTextColor:[UIColor blackColor]]; [titleLab setFont:[UIFont systemFontOfSize:16]]; [titleLab setText:[NSString stringWithFormat:@"%@钻石",titleArray[i]]]; [_tableFootView addSubview:titleLab]; UILabel *detialLab =[[UILabel alloc]initWithFrame:CGRectMake(0+(footWidth)*i, 50, footWidth, 14)]; [detialLab setTextAlignment:NSTextAlignmentCenter]; [detialLab setTextColor:[UIColor lightGrayColor]]; [detialLab setFont:[UIFont systemFontOfSize:14]]; [detialLab setText:[NSString stringWithFormat:@"%@", detailtitleArray[i]]]; [_tableFootView addSubview:detialLab]; } return _tableFootView; } -(void)btnClick:(UIButton *)btn { NSIndexPath *indexPath=[self.tableView indexPathForCell:(UITableViewCell*)[[btn superview]superview]]; if([_delegate respondsToSelector:@selector(youpaifvideoChose:userId:)]) { [self dismissViewControllerAnimated:YES completion:^{ [_delegate youpaifvideoChose:indexPath.row userId:self.userId]; }]; } } -(void)headerClick { if(self.avblock) { [self dismissViewControllerAnimated:YES completion:^{ self.avblock(); }]; } } /* #pragma mark - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller. } */ @end