// // LDSuperInfoVC.m // YouHuiProject // // Created by liuxueli on 2019/2/25. // Copyright © 2019 kuxuan. All rights reserved. // #import "LDSuperInfoVC.h" #import #import "LDUserInfoView.h" #import "LDUserInfo.h" @interface LDSuperInfoVC () { NSDictionary *detaidic; } @property (nonatomic, strong) UIImageView *headerImg; @property (nonatomic, strong) LDUserInfoView *userInfoView; @property (nonatomic, strong) UITableView *tableView; @property (nonatomic, strong)UIImageView *logoimgV; @property (nonatomic, strong)UILabel *typeLabel; @property (nonatomic, strong)UILabel *nameLabel; @property (nonatomic, strong) NSArray *dataArr; @end @implementation LDSuperInfoVC - (void)viewDidLoad { [super viewDidLoad]; [self configNavightion]; [self configTableView]; [self requestFastDetail]; } - (void)configNavightion { self.navigationBar.backgroundColor = [UIColor changeColor]; self.navigationBar.hidden = NO; } -(void)requestFastDetail { NSDictionary *dic =@{@"user_id":_fansmodel.user_id}; [LDHttp post:FansSurperDetail params:dic success:^(id json) { NSLog(@"%@",json); detaidic=json; LDUserInfo *userinfo =[[LDUserInfo alloc]init]; userinfo.name=detaidic[@"nickname"]; userinfo.img=detaidic[@"headerImg"]; userinfo.user_level=[NSString stringWithFormat:@"%@",detaidic[@"level"]]; [self.userInfoView setUserInfo:userinfo]; [self.userInfoView setUserInfo]; [self.tableView reloadData]; } failure:^(NSError *error) { }]; } - (void)backAction { [self.navigationController popViewControllerAnimated:YES]; } -(void)configTableView { //头部背景图 self.headerImg = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 76)]; self.headerImg.userInteractionEnabled = YES; self.headerImg.image = [UIImage imageNamed:@"mine_bg"]; self.tableView.tableHeaderView = self.headerImg; //用户信息 self.userInfoView = [[LDUserInfoView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 60)]; [self.headerImg addSubview:self.userInfoView]; [self.userInfoView setUserInfo]; UIButton *leftBtn = [[UIButton alloc] initWithFrame:CGRectMake(10, 15, 40, 40)]; [leftBtn setImage:[UIImage imageNamed:@"back_white"] forState:UIControlStateNormal]; [leftBtn addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside]; [self.navigationBar setCustomLeftButtons:@[leftBtn]]; [self.view addSubview:self.tableView]; } #pragma mark ------------------ - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { if ([cell respondsToSelector:@selector(setSeparatorInset:)]) { [cell setSeparatorInset:UIEdgeInsetsMake(0, 0, 0, 0)]; } } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [self.dataArr[section] count]; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return 50; } - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section { return 10; } -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return self.dataArr.count; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"cellID"]; cell.textLabel.text = self.dataArr[indexPath.section][indexPath.row]; cell.textLabel.font = [UIFont systemFontOfSize:15]; cell.textLabel.textColor = [UIColor YHColorWithHex:0x666666]; cell.selectionStyle = UITableViewCellSelectionStyleNone; if (indexPath.section != 0 ) { if (indexPath.section == 1) { if (indexPath.row == 0) { cell.detailTextLabel.text =[NSString stringWithFormat:@"%ld人",[detaidic[@"lowFriendCount"] integerValue]]; } if (indexPath.row == 1) { cell.detailTextLabel.text =[NSString stringWithFormat:@"¥%.2f",[detaidic[@"allIncomeend"] floatValue]]; } } if (indexPath.section ==2 ) { if (indexPath.row == 0) { cell.detailTextLabel.text =detaidic[@"parentNickname"]; } if (indexPath.row == 1) { cell.detailTextLabel.text =detaidic[@"registeTime"]; } } cell.detailTextLabel.font = [UIFont systemFontOfSize:15]; cell.detailTextLabel.textColor = [UIColor YHColorWithHex:0x999999]; cell.detailTextLabel.textAlignment=NSTextAlignmentRight; if (indexPath.section == 2 && indexPath.row == 0) { UIImageView *imgv =[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"fans_super"]]; CGSize size =[self sizeWithText:detaidic[@"parentNickname"] font:15 maxSize:CGSizeMake(300, 50)]; imgv.frame=CGRectMake(SCREEN_WIDTH-size.width-50, 11, 28, 28); [cell addSubview:imgv]; } }else{ UILabel *wechatnumL =[[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH-237, 0, 150, 50)]; wechatnumL.font = [UIFont systemFontOfSize:15]; wechatnumL.textColor = [UIColor YHColorWithHex:0x999999]; wechatnumL.textAlignment=NSTextAlignmentRight; [cell addSubview:wechatnumL]; UIButton *wechatBtn =[[UIButton alloc]initWithFrame:CGRectMake(SCREEN_WIDTH-77, 16.5, 57, 17)]; wechatBtn.layer.cornerRadius=8.5; wechatBtn.layer.masksToBounds=YES; wechatBtn.layer.borderColor=[UIColor YHColorWithHex:0xFA2C36].CGColor; wechatBtn.layer.borderWidth=0.5; [wechatBtn setTitleColor:[UIColor YHColorWithHex:0xFA2C36] forState:UIControlStateNormal]; wechatBtn.titleLabel.font=[UIFont systemFontOfSize:9]; [wechatBtn addTarget:self action:@selector(pastClickWechat) forControlEvents:UIControlEventTouchUpInside]; [cell addSubview:wechatBtn]; if ([detaidic[@"isHasWechat"] integerValue ]==1) { [wechatBtn setTitle:@"复制" forState:UIControlStateNormal]; wechatnumL.text =detaidic[@"wechat"]; }else{ [wechatBtn setTitle:@"发送请求" forState:UIControlStateNormal]; wechatnumL.text =@"未填写"; } } return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { } -(void)pastClickWechat { if ([detaidic[@"isHasWechat"] integerValue ]==1) { UIPasteboard *pasteboard = [UIPasteboard generalPasteboard]; pasteboard.string=detaidic[@"wechat"]; [SVProgressHUD showSuccessWithStatus:@"复制成功"]; }else { NSDictionary *dic =@{@"user_id":_fansmodel.user_id}; [LDHttp post:sendWechatFans params:dic success:^(id json) { NSLog(@"%@",json); [SVProgressHUD showSuccessWithStatus:json[@"msg"]]; } failure:^(NSError *error) { }]; } } - (UITableView *)tableView { if (!_tableView) { _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, NavBarHeight, SCREEN_WIDTH, SCREEN_HEIGHT-TabbarHeight) style:UITableViewStylePlain]; _tableView.estimatedSectionHeaderHeight = 0; _tableView.estimatedSectionFooterHeight = 0; _tableView.sectionFooterHeight = 0; _tableView.sectionHeaderHeight = 0; _tableView.delegate = self; _tableView.dataSource = self; // _tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero]; _tableView.backgroundColor = [UIColor YHColorWithHex:0xf4f4f4]; _tableView.bounces = YES; _tableView.showsVerticalScrollIndicator = NO; _tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine; _tableView.separatorColor = [UIColor YHColorWithHex:0xEEEEEE]; } return _tableView; } - (NSArray *)dataArr { if (!_dataArr) { _dataArr = @[@[@"微信号"],@[@"直属好友",@"累计收益"],@[@"邀请人",@"注册时间"] ]; } return _dataArr; } - (CGSize)sizeWithText:(NSString *)text font:(CGFloat )font maxSize:(CGSize)maxSize { NSDictionary *attrs = @{NSFontAttributeName : [UIFont systemFontOfSize:font]}; return [text boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:attrs context:nil].size; } @end