BGReadPackListView.m 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. //
  2. // BGReadPackListView.m
  3. // BuguLive
  4. //
  5. // Created by 志刚杨 on 2021/12/23.
  6. // Copyright © 2021 xfg. All rights reserved.
  7. //
  8. #import "BGReadPackListView.h"
  9. #import "BGReadPackTableViewCell.h"
  10. #import "BGRedPackModel.h"
  11. #import <QMUIKit/QMUIKit.h>
  12. #import "BGOpenRedPackView.h"
  13. @interface BGReadPackListView()<UITableViewDelegate,UITableViewDataSource>
  14. @property(nonatomic, strong) UITableView *myTableView;
  15. @property(nonatomic, strong) UILabel *labCount;
  16. @property(nonatomic, strong) NSArray *list;
  17. @end
  18. @implementation BGReadPackListView
  19. - (instancetype)init
  20. {
  21. self = [super init];
  22. if (self) {
  23. [self initWithTableView];
  24. }
  25. return self;
  26. }
  27. - (void)initWithTableView {
  28. self.list = [NSArray array];
  29. UIImageView *bgImg = [[UIImageView alloc] init];
  30. bgImg.image = [UIImage imageNamed:@"qianghongbao_bgm"];
  31. self.backgroundColor = kClearColor;
  32. [self addSubview:bgImg];
  33. [bgImg mas_makeConstraints:^(MASConstraintMaker *make) {
  34. make.edges.equalTo(self);
  35. }];
  36. UILabel *labtitle = [[UILabel alloc] init];
  37. labtitle.text = ASLocalizedString(@"直播间红包");
  38. labtitle.font = [UIFont systemFontOfSize:24];
  39. labtitle.textColor = [UIColor colorWithHexString:@"#FFC601"];
  40. [self addSubview:labtitle];
  41. [labtitle mas_makeConstraints:^(MASConstraintMaker *make) {
  42. make.centerX.equalTo(self);
  43. make.top.mas_equalTo(11);
  44. }];
  45. _labCount = [[UILabel alloc] init];//Нийт
  46. _labCount.text = [NSString stringWithFormat:@"%@",ASLocalizedString(@"剩余")];
  47. _labCount.font = [UIFont systemFontOfSize:15];
  48. _labCount.textColor = [UIColor colorWithHexString:@"#ffffff"];
  49. [self addSubview:_labCount];
  50. [_labCount mas_makeConstraints:^(MASConstraintMaker *make) {
  51. make.centerX.equalTo(self);
  52. make.top.mas_equalTo(labtitle.mas_bottom).offset(10.5);
  53. }];
  54. self.myTableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
  55. self.myTableView.dataSource = self;
  56. self.myTableView.delegate = self;
  57. self.myTableView.dataSource = self;
  58. self.myTableView.delegate = self;
  59. [self.myTableView registerNib:[UINib nibWithNibName:[BGReadPackTableViewCell className] bundle:nil] forCellReuseIdentifier:@"ReadPackCell"];
  60. // [self.myTableView registerClass:UITableViewCell.class forCellReuseIdentifier:@"ReadPackCell"];
  61. self.myTableView.tableFooterView = [UIView new];
  62. self.myTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  63. [self addSubview:self.myTableView];
  64. [self.myTableView mas_makeConstraints:^(MASConstraintMaker *make) {
  65. make.left.and.right.and.bottom.equalTo(self);
  66. make.top.mas_equalTo(77);
  67. }];
  68. [self.myTableView reloadData];
  69. // self.qmui_borderPosition = QMUIViewBorderPositionBottom;
  70. // self
  71. // self.qmui_borderWidth = 1;
  72. }
  73. - (void)requestData{
  74. NSMutableDictionary *dict = [[NSMutableDictionary alloc]init];
  75. [dict setValue:@"surprise" forKey:@"ctl"];
  76. [dict setValue:@"requestGetSurpriseList" forKey:@"act"];
  77. [dict setValue:self.video_id forKey:@"video_id"];
  78. [[NetHttpsManager manager] POSTWithParameters:dict SuccessBlock:^(NSDictionary *responseJson) {
  79. NSLog(@"104responseJson%@",responseJson);
  80. if ([responseJson toInt:@"status"] == 1) {
  81. self.list = [NSArray modelArrayWithClass:BGRedPackModel.class json:responseJson[@"list"]];
  82. self->_labCount.text = [NSString stringWithFormat:@"%@ %ld",ASLocalizedString(@"剩余"),self.list.count];
  83. [self.myTableView reloadData];
  84. }else{
  85. //接口请求失败
  86. NSLog(NSLocalizedString(@"守护列表请求数据失败responseJson:%@", nil),responseJson);
  87. }
  88. } FailureBlock:^(NSError *error) {
  89. NSLog(NSLocalizedString(@"守护列表请求数据失败error:%@", nil),error);
  90. }];
  91. }
  92. #pragma mark UITableViewDelegate, UITableViewDataSource
  93. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  94. return 1;
  95. }
  96. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  97. return self.list.count;
  98. }
  99. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  100. return 80;
  101. }
  102. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  103. BGReadPackTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ReadPackCell"];
  104. cell.backgroundColor = kWhiteColor;
  105. BGRedPackModel *user = self.list[indexPath.row];
  106. [cell.avatar sd_setImageWithURL:[NSURL URLWithString:user.head_image]];
  107. cell.labNickname.text = user.nick_name;
  108. cell.labTime.text = ASLocalizedString(@"派发了一个即时红包");
  109. return cell;
  110. }
  111. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  112. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  113. [self hide];
  114. BGRedPackModel *user = self.list[indexPath.row];
  115. BGOpenRedPackView *readView = [[BGOpenRedPackView alloc] init];
  116. readView.video_id = self.video_id;
  117. readView.userModel = user;
  118. readView.frame = CGRectMake(40, 0, kScreenW-40*2, kScreenH-140*2);
  119. readView.userModel = user;
  120. // readView.backgroundColor = kRedColor;
  121. [readView show:[AppDelegate sharedAppDelegate].topViewController.view type:FDPopTypeCenter];
  122. // [readView requestData];
  123. // BGOpenRedPackView *
  124. }
  125. @end