MOUserDisConnectedView.m 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. //
  2. // MOUserDisConnectedView.m
  3. // MiMoLive
  4. //
  5. // Created by SuperC on 2024/9/11.
  6. //
  7. //一页的size
  8. #define kPageSize 15
  9. #import "MOUserDisConnectedView.h"
  10. #import "MOVoiceContriCell.h"
  11. #import "MOLinkMicSummaryData.h"
  12. @interface MOUserDisConnectedView ()<UITableViewDelegate,UITableViewDataSource>
  13. @property (weak, nonatomic) IBOutlet UIView *bgView;
  14. @property (weak, nonatomic) IBOutlet UILabel *titleLab;
  15. @property (weak, nonatomic) IBOutlet UILabel *goldNumLab;
  16. @property (weak, nonatomic) IBOutlet UIButton *goldNumBtn;
  17. @property (weak, nonatomic) IBOutlet UILabel *timeLab;
  18. @property (weak, nonatomic) IBOutlet UIButton *timeTagBtn;
  19. @property (weak, nonatomic) IBOutlet UILabel *linkTimeLab;
  20. @property (weak, nonatomic) IBOutlet UIButton *linkTimeTagBtn;
  21. @property (weak, nonatomic) IBOutlet UILabel *tipLab;
  22. @property (weak, nonatomic) IBOutlet UIButton *zuanNumBtn;
  23. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *tableViewTop;
  24. @property (weak, nonatomic) IBOutlet UITableView *tableView;
  25. @property (weak, nonatomic) IBOutlet UILabel *contributionTagLab;
  26. /** 展示数据 */
  27. @property (nonatomic, strong) NSMutableArray *dataArr;
  28. @property (nonatomic, copy) NSString *next;
  29. @end
  30. @implementation MOUserDisConnectedView
  31. + (instancetype)moUserDisConnectedView{
  32. return [[[NSBundle mainBundle] loadNibNamed:@"MOUserDisConnectedView" owner:self options:nil] firstObject];
  33. }
  34. - (void)awakeFromNib{
  35. [super awakeFromNib];
  36. self.next = @"";
  37. //上方 两个圆角
  38. self.bgView.layer.cornerRadius = 16.0;
  39. self.bgView.layer.masksToBounds = YES;
  40. self.bgView.layer.maskedCorners = kCALayerMinXMinYCorner | kCALayerMaxXMinYCorner;
  41. self.titleLab.text = NSLocalString(@"mimo_live_link_disconnected");
  42. [self.goldNumBtn setTitle:NSLocalString(@"mimo_live_link_golden_bean") forState:UIControlStateNormal];
  43. [self.timeTagBtn setTitle:NSLocalString(@"mimo_live_link_link_time") forState:UIControlStateNormal];
  44. [self.linkTimeTagBtn setTitle:NSLocalString(@"mimo_live_link_links") forState:UIControlStateNormal];
  45. self.tipLab.text = NSLocalString(@"mimo_live_link_e_d_r");
  46. self.contributionTagLab.text = NSLocalString(@"mimo_live_link_contribution_list");
  47. self.goldNumBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 10.0, 0, 0);
  48. self.timeTagBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 10.0, 0, 0);
  49. self.linkTimeTagBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 10.0, 0, 0);
  50. self.zuanNumBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 20.0, 0, 0);
  51. self.titleLab.font = [MOTextTools getTheFontWithSize:16.0 AndFontName:kNormalTitleFontStr];
  52. self.contributionTagLab.font = [MOTextTools getTheFontWithSize:16.0 AndFontName:kNormalContentFontStr];
  53. self.goldNumLab.font = [MOTextTools getTheFontWithSize:20.0 AndFontName:kNormalContentFontStr];
  54. [self.goldNumBtn setFont:[MOTextTools getTheFontWithSize:12.0 AndFontName:kNormalContentFontStr]];
  55. self.timeLab.font = [MOTextTools getTheFontWithSize:20.0 AndFontName:kNormalContentFontStr];
  56. [self.timeTagBtn setFont:[MOTextTools getTheFontWithSize:12.0 AndFontName:kNormalContentFontStr]];
  57. self.linkTimeLab.font = [MOTextTools getTheFontWithSize:20.0 AndFontName:kNormalContentFontStr];
  58. [self.linkTimeTagBtn setFont:[MOTextTools getTheFontWithSize:12.0 AndFontName:kNormalContentFontStr]];
  59. self.tipLab.font = [MOTextTools getTheFontWithSize:16.0 AndFontName:kNormalContentFontStr];
  60. [self.zuanNumBtn setFont:[MOTextTools getTheFontWithSize:24.0 AndFontName:kNormalContentFontStr]];
  61. self.tableView.delegate = self;
  62. self.tableView.dataSource = self;
  63. self.tableView.rowHeight = 62.0;
  64. self.tableView.estimatedRowHeight = 0;
  65. self.tableView.estimatedSectionHeaderHeight = 0;
  66. self.tableView.estimatedSectionFooterHeight = 0;
  67. //iOS15适配
  68. if (@available(iOS 15.0, *))
  69. {
  70. self.tableView.sectionHeaderTopPadding = 0;
  71. }
  72. [self.tableView registerNib:[UINib nibWithNibName:@"MOVoiceContriCell" bundle:nil] forCellReuseIdentifier:MOVoiceContriCell_ID];
  73. WEAKSELF
  74. self.tableView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
  75. NSString *roomId = weakSelf.roomId;
  76. if(roomId.length == 0){
  77. return;
  78. }
  79. NSDictionary *basePage = @{@"size":@(kPageSize),@"next":weakSelf.next};
  80. NSDictionary *baseDict = @{@"page":basePage,
  81. @"roomId":roomId,
  82. @"userId":weakSelf.userId};
  83. [weakSelf getTheVoiceOutcomeRankDataWith:baseDict];
  84. }];
  85. }
  86. - (IBAction)closeBtnClick:(id)sender {
  87. [self dismissUserDisConnectedView];
  88. }
  89. - (void)getTheConnectData{
  90. WEAKSELF
  91. NSString *roomId = self.roomId;
  92. if(roomId.length == 0){
  93. return;
  94. }
  95. NSDictionary *dict = @{@"id":roomId};
  96. [kHttpManager toGetTheLiveLinkMicGuestSummaryWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
  97. if(kCode_Success){
  98. MOLogV(@"%@",[[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:data options:0 error:nil] encoding:NSUTF8StringEncoding]);
  99. MOLinkMicSummaryData *baseData = [MOLinkMicSummaryData modelObjectWithDictionary:data[@"data"]];
  100. [weakSelf updataTheTopInfoViewWith:baseData];
  101. }
  102. else{
  103. MOLogV(@"toGetTheLiveLinkMicGuestSummaryWithParams 接口报错了");
  104. kShowNetError(data)
  105. }
  106. }];
  107. }
  108. - (void)updataTheTopInfoViewWith:(MOLinkMicSummaryData *)viewData{
  109. self.goldNumLab.text = [MOTextTools formatNumberDecimalValue:viewData.goldenBean];
  110. self.timeLab.text = [NSString stringWithFormat:@"%.f min",viewData.linkMinutes];
  111. self.linkTimeLab.text = [NSString stringWithFormat:@"%.f",viewData.linkCount];
  112. if(viewData.anchor){
  113. self.tableViewTop.constant = 60.0;
  114. self.zuanNumBtn.hidden = YES;
  115. self.tipLab.hidden = YES;
  116. }
  117. else{
  118. self.tableViewTop.constant = 150.0;
  119. }
  120. [self.zuanNumBtn setTitle:[MOTextTools formatNumberDecimalValue:viewData.incomeDiamond] forState:UIControlStateNormal];
  121. }
  122. - (void)getFirstHttpData{
  123. self.next = @"";
  124. NSString *roomId = self.roomId;
  125. if(roomId.length == 0 || self.userId.length == 0){
  126. return;
  127. }
  128. [self getTheConnectData];
  129. NSDictionary *basePage = @{@"size":@(kPageSize),@"next":self.next};
  130. NSDictionary *baseDict = @{@"page":basePage,
  131. @"roomId":roomId,
  132. @"userId":self.userId};
  133. [self getTheVoiceOutcomeRankDataWith:baseDict];
  134. }
  135. - (void)getTheVoiceOutcomeRankDataWith:(NSDictionary *)dict{
  136. WEAKSELF
  137. [kHttpManager toGetTheOutcomeAboutGuestWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
  138. if(kCode_Success){
  139. MOLogV(@"%@",[[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:data options:0 error:nil] encoding:NSUTF8StringEncoding]);
  140. MORankBasedata *personModel = [MORankBasedata modelObjectWithDictionary:data[@"data"]];
  141. if(personModel.next == nil || personModel.next.length == 0){
  142. if(self.next == nil || self.next.length == 0){
  143. //第一页
  144. self.dataArr = [personModel.ranklist mutableCopy];
  145. }
  146. else{
  147. //最后一页
  148. [self.dataArr addObjectsFromArray:personModel.ranklist];
  149. }
  150. self.next = @"";
  151. [self.tableView.mj_footer endRefreshingWithNoMoreData];
  152. }
  153. else{
  154. self.next = personModel.next;
  155. [self.dataArr addObjectsFromArray:personModel.ranklist];
  156. }
  157. [self.tableView reloadData];
  158. self.tableView.mj_footer.hidden = (self.dataArr.count > 0) ? NO : YES;
  159. }
  160. else{
  161. MOLogV(@"toGetTheOutcomeAboutGuestWithParams 接口报错了");
  162. kShowNetError(data)
  163. }
  164. }];
  165. }
  166. #pragma mark - UITableViewDelegate,UITableViewDataSource
  167. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  168. return 1;
  169. }
  170. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  171. return self.dataArr.count;
  172. }
  173. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  174. MORanklist *model = self.dataArr[indexPath.row];
  175. MOVoiceContriCell *cell = [tableView dequeueReusableCellWithIdentifier:MOVoiceContriCell_ID];
  176. cell.cellIndexPath = indexPath;
  177. cell.cellModel = model;
  178. return cell;
  179. }
  180. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  181. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  182. }
  183. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
  184. UIView *view = [[UIView alloc] init];
  185. view.backgroundColor = [UIColor clearColor];
  186. return view;
  187. }
  188. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
  189. return 0.01;
  190. }
  191. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
  192. return 0.01;
  193. }
  194. - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
  195. UIView *view = [[UIView alloc] init];
  196. view.backgroundColor = [UIColor clearColor];
  197. return view;
  198. }
  199. - (void)showUserDisConnectedView{
  200. self.frame = CGRectMake(0, 0, SCREENWIDTH, SCREENHEIGHT);
  201. CGRect actionViewRect = self.bgView.frame;
  202. actionViewRect.origin.y = SCREENHEIGHT;
  203. self.bgView.frame = actionViewRect;
  204. WEAKSELF
  205. [UIView animateWithDuration:0.3 animations:^{
  206. CGRect actionViewRect = weakSelf.bgView.frame;
  207. actionViewRect.origin.y = SCREENHEIGHT - 480.0;
  208. weakSelf.bgView.frame = actionViewRect;
  209. }];
  210. //不能滑动
  211. SendNotification(@"MOShowLivePagesVCCannotScroll")
  212. }
  213. - (void)dismissUserDisConnectedView{
  214. //完成下移动画
  215. WEAKSELF
  216. [UIView animateWithDuration:0.3 animations:^
  217. {
  218. CGRect actionSheetViewRect = weakSelf.bgView.frame;
  219. actionSheetViewRect.origin.y = SCREENHEIGHT;
  220. weakSelf.bgView.frame = actionSheetViewRect;
  221. } completion:^(BOOL finished)
  222. {
  223. [self removeFromSuperview];
  224. }];
  225. //可以滑动
  226. SendNotification(@"MOShowLivePagesVCCanScroll")
  227. }
  228. - (NSMutableArray *)dataArr{
  229. if(!_dataArr){
  230. _dataArr = [NSMutableArray array];
  231. }
  232. return _dataArr;
  233. }
  234. @end