猎豆优选

LDSuperInfoVC.m 8.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. //
  2. // LDSuperInfoVC.m
  3. // YouHuiProject
  4. //
  5. // Created by liuxueli on 2019/2/25.
  6. // Copyright © 2019 kuxuan. All rights reserved.
  7. //
  8. #import "LDSuperInfoVC.h"
  9. #import <UIKit/UIKit.h>
  10. #import "LDUserInfoView.h"
  11. #import "LDUserInfo.h"
  12. @interface LDSuperInfoVC ()<UITableViewDelegate,UITableViewDataSource>
  13. {
  14. NSDictionary *detaidic;
  15. }
  16. @property (nonatomic, strong) UIImageView *headerImg;
  17. @property (nonatomic, strong) LDUserInfoView *userInfoView;
  18. @property (nonatomic, strong) UITableView *tableView;
  19. @property (nonatomic, strong)UIImageView *logoimgV;
  20. @property (nonatomic, strong)UILabel *typeLabel;
  21. @property (nonatomic, strong)UILabel *nameLabel;
  22. @property (nonatomic, strong) NSArray *dataArr;
  23. @end
  24. @implementation LDSuperInfoVC
  25. - (void)viewDidLoad {
  26. [super viewDidLoad];
  27. [self configNavightion];
  28. [self configTableView];
  29. [self requestFastDetail];
  30. }
  31. - (void)configNavightion {
  32. self.navigationBar.backgroundColor = [UIColor changeColor];
  33. self.navigationBar.hidden = NO;
  34. }
  35. -(void)requestFastDetail
  36. {
  37. NSDictionary *dic =@{@"user_id":_fansmodel.user_id};
  38. [LDHttp post:FansSurperDetail params:dic success:^(id json) {
  39. NSLog(@"%@",json);
  40. detaidic=json;
  41. LDUserInfo *userinfo =[[LDUserInfo alloc]init];
  42. userinfo.name=detaidic[@"nickname"];
  43. userinfo.img=detaidic[@"headerImg"];
  44. userinfo.user_level=[NSString stringWithFormat:@"%@",detaidic[@"level"]];
  45. [self.userInfoView setUserInfo:userinfo];
  46. [self.userInfoView setUserInfo];
  47. [self.tableView reloadData];
  48. } failure:^(NSError *error) {
  49. }];
  50. }
  51. - (void)backAction {
  52. [self.navigationController popViewControllerAnimated:YES];
  53. }
  54. -(void)configTableView
  55. {
  56. //头部背景图
  57. self.headerImg = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 76)];
  58. self.headerImg.userInteractionEnabled = YES;
  59. self.headerImg.image = [UIImage imageNamed:@"mine_bg"];
  60. self.tableView.tableHeaderView = self.headerImg;
  61. //用户信息
  62. self.userInfoView = [[LDUserInfoView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 60)];
  63. [self.headerImg addSubview:self.userInfoView];
  64. [self.userInfoView setUserInfo];
  65. UIButton *leftBtn = [[UIButton alloc] initWithFrame:CGRectMake(10, 15, 40, 40)];
  66. [leftBtn setImage:[UIImage imageNamed:@"back_white"] forState:UIControlStateNormal];
  67. [leftBtn addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
  68. [self.navigationBar setCustomLeftButtons:@[leftBtn]];
  69. [self.view addSubview:self.tableView];
  70. }
  71. #pragma mark ------------------
  72. - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
  73. if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
  74. [cell setSeparatorInset:UIEdgeInsetsMake(0, 0, 0, 0)];
  75. }
  76. }
  77. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  78. return [self.dataArr[section] count];
  79. }
  80. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  81. return 50;
  82. }
  83. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
  84. return 10;
  85. }
  86. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  87. {
  88. return self.dataArr.count;
  89. }
  90. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  91. UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"cellID"];
  92. cell.textLabel.text = self.dataArr[indexPath.section][indexPath.row];
  93. cell.textLabel.font = [UIFont systemFontOfSize:15];
  94. cell.textLabel.textColor = [UIColor YHColorWithHex:0x666666];
  95. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  96. if (indexPath.section != 0 ) {
  97. if (indexPath.section == 1) {
  98. if (indexPath.row == 0) {
  99. cell.detailTextLabel.text =[NSString stringWithFormat:@"%ld人",[detaidic[@"lowFriendCount"] integerValue]];
  100. }
  101. if (indexPath.row == 1) {
  102. cell.detailTextLabel.text =[NSString stringWithFormat:@"¥%.2f",[detaidic[@"allIncomeend"] floatValue]];
  103. }
  104. }
  105. if (indexPath.section ==2 ) {
  106. if (indexPath.row == 0) {
  107. cell.detailTextLabel.text =detaidic[@"parentNickname"];
  108. }
  109. if (indexPath.row == 1) {
  110. cell.detailTextLabel.text =detaidic[@"registeTime"];
  111. }
  112. }
  113. cell.detailTextLabel.font = [UIFont systemFontOfSize:15];
  114. cell.detailTextLabel.textColor = [UIColor YHColorWithHex:0x999999];
  115. cell.detailTextLabel.textAlignment=NSTextAlignmentRight;
  116. if (indexPath.section == 2 && indexPath.row == 0) {
  117. UIImageView *imgv =[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"fans_super"]];
  118. CGSize size =[self sizeWithText:detaidic[@"parentNickname"] font:15 maxSize:CGSizeMake(300, 50)];
  119. imgv.frame=CGRectMake(SCREEN_WIDTH-size.width-50, 11, 28, 28);
  120. [cell addSubview:imgv];
  121. }
  122. }else{
  123. UILabel *wechatnumL =[[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH-237, 0, 150, 50)];
  124. wechatnumL.font = [UIFont systemFontOfSize:15];
  125. wechatnumL.textColor = [UIColor YHColorWithHex:0x999999];
  126. wechatnumL.textAlignment=NSTextAlignmentRight;
  127. [cell addSubview:wechatnumL];
  128. UIButton *wechatBtn =[[UIButton alloc]initWithFrame:CGRectMake(SCREEN_WIDTH-77, 16.5, 57, 17)];
  129. wechatBtn.layer.cornerRadius=8.5;
  130. wechatBtn.layer.masksToBounds=YES;
  131. wechatBtn.layer.borderColor=[UIColor YHColorWithHex:0xFA2C36].CGColor;
  132. wechatBtn.layer.borderWidth=0.5;
  133. [wechatBtn setTitleColor:[UIColor YHColorWithHex:0xFA2C36] forState:UIControlStateNormal];
  134. wechatBtn.titleLabel.font=[UIFont systemFontOfSize:9];
  135. [wechatBtn addTarget:self action:@selector(pastClickWechat) forControlEvents:UIControlEventTouchUpInside];
  136. [cell addSubview:wechatBtn];
  137. if ([detaidic[@"isHasWechat"] integerValue ]==1) {
  138. [wechatBtn setTitle:@"复制" forState:UIControlStateNormal];
  139. wechatnumL.text =detaidic[@"wechat"];
  140. }else{
  141. [wechatBtn setTitle:@"发送请求" forState:UIControlStateNormal];
  142. wechatnumL.text =@"未填写";
  143. }
  144. }
  145. return cell;
  146. }
  147. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  148. }
  149. -(void)pastClickWechat
  150. {
  151. if ([detaidic[@"isHasWechat"] integerValue ]==1) {
  152. UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
  153. pasteboard.string=detaidic[@"wechat"];
  154. [SVProgressHUD showSuccessWithStatus:@"复制成功"];
  155. }else {
  156. NSDictionary *dic =@{@"user_id":_fansmodel.user_id};
  157. [LDHttp post:sendWechatFans params:dic success:^(id json) {
  158. NSLog(@"%@",json);
  159. [SVProgressHUD showSuccessWithStatus:json[@"msg"]];
  160. } failure:^(NSError *error) {
  161. }];
  162. }
  163. }
  164. - (UITableView *)tableView {
  165. if (!_tableView) {
  166. _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, NavBarHeight, SCREEN_WIDTH, SCREEN_HEIGHT-TabbarHeight) style:UITableViewStylePlain];
  167. _tableView.estimatedSectionHeaderHeight = 0;
  168. _tableView.estimatedSectionFooterHeight = 0;
  169. _tableView.sectionFooterHeight = 0;
  170. _tableView.sectionHeaderHeight = 0;
  171. _tableView.delegate = self;
  172. _tableView.dataSource = self;
  173. // _tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
  174. _tableView.backgroundColor = [UIColor YHColorWithHex:0xf4f4f4];
  175. _tableView.bounces = YES;
  176. _tableView.showsVerticalScrollIndicator = NO;
  177. _tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
  178. _tableView.separatorColor = [UIColor YHColorWithHex:0xEEEEEE];
  179. }
  180. return _tableView;
  181. }
  182. - (NSArray *)dataArr {
  183. if (!_dataArr) {
  184. _dataArr = @[@[@"微信号"],@[@"直属好友",@"累计收益"],@[@"邀请人",@"注册时间"]
  185. ];
  186. }
  187. return _dataArr;
  188. }
  189. - (CGSize)sizeWithText:(NSString *)text font:(CGFloat )font maxSize:(CGSize)maxSize
  190. {
  191. NSDictionary *attrs = @{NSFontAttributeName : [UIFont systemFontOfSize:font]};
  192. return [text boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:attrs context:nil].size;
  193. }
  194. @end