YOUPAIFSVideoChoseVC.m 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. //
  2. // YOUPAIFSVideoChoseVC.m
  3. // FoxSister
  4. //
  5. // Created by leo on 2019/11/19.
  6. // Copyright © 2019 fox. All rights reserved.
  7. //
  8. #import "YOUPAIFSVideoChoseVC.h"
  9. #import "YOUPAILCUserShowModel.h"
  10. @interface YOUPAIFSVideoChoseVC ()<UITableViewDelegate,UITableViewDataSource,UIGestureRecognizerDelegate>
  11. @property(nonatomic,strong)YOUPAILCUserShowModel *showModel;
  12. @property(nonatomic,strong)UITableView *tableView;
  13. @property(nonatomic,strong)UIView *tableHeaderView,*tableFootView;
  14. @property(nonatomic,assign)NSInteger account_value;
  15. @property(nonatomic,strong)NSDictionary *dataDic;
  16. @end
  17. @implementation YOUPAIFSVideoChoseVC
  18. - (void)viewDidLoad {
  19. [super viewDidLoad];
  20. // [self.view setFrame:CGRectMake(0, 0, _screenWidth, _screenHeight)];
  21. // [self.view setBackgroundColor:[UIColor whiteColor]];
  22. //
  23. // CAShapeLayer *maskLayer = [CAShapeLayer layer];
  24. // UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:self.view.bounds cornerRadius:25];
  25. // maskLayer.path = path.CGPath;
  26. // self.view.layer.mask = maskLayer;
  27. _tableView = [[UITableView alloc]initWithFrame:CGRectMake(40, 0, self.vWidth-80,self.vHeight) style:UITableViewStylePlain];
  28. _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  29. _tableView.backgroundColor = [UIColor whiteColor];
  30. _tableView.tableFooterView =[[UIView alloc] initWithFrame:CGRectZero];
  31. _tableView.rowHeight = 67;
  32. _tableView.estimatedRowHeight =0;
  33. _tableView.delegate = self;
  34. _tableView.dataSource = self;
  35. if (@available(iOS 15.0, *)) {
  36. _tableView.sectionHeaderTopPadding = 0;
  37. }
  38. [self.baseView addSubview:_tableView];
  39. [self youpaifinitData];
  40. UITapGestureRecognizer *tapGes = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(headerClick)];
  41. tapGes.delegate = self;
  42. [self.baseView addGestureRecognizer:tapGes];
  43. // Do any additional setup after loading the view.
  44. }
  45. -(void)refreshVC
  46. {
  47. _tableView.tableHeaderView = [self tableHeaderView];
  48. _tableView.tableFooterView = [self tableFootView];
  49. [_tableView reloadData];
  50. }
  51. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  52. {
  53. }
  54. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  55. {
  56. return 1;
  57. }
  58. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  59. {
  60. return 0;
  61. }
  62. -(UIView *)tableHeaderView
  63. {
  64. if(!_tableHeaderView)
  65. {
  66. _tableHeaderView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.vWidth-80, 135)];
  67. }
  68. CGFloat tableWith = self.vWidth-80;
  69. [_tableHeaderView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
  70. UIImageView *headerIcon = [[UIImageView alloc]initWithFrame:CGRectMake(tableWith/2-24, 15, 48, 48)];
  71. [headerIcon sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@/%@",[LCSaveData getImageUrl]?[LCSaveData getImageUrl]:BaseImgUrl,self.dataDic[@"avatar"]]]];
  72. headerIcon.layer.cornerRadius =24;
  73. headerIcon.layer.masksToBounds = YES;
  74. [_tableHeaderView addSubview:headerIcon];
  75. UILabel *titleLab =[[UILabel alloc]initWithFrame:CGRectMake(0, 56+15, tableWith, 14)];
  76. [titleLab setTextAlignment:NSTextAlignmentCenter];
  77. [titleLab setTextColor:[UIColor blackColor]];
  78. [titleLab setFont:[UIFont systemFontOfSize:14]];
  79. [titleLab setText:self.dataDic[@"nickname"]];
  80. [_tableHeaderView addSubview:titleLab];
  81. UILabel *detialLab =[[UILabel alloc]initWithFrame:CGRectMake(0, 56+15+12+14, tableWith, 12)];
  82. [detialLab setTextAlignment:NSTextAlignmentCenter];
  83. [detialLab setTextColor:[UIColor blackColor]];
  84. [detialLab setFont:[UIFont systemFontOfSize:12]];
  85. [detialLab setText:[NSString stringWithFormat:@"%@ %ld岁 富豪值:%ld",self.dataDic[@"city"],[self.dataDic[@"age"]integerValue],[self.dataDic[@"wealth_value"]integerValue]]];
  86. [_tableHeaderView addSubview:detialLab];
  87. return _tableHeaderView;
  88. }
  89. - (void)youpaifinitData{
  90. WeakSelf;
  91. [LCHttpHelper requestWithURLString:UserLite parameters:@{@"user_id":self.userId} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  92. NSDictionary* dict = (NSDictionary*)responseObject;
  93. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  94. if (code==0) {//成功
  95. weakSelf.dataDic = dict[@"data"];
  96. weakSelf.account_value = [dict[@"data"][@"account_value"] integerValue];
  97. [weakSelf refreshVC];
  98. }
  99. } failure:^(NSError *error) {
  100. }];
  101. }
  102. -(UIView *)tableFootView
  103. {
  104. if(!_tableFootView)
  105. {
  106. _tableFootView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.vWidth-80, 80)];
  107. }
  108. CGFloat footWidth = (self.vWidth-80)/2;
  109. // CGFloat tableWith = self.vWidth-80;
  110. [_tableFootView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
  111. NSArray *detailtitleArray = @[@"消费",@"财富"];
  112. NSArray *titleArray = @[@(self.account_value),@([self.dataDic[@"wealth_value"]integerValue])];
  113. for(int i=0;i<2;i++)
  114. {
  115. UILabel *titleLab =[[UILabel alloc]initWithFrame:CGRectMake(0+(footWidth)*i, 20, footWidth, 20)];
  116. [titleLab setTextAlignment:NSTextAlignmentCenter];
  117. [titleLab setTextColor:[UIColor blackColor]];
  118. [titleLab setFont:[UIFont systemFontOfSize:16]];
  119. [titleLab setText:[NSString stringWithFormat:@"%@钻石",titleArray[i]]];
  120. [_tableFootView addSubview:titleLab];
  121. UILabel *detialLab =[[UILabel alloc]initWithFrame:CGRectMake(0+(footWidth)*i, 50, footWidth, 14)];
  122. [detialLab setTextAlignment:NSTextAlignmentCenter];
  123. [detialLab setTextColor:[UIColor lightGrayColor]];
  124. [detialLab setFont:[UIFont systemFontOfSize:14]];
  125. [detialLab setText:[NSString stringWithFormat:@"%@", detailtitleArray[i]]];
  126. [_tableFootView addSubview:detialLab];
  127. }
  128. return _tableFootView;
  129. }
  130. -(void)btnClick:(UIButton *)btn
  131. {
  132. NSIndexPath *indexPath=[self.tableView indexPathForCell:(UITableViewCell*)[[btn superview]superview]];
  133. if([_delegate respondsToSelector:@selector(youpaifvideoChose:userId:)])
  134. {
  135. [self dismissViewControllerAnimated:YES completion:^{
  136. [_delegate youpaifvideoChose:indexPath.row userId:self.userId];
  137. }];
  138. }
  139. }
  140. -(void)headerClick
  141. {
  142. if(self.avblock)
  143. {
  144. [self dismissViewControllerAnimated:YES completion:^{
  145. self.avblock();
  146. }];
  147. }
  148. }
  149. /*
  150. #pragma mark - Navigation
  151. // In a storyboard-based application, you will often want to do a little preparation before navigation
  152. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  153. // Get the new view controller using [segue destinationViewController].
  154. // Pass the selected object to the new view controller.
  155. }
  156. */
  157. @end