// // KDPUserInfoVC.m // KuDianProject // // Created by 学丽 on 2019/7/8. // Copyright © 2019 KDP. All rights reserved. // #import "KDPUserInfoVC.h" #import "KDPUserInfoListCell.h" @interface KDPUserInfoVC () { NSArray *infoArray; NSDictionary *userInfoDic; } @property(nonatomic,strong)UITableView *infoView; @end @implementation KDPUserInfoVC - (void)viewDidLoad { [super viewDidLoad]; [self addNavUI]; [self getUserINfo]; } -(void)getUserINfo { [LoadingView show]; [KDPNetworkRequestHTTP postURL:UserInfoURL params:nil success:^(id _Nonnull json) { userInfoDic =json[@"data"]; [self.infoView reloadData]; [LoadingView dismiss]; } failure:^(NSError * _Nonnull error) { [LoadingView dismiss]; }]; } -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { KDPUserInfoListCell *listC=[tableView dequeueReusableCellWithIdentifier:@"info"]; if (!listC) { listC=[[KDPUserInfoListCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"info"]; listC.selectionStyle=UITableViewCellSelectionStyleNone; } listC.nickLabel.text=infoArray[indexPath.row]; if (indexPath.row == 0) { listC.iconImgV.hidden=NO; listC.contentLabel.hidden=YES; [listC.iconImgV sd_setImageWithURL:[NSURL URLWithString:userInfoDic[@"kwai_headurl"]]placeholderImage:[UIImage imageNamed:placholderImg]]; }else{ listC.contentLabel.hidden=NO; listC.iconImgV.hidden=YES; if (indexPath.row == 1) { NSString *userName = [userInfoDic[@"kwai_username"] isEqual:[NSNull null]] ? @"" : userInfoDic[@"kwai_username"]; listC.contentLabel.text=userName; }else if (indexPath.row == 2) { listC.contentLabel.text=userInfoDic[@"kwai_num"]; }else if (indexPath.row == 3) { NSInteger sex=[[NSString stringWithFormat:@"%@",userInfoDic[@"kwai_sex"]] integerValue]; if (sex == 1) { listC.contentLabel.text=@"女"; }else{ listC.contentLabel.text=@"男"; } }else if (indexPath.row == 4) { NSString *cityName = [userInfoDic[@"kwai_city_name"] isEqual:[NSNull null]] ? @"":userInfoDic[@"kwai_city_name"]; listC.contentLabel.text=cityName; }else if (indexPath.row == 5) { listC.contentLabel.text=userInfoDic[@"favorite_cate"]; } } return listC; } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return infoArray.count; } -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { } -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { if (indexPath.row == 0) { return 57; } return 43; } -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } -(UITableView *)infoView { if (!_infoView) { _infoView=[[UITableView alloc]init]; _infoView.backgroundColor=[UIColor clearColor]; _infoView.separatorStyle=UITableViewCellSeparatorStyleNone; if (@available(iOS 11.0, *)) { _infoView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; } else { self.automaticallyAdjustsScrollViewInsets = NO; } _infoView.delegate=self; _infoView.dataSource=self; } return _infoView; } -(void)addNavUI { [self.navBar addleftReturnButton:self selector:@selector(returnClickBtn)]; self.navBar.navTitleLabel.text=@"个人信息"; infoArray =@[@"我的头像",@"我的昵称",@"快手号",@"性别",@"所在地",@"标签"]; self.view.backgroundColor=[UIColor colorWithHexString:LineColor]; [self.view addSubview:self.infoView]; [self.infoView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.right.bottom.mas_equalTo(0); make.top.mas_equalTo(KDNavBarHeight); }]; } -(void)returnClickBtn { [self.navigationController popViewControllerAnimated:YES]; } -(void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; self.navigationController.navigationBar.hidden=YES; self.tabBarController.tabBar.hidden=YES; } -(void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; self.tabBarController.tabBar.hidden=NO; } @end