酷店

KDPUserInfoVC.m 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. //
  2. // KDPUserInfoVC.m
  3. // KuDianProject
  4. //
  5. // Created by 学丽 on 2019/7/8.
  6. // Copyright © 2019 KDP. All rights reserved.
  7. //
  8. #import "KDPUserInfoVC.h"
  9. #import "KDPUserInfoListCell.h"
  10. @interface KDPUserInfoVC ()<UITableViewDelegate,UITableViewDataSource>
  11. {
  12. NSArray *infoArray;
  13. NSDictionary *userInfoDic;
  14. }
  15. @property(nonatomic,strong)UITableView *infoView;
  16. @end
  17. @implementation KDPUserInfoVC
  18. - (void)viewDidLoad {
  19. [super viewDidLoad];
  20. [self addNavUI];
  21. [self getUserINfo];
  22. }
  23. -(void)getUserINfo
  24. {
  25. [LoadingView show];
  26. [KDPNetworkRequestHTTP postURL:UserInfoURL params:nil success:^(id _Nonnull json) {
  27. userInfoDic =json[@"data"];
  28. [self.infoView reloadData];
  29. [LoadingView dismiss];
  30. } failure:^(NSError * _Nonnull error) {
  31. [LoadingView dismiss];
  32. }];
  33. }
  34. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  35. {
  36. KDPUserInfoListCell *listC=[tableView dequeueReusableCellWithIdentifier:@"info"];
  37. if (!listC) {
  38. listC=[[KDPUserInfoListCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"info"];
  39. listC.selectionStyle=UITableViewCellSelectionStyleNone;
  40. }
  41. listC.nickLabel.text=infoArray[indexPath.row];
  42. if (indexPath.row == 0) {
  43. listC.iconImgV.hidden=NO;
  44. listC.contentLabel.hidden=YES;
  45. [listC.iconImgV sd_setImageWithURL:[NSURL URLWithString:userInfoDic[@"kwai_headurl"]]placeholderImage:[UIImage imageNamed:placholderImg]];
  46. }else{
  47. listC.contentLabel.hidden=NO;
  48. listC.iconImgV.hidden=YES;
  49. if (indexPath.row == 1) {
  50. NSString *userName = [userInfoDic[@"kwai_username"] isEqual:[NSNull null]] ? @"" : userInfoDic[@"kwai_username"];
  51. listC.contentLabel.text=userName;
  52. }else if (indexPath.row == 2) {
  53. listC.contentLabel.text=userInfoDic[@"kwai_num"];
  54. }else if (indexPath.row == 3) {
  55. NSInteger sex=[[NSString stringWithFormat:@"%@",userInfoDic[@"kwai_sex"]] integerValue];
  56. if (sex == 1) {
  57. listC.contentLabel.text=@"女";
  58. }else{
  59. listC.contentLabel.text=@"男";
  60. }
  61. }else if (indexPath.row == 4) {
  62. NSString *cityName = [userInfoDic[@"kwai_city_name"] isEqual:[NSNull null]] ? @"":userInfoDic[@"kwai_city_name"];
  63. listC.contentLabel.text=cityName;
  64. }else if (indexPath.row == 5) {
  65. listC.contentLabel.text=userInfoDic[@"favorite_cate"];
  66. }
  67. }
  68. return listC;
  69. }
  70. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  71. {
  72. return infoArray.count;
  73. }
  74. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  75. {
  76. }
  77. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  78. {
  79. if (indexPath.row == 0) {
  80. return 57;
  81. }
  82. return 43;
  83. }
  84. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  85. {
  86. return 1;
  87. }
  88. -(UITableView *)infoView
  89. {
  90. if (!_infoView) {
  91. _infoView=[[UITableView alloc]init];
  92. _infoView.backgroundColor=[UIColor clearColor];
  93. _infoView.separatorStyle=UITableViewCellSeparatorStyleNone;
  94. if (@available(iOS 11.0, *)) {
  95. _infoView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
  96. } else {
  97. self.automaticallyAdjustsScrollViewInsets = NO;
  98. }
  99. _infoView.delegate=self;
  100. _infoView.dataSource=self;
  101. }
  102. return _infoView;
  103. }
  104. -(void)addNavUI
  105. {
  106. [self.navBar addleftReturnButton:self selector:@selector(returnClickBtn)];
  107. self.navBar.navTitleLabel.text=@"个人信息";
  108. infoArray =@[@"我的头像",@"我的昵称",@"快手号",@"性别",@"所在地",@"标签"];
  109. self.view.backgroundColor=[UIColor colorWithHexString:LineColor];
  110. [self.view addSubview:self.infoView];
  111. [self.infoView mas_makeConstraints:^(MASConstraintMaker *make) {
  112. make.left.right.bottom.mas_equalTo(0);
  113. make.top.mas_equalTo(KDNavBarHeight);
  114. }];
  115. }
  116. -(void)returnClickBtn
  117. {
  118. [self.navigationController popViewControllerAnimated:YES];
  119. }
  120. -(void)viewWillAppear:(BOOL)animated
  121. {
  122. [super viewWillAppear:animated];
  123. self.navigationController.navigationBar.hidden=YES;
  124. self.tabBarController.tabBar.hidden=YES;
  125. }
  126. -(void)viewWillDisappear:(BOOL)animated
  127. {
  128. [super viewWillDisappear:animated];
  129. self.tabBarController.tabBar.hidden=NO;
  130. }
  131. @end