BGRedPackResultList.m 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. //
  2. // BGReadPackListView.m
  3. // BuguLive
  4. //
  5. // Created by 志刚杨 on 2021/12/23.
  6. // Copyright © 2021 xfg. All rights reserved.
  7. //
  8. #import "BGRedPackResultList.h"
  9. #import "BGReadPackResultTableViewCell.h"
  10. #import "BGRedPackModel.h"
  11. #import <QMUIKit/QMUIKit.h>
  12. #import "BGOpenRedPackView.h"
  13. #import "SurpriseGetDetailListModel.h"
  14. @interface BGRedPackResultList()<UITableViewDelegate,UITableViewDataSource>
  15. @property(nonatomic, strong) UITableView *myTableView;
  16. @property(nonatomic, strong) UILabel *labCount;
  17. @property(nonatomic, strong) UILabel *labGetInfo;
  18. @property(nonatomic, strong) NSArray *list;
  19. @property(nonatomic, strong) UIImageView *ivAvatar;
  20. @property(nonatomic, strong) UILabel *labNickname;
  21. @property(nonatomic, strong) UILabel * labCount2;
  22. @end
  23. @implementation BGRedPackResultList
  24. - (instancetype)init
  25. {
  26. self = [super init];
  27. if (self) {
  28. [self initWithTableView];
  29. }
  30. return self;
  31. }
  32. - (void)initWithTableView {
  33. self.list = [NSArray array];
  34. UIImageView *bgImg = [[UIImageView alloc] init];
  35. bgImg.image = [UIImage imageNamed:@"hongbaoxiagnqing_bgm"];
  36. self.backgroundColor = kClearColor;
  37. [self addSubview:bgImg];
  38. [bgImg mas_makeConstraints:^(MASConstraintMaker *make) {
  39. make.edges.equalTo(self);
  40. }];
  41. UIImageView *ivAvatar = [[UIImageView alloc] init];
  42. [self addSubview:ivAvatar];
  43. [ivAvatar mas_makeConstraints:^(MASConstraintMaker *make) {
  44. make.width.equalTo(@(kRealValue(70)));
  45. make.height.equalTo(@(kRealValue(70)));
  46. make.top.equalTo(@(15));
  47. make.centerX.equalTo(self);
  48. }];
  49. ViewRadius(ivAvatar, kRealValue(35));
  50. [ivAvatar sd_setImageWithURL:[NSURL URLWithString:[IMAPlatform sharedInstance].host.imUserIconUrl]];
  51. self.labNickname = [[UILabel alloc] init];
  52. self.labNickname.text = [IMAPlatform sharedInstance].host.imUserName;
  53. self.labNickname.font = [UIFont systemFontOfSize:17];
  54. self.labNickname.textColor = [UIColor colorWithHexString:@"#FFFFFF"];
  55. [self addSubview:self.labNickname];
  56. [self.labNickname mas_makeConstraints:^(MASConstraintMaker *make) {
  57. make.centerX.equalTo(self);
  58. make.top.mas_equalTo(ivAvatar.mas_bottom).offset(6);
  59. }];
  60. _labCount = [[UILabel alloc] init];//Нийт
  61. _labCount.text = [NSString stringWithFormat:@"0"];
  62. _labCount.font = [UIFont systemFontOfSize:19];
  63. _labCount.textColor = [UIColor colorWithHexString:@"#FFC601"];
  64. [self addSubview:_labCount];
  65. [_labCount mas_makeConstraints:^(MASConstraintMaker *make) {
  66. make.centerX.equalTo(self);
  67. make.top.mas_equalTo(self.labNickname.mas_bottom).offset(10.5);
  68. }];
  69. _labCount2 = [[UILabel alloc] init];//Нийт
  70. _labCount2.text = @"0";
  71. _labCount2.font = [UIFont systemFontOfSize:19];
  72. _labCount2.textColor = [UIColor colorWithHexString:@"#FFC601"];
  73. _labCount2.text = @""; //NSLocalizedString(@"已存入 我的钻石", nil);
  74. [self addSubview:_labCount2];
  75. [_labCount2 mas_makeConstraints:^(MASConstraintMaker *make) {
  76. make.centerX.equalTo(self);
  77. make.top.mas_equalTo(_labCount.mas_bottom).offset(9);
  78. }];
  79. _labGetInfo = [[UILabel alloc] init];//Нийт
  80. _labGetInfo.text = @"";
  81. _labGetInfo.font = [UIFont systemFontOfSize:13];
  82. _labGetInfo.textColor = [UIColor colorWithHexString:@"#FF0303"];
  83. [self addSubview:_labGetInfo];
  84. [_labGetInfo mas_makeConstraints:^(MASConstraintMaker *make) {
  85. make.centerX.equalTo(self);
  86. make.top.mas_equalTo(_labCount2.mas_bottom).offset(23.5);
  87. }];
  88. self.myTableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
  89. self.myTableView.dataSource = self;
  90. self.myTableView.delegate = self;
  91. self.myTableView.dataSource = self;
  92. self.myTableView.delegate = self;
  93. [self.myTableView registerNib:[UINib nibWithNibName:[BGReadPackResultTableViewCell className] bundle:nil] forCellReuseIdentifier:@"BGReadPackResultTableViewCell"];
  94. // [self.myTableView registerClass:UITableViewCell.class forCellReuseIdentifier:@"ReadPackCell"];
  95. self.myTableView.tableFooterView = [UIView new];
  96. self.myTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  97. [self addSubview:self.myTableView];
  98. [self.myTableView mas_makeConstraints:^(MASConstraintMaker *make) {
  99. make.left.and.right.and.bottom.equalTo(self);
  100. make.top.equalTo(_labGetInfo.mas_bottom).offset(29);
  101. }];
  102. [self.myTableView reloadData];
  103. // self.qmui_borderPosition = QMUIViewBorderPositionBottom;
  104. // self
  105. // self.qmui_borderWidth = 1;
  106. }
  107. - (void)requestData{
  108. NSMutableDictionary *dict = [[NSMutableDictionary alloc]init];
  109. [dict setValue:@"surprise" forKey:@"ctl"];
  110. [dict setValue:@"requestGetSurpriseGetDetailList" forKey:@"act"];
  111. [dict setValue:self.model.id forKey:@"surprise_id"];
  112. [[NetHttpsManager manager] POSTWithParameters:dict SuccessBlock:^(NSDictionary *responseJson) {
  113. NSLog(@"104responseJson%@",responseJson);
  114. if ([responseJson toInt:@"status"] == 1) {
  115. self.list = [NSArray modelArrayWithClass:SurpriseGetDetailListModel.class json:responseJson[@"list"]];
  116. self->_labCount.text = [NSString stringWithFormat:@"%@%@",responseJson[@"diamonds_quantity"],@"Coin"];
  117. self->_labGetInfo.text = responseJson[@"get_info"];
  118. // self->_labCount.text = [NSString stringWithFormat:@"%@ %ld",NSLocalizedString(@"剩余", nil),self.list.count];
  119. // self.labNickname.text = responseJson[@""];
  120. [self.myTableView reloadData];
  121. }else{
  122. //接口请求失败
  123. NSLog(NSLocalizedString(@"守护列表请求数据失败responseJson:%@", nil),responseJson);
  124. }
  125. } FailureBlock:^(NSError *error) {
  126. NSLog(NSLocalizedString(@"守护列表请求数据失败error:%@", nil),error);
  127. }];
  128. }
  129. #pragma mark UITableViewDelegate, UITableViewDataSource
  130. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  131. return 1;
  132. }
  133. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  134. return self.list.count;
  135. }
  136. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  137. return 80;
  138. }
  139. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  140. BGReadPackResultTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"BGReadPackResultTableViewCell"];
  141. cell.backgroundColor = kWhiteColor;
  142. SurpriseGetDetailListModel *user = self.list[indexPath.row];
  143. [cell.avatar sd_setImageWithURL:[NSURL URLWithString:user.head_image]];
  144. cell.labNickname.text = user.nick_name;
  145. cell.labTime.text = user.get_time;
  146. cell.labCount.text = user.diamonds_quantity;
  147. return cell;
  148. }
  149. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  150. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  151. [self hide];
  152. BGRedPackModel *user = self.list[indexPath.row];
  153. // BGOpenRedPackView *readView = [[BGOpenRedPackView alloc] init];
  154. // readView.video_id = self.video_id;
  155. // readView.userModel = user;
  156. // readView.frame = CGRectMake(40, 0, kScreenW-40*2, kScreenH-140*2);
  157. // readView.userModel = user;
  158. //// readView.backgroundColor = kRedColor;
  159. // [readView show:[AppDelegate sharedAppDelegate].topViewController.view type:FDPopTypeCenter];
  160. // [readView requestData];
  161. // BGOpenRedPackView *
  162. }
  163. @end