PKBattleViewController.m 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. //
  2. // PKBattleViewController.m
  3. // BuguLive
  4. //
  5. // Created by 宋晨光 on 2021/3/30.
  6. // Copyright © 2021 xfg. All rights reserved.
  7. //
  8. #import "PKBattleViewController.h"
  9. #import "PKBattleListCell.h"
  10. #import "PKBattleListModel.h"
  11. @interface PKBattleViewController ()<PKBattleDelegate>
  12. @property(nonatomic, strong) UITableView *tableView;
  13. @property(nonatomic, strong) NSMutableArray *listArr;
  14. @property(nonatomic, assign) NSInteger page;
  15. @end
  16. @implementation PKBattleViewController
  17. - (void)viewDidLoad {
  18. [super viewDidLoad];
  19. // Do any additional setup after loading the view.
  20. self.title = ASLocalizedString(@"PK对战");
  21. self.view.backgroundColor = kWhiteColor;
  22. }
  23. - (void)initFWData{
  24. [super initFWData];
  25. self.listArr = [NSMutableArray array];
  26. self.page = 0;
  27. [self loadDataWithPage:self.page];
  28. }
  29. -(void)loadDataWithPage:(NSInteger)index{
  30. NSMutableDictionary *mDict = [NSMutableDictionary dictionary];
  31. if(![GlobalVariables sharedInstance].openAgora)
  32. {
  33. [mDict setObject:@"pk_tencent" forKey:@"ctl"];
  34. }
  35. else
  36. {
  37. [mDict setObject:@"pk_agora" forKey:@"ctl"];
  38. }
  39. [mDict setObject:@"get_pk_lists" forKey:@"act"];
  40. [mDict setObject:[BGIMLoginManager sharedInstance].loginParam.identifier forKey:@"user_id"];
  41. [mDict setObject:[NSString stringWithFormat:@"%ld",index] forKey:@"page"];
  42. FWWeakify(self)
  43. [self.httpsManager POSTWithParameters:mDict SuccessBlock:^(NSDictionary *responseJson) {
  44. FWStrongify(self)
  45. if ([responseJson toInt:@"status"] == 1)
  46. {
  47. NSArray *list = responseJson[@"data"];
  48. [self.listArr removeAllObjects];
  49. for (NSDictionary * bankerDic in list)
  50. {
  51. PKBattleListModel * model = [PKBattleListModel mj_objectWithKeyValues:bankerDic];
  52. [self.listArr addObject:model];
  53. }
  54. if (self.listArr.count > 0) {
  55. [self hideNoContentView];
  56. }else{
  57. [self showNoContentView];
  58. // }
  59. }
  60. [self.tableView reloadData];
  61. }
  62. else
  63. {
  64. if (self.page == 0) {
  65. [self.listArr removeAllObjects];
  66. [self.tableView reloadData];
  67. [self showNoContentView];
  68. }
  69. // [[BGHUDHelper sharedInstance] tipMessage:responseJson[@"msg"]];
  70. }
  71. [BGMJRefreshManager endRefresh:_tableView];
  72. } FailureBlock:^(NSError *error) {
  73. [BGMJRefreshManager endRefresh:_tableView];
  74. }];
  75. }
  76. #pragma mark 头部刷新
  77. - (void)headerReresh
  78. {
  79. [self loadDataWithPage:0];
  80. }
  81. #pragma mark 尾部刷新
  82. - (void)footerReresh
  83. {
  84. _page ++;
  85. [self loadDataWithPage:_page];
  86. }
  87. - (void)initFWUI
  88. {
  89. [super initFWUI];
  90. [self setupBackBtnWithBlock:nil];
  91. self.title = ASLocalizedString(@"PK对战");
  92. [self.view addSubview:self.tableView];
  93. }
  94. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  95. return 1;
  96. }
  97. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  98. return self.listArr.count;
  99. }
  100. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  101. return kRealValue(230);
  102. }
  103. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  104. PKBattleListCell *cell = [tableView dequeueReusableCellWithIdentifier:@"PKBattleListCell"];
  105. cell.model = self.listArr[indexPath.row];
  106. cell.delegate = self;
  107. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  108. return cell;
  109. }
  110. #pragma mark NewestViewController跳转到直播
  111. -(void)clickBattleModel:(PKBattleListModel *)model LeftOrRight:(BOOL)isLeft{
  112. if (![BGUtils isNetConnected])
  113. {
  114. return;
  115. }
  116. [self.BuguLive.newestLivingMArray removeAllObjects];
  117. [self.BuguLive.newestLivingMArray addObject:model];
  118. if ([self checkUser:[IMAPlatform sharedInstance].host])
  119. {
  120. TCShowLiveListItem *item = [[TCShowLiveListItem alloc]init];
  121. //点击左边主播
  122. if (isLeft) {
  123. item.chatRoomId = model.group_id1;
  124. item.avRoomId = model.room_id1.intValue;
  125. item.title = model.room_id1;
  126. item.vagueImgUrl = model.head_image1;
  127. // item.is_voice = model.is_voice;
  128. TCShowUser *showUser = [[TCShowUser alloc]init];
  129. showUser.uid = model.emcee_user_id1;
  130. showUser.avatar = model.head_image1;
  131. item.host = showUser;
  132. item.liveType = FW_LIVE_TYPE_AUDIENCE;
  133. }else{
  134. item.chatRoomId = model.group_id2;
  135. item.avRoomId = model.room_id2.intValue;
  136. item.title = model.room_id2;
  137. item.vagueImgUrl = model.head_image2;
  138. // item.is_voice = model.is_voice;
  139. TCShowUser *showUser = [[TCShowUser alloc]init];
  140. showUser.uid = model.emcee_user_id2;
  141. showUser.avatar = model.head_image2;
  142. item.host = showUser;
  143. item.liveType = FW_LIVE_TYPE_AUDIENCE;
  144. }
  145. if ([LiveCenterManager sharedInstance].itemModel) {
  146. [[NSNotificationCenter defaultCenter]postNotificationName:@"clickLiveRoomNotification" object:nil];
  147. }
  148. [LiveCenterManager sharedInstance].itemModel=item;
  149. //2020-1-7 小直播变大
  150. [LiveCenterManager sharedInstance].itemModel=item;
  151. BOOL isSusWindow = [[LiveCenterManager sharedInstance] judgeIsSusWindow];
  152. [[LiveCenterManager sharedInstance] showLiveOfAudienceLiveofTCShowLiveListItem:item modelArr:nil isSusWindow:isSusWindow isSmallScreen:NO block:^(BOOL isFinished) {
  153. }];
  154. }
  155. else
  156. {
  157. [[BGHUDHelper sharedInstance] loading:@"" delay:2 execute:^{
  158. [[BGIMLoginManager sharedInstance] loginImSDK:YES succ:nil failed:nil];
  159. } completion:^{
  160. }];
  161. }
  162. }
  163. - (BOOL)checkUser:(id<IMHostAble>)user
  164. {
  165. if (![user conformsToProtocol:@protocol(AVUserAble)])
  166. {
  167. return NO;
  168. }
  169. return YES;
  170. }
  171. -(UITableView *)tableView{
  172. if (!_tableView) {
  173. _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, kScreenH - kTopHeight) style:UITableViewStylePlain];
  174. _tableView.delegate = self;
  175. _tableView.dataSource = self;
  176. _tableView.tag = 1107;
  177. [_tableView registerNib:[UINib nibWithNibName:@"PKBattleListCell" bundle:nil] forCellReuseIdentifier:@"PKBattleListCell"];
  178. _tableView.tableFooterView = [[UIView alloc]init];
  179. _tableView.separatorStyle = UITableViewCellSelectionStyleNone;
  180. [BGMJRefreshManager refresh:_tableView target:self headerRereshAction:@selector(headerReresh) shouldHeaderBeginRefresh:NO footerRereshAction:@selector(footerReresh)];
  181. }
  182. return _tableView;
  183. }
  184. /*
  185. #pragma mark - Navigation
  186. // In a storyboard-based application, you will often want to do a little preparation before navigation
  187. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  188. // Get the new view controller using [segue destinationViewController].
  189. // Pass the selected object to the new view controller.
  190. }
  191. */
  192. @end