MGShowVIPListView.m 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. //
  2. // MGShowVIPListView.m
  3. // BuguLive
  4. //
  5. // Created by 宋晨光 on 2019/12/19.
  6. // Copyright © 2019 xfg. All rights reserved.
  7. //
  8. #import "MGShowVIPListView.h"
  9. @implementation MGShowVIPListView
  10. - (instancetype)initWithFrame:(CGRect)frame
  11. {
  12. self = [super initWithFrame:frame];
  13. if (self) {
  14. [self setUpView];
  15. }
  16. return self;
  17. }
  18. -(void)setUpView{
  19. UIView *bgView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, kRealValue(50))];
  20. bgView.backgroundColor = kWhiteColor;
  21. bgView.layer.masksToBounds = YES;
  22. bgView.layer.cornerRadius = kRealValue(4);
  23. UILabel *titleL = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, kScreenW / 2, kRealValue(44))];
  24. titleL.centerX = kScreenW / 2;
  25. titleL.text = ASLocalizedString(@"贵族列表");
  26. titleL.textAlignment = NSTextAlignmentCenter;
  27. titleL.font = [UIFont boldSystemFontOfSize:16];
  28. _titleL = titleL;
  29. UIButton *closeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  30. closeBtn.frame = CGRectMake(kScreenW - 40, 0, 40, 40);
  31. [closeBtn setImage:[UIImage imageNamed:@"com_close_2"] forState:UIControlStateNormal];
  32. closeBtn.hidden = YES;
  33. [closeBtn addTarget:self action:@selector(closeBtnAction) forControlEvents:UIControlEventTouchUpInside];
  34. [self addSubview:bgView];
  35. [self addSubview:titleL];
  36. [self addSubview:self.tableView];
  37. [self addSubview:closeBtn];
  38. }
  39. - (void)closeBtnAction{
  40. [self.shadowView removeFromSuperview];
  41. [self removeFromSuperview];
  42. }
  43. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  44. return 1;
  45. }
  46. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  47. return self.listArr.count;
  48. }
  49. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  50. return kRealValue(54);
  51. }
  52. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  53. BogoShowNobleCell *cell = [tableView dequeueReusableCellWithIdentifier:@"BogoShowNobleCell"];
  54. if (self.listArr.count > 0) {
  55. // MGShowVipModel *model = self.listArr[indexPath.row];
  56. [cell resetModel:self.listArr[indexPath.row]];
  57. WeakSelf
  58. cell.clickHeadBlock = ^(MGShowVipModel * _Nonnull model) {
  59. [weakSelf pushPesonVCWithModel:model];
  60. };
  61. cell.headViewAttentionBlock = ^(BOOL isAttention) {
  62. [weakSelf requestModelWithRoomID:weakSelf.roomID];
  63. };
  64. cell.rankLabel.text = [NSString stringWithFormat:@"%ld",indexPath.row + 1];
  65. }
  66. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  67. return cell;
  68. }
  69. -(void)pushPesonVCWithModel:(MGShowVipModel *)model{
  70. if (model.is_noble_mysterious.integerValue == 1) {
  71. return;;
  72. }
  73. SHomePageVC *tmpController= [[SHomePageVC alloc]init];
  74. tmpController.user_id = model.uid;
  75. tmpController.type = 0;
  76. [[AppDelegate sharedAppDelegate]pushViewController:tmpController animated:YES];
  77. }
  78. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  79. }
  80. //-(void)
  81. //手势代理
  82. - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
  83. if ([touch.view isKindOfClass:[UITableView class]]){
  84. return NO;
  85. }
  86. if ([NSStringFromClass([touch.view class]) isEqualToString:@"UITableViewCellContentView"]) {
  87. return NO;
  88. }
  89. return YES;
  90. }
  91. -(void)requestModelWithRoomID:(NSString *)roomID{
  92. self.roomID = roomID;
  93. self.listArr = [NSMutableArray array];
  94. NSMutableDictionary *mDict = [NSMutableDictionary dictionary];
  95. [mDict setObject:@"video" forKey:@"ctl"];
  96. [mDict setObject:@"get_noble_list_test" forKey:@"act"];
  97. [mDict setObject:roomID forKey:@"room_id"];
  98. [[NetHttpsManager manager] POSTWithParameters:mDict SuccessBlock:^(NSDictionary *responseJson) {
  99. if ([responseJson toInt:@"status"] == 1)
  100. {
  101. NSArray *arr = [NSArray modelArrayWithClass:[MGShowVipModel class] json:[responseJson valueForKey:@"noble_list"]];
  102. // [responseJson valueForKey:@"noble_list"];
  103. [self.listArr removeAllObjects];
  104. [self.listArr addObjectsFromArray:arr];
  105. [self.tableView reloadData];
  106. }
  107. } FailureBlock:^(NSError *error) {
  108. }];
  109. }
  110. #pragma mark - Show And Hide
  111. - (void)show:(UIView *)superView withRoomID:(NSString *)roomID{
  112. [self requestModelWithRoomID:roomID];
  113. [superView addSubview:self.shadowView];
  114. [superView addSubview:self];
  115. [UIView animateWithDuration:0.25 animations:^{
  116. self.shadowView.alpha = 1;
  117. self.y = kScreenH / 2;
  118. }];
  119. }
  120. - (void)hide{
  121. //
  122. // if (self.clickHideLiveWishBlock) {
  123. // self.clickHideLiveWishBlock();
  124. // }
  125. //
  126. [UIView animateWithDuration:0.25 animations:^{
  127. self.shadowView.alpha = 1;
  128. self.y = kScreenH;
  129. } completion:^(BOOL finished) {
  130. [self.shadowView removeFromSuperview];
  131. [self removeFromSuperview];
  132. }];
  133. }
  134. -(UITableView *)tableView{
  135. if (!_tableView) {
  136. _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, self.titleL.bottom, kScreenW, kScreenH / 2 - self.titleL.bottom) style:UITableViewStylePlain];
  137. _tableView.delegate = self;
  138. _tableView.dataSource = self;
  139. [_tableView registerNib:[UINib nibWithNibName:@"BogoShowNobleCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"BogoShowNobleCell"];
  140. // [_tableView registerClass:[BogoShowNobleCell class] forCellReuseIdentifier:@"BogoShowNobleCell"];
  141. _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  142. _tableView.tableFooterView = [UIView new];
  143. }
  144. return _tableView;
  145. }
  146. - (UIView *)shadowView{
  147. if (!_shadowView) {
  148. _shadowView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, kScreenH)];
  149. _shadowView.backgroundColor = kClearColor;
  150. _shadowView.userInteractionEnabled = YES;
  151. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(hide)];
  152. [_shadowView addGestureRecognizer:tap];
  153. }
  154. return _shadowView;
  155. }
  156. @end