PKUserListViewController.m 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. //
  2. // PKUserListViewController.m
  3. // FanweApp
  4. //
  5. // Created by 志刚杨 on 2018/7/18.
  6. // Copyright © 2018年 xfg. All rights reserved.
  7. //
  8. #import "PKUserListViewController.h"
  9. #import "PKUser.h"
  10. #import "PKUserTableViewCell.h"
  11. #import "PKPopView.h"
  12. @interface PKUserListViewController ()<UITableViewDelegate,UITableViewDataSource>
  13. @property(nonatomic, strong) UITableView *tableview;
  14. @property(nonatomic, strong) NSMutableArray *userlist;
  15. @end
  16. @implementation PKUserListViewController
  17. - (void)viewDidLoad {
  18. [super viewDidLoad];
  19. self.tableview = [[UITableView alloc] init];
  20. self.tableview.frame = self.view.bounds;
  21. self.tableview.delegate = self;
  22. self.tableview.dataSource = self;
  23. self.tableview.backgroundColor = kWhiteColor;
  24. self.tableview.separatorStyle = UITableViewCellSeparatorStyleNone;
  25. [self.tableview registerNib:[UINib nibWithNibName:@"PKUserTableViewCell" bundle:nil] forCellReuseIdentifier:@"PKUserTableViewCell"];
  26. [self.tableview reloadData];
  27. [self.view addSubview:self.tableview];
  28. //2020-1-2 加圆角
  29. self.tableview.layer.cornerRadius=6;
  30. }
  31. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  32. return 1;
  33. }
  34. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  35. return self.userlist.count;
  36. }
  37. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  38. return 50;
  39. }
  40. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  41. static NSString *identifier = @"PKUserTableViewCell";
  42. PKUserTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
  43. if (!cell) {
  44. cell = [[PKUserTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
  45. }
  46. UserModel *user = self.userlist[indexPath.row];
  47. [cell setUser:user];
  48. // cell.backgroundColor = kRandomFlatColor;
  49. [cell setClickPkBlock:^(UserModel *user) {
  50. NSInteger index = [self.userlist indexOfObject:user];
  51. [self selectIndex:index];
  52. }];
  53. return cell;
  54. }
  55. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
  56. UIView *headerView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, 50)];
  57. headerView.backgroundColor = kWhiteColor;
  58. UILabel *onlineListLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, kScreenW - 10, 50)];
  59. onlineListLabel.text = ASLocalizedString(@"在线主播列表");
  60. onlineListLabel.font = [UIFont systemFontOfSize:17];
  61. onlineListLabel.textColor = kBlackColor;
  62. onlineListLabel.textAlignment = NSTextAlignmentCenter;
  63. UIButton *closeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  64. closeBtn.frame = CGRectMake(kScreenW - kRealValue(44) - kRealValue(10), 0, kRealValue(44), 50);
  65. [closeBtn setImage:[UIImage imageNamed:@"pl_publishlive_close"] forState:UIControlStateNormal];
  66. [closeBtn addTarget:self action:@selector(clockCloes:) forControlEvents:UIControlEventTouchUpInside];
  67. UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(0, 39.5, kScreenW, 0.5)];
  68. lineView.backgroundColor = kClearColor;
  69. // [kBlackColor colorWithAlphaComponent:0.3];
  70. [headerView addSubview:closeBtn];
  71. [headerView addSubview:onlineListLabel];
  72. [headerView addSubview:lineView];
  73. return headerView;
  74. }
  75. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
  76. return 40;
  77. }
  78. -(void)reloadData
  79. {
  80. NSMutableDictionary *mDict = [NSMutableDictionary dictionary];
  81. if(![GlobalVariables sharedInstance].openAgora)
  82. {
  83. [mDict setObject:@"pk_tencent" forKey:@"ctl"];
  84. }
  85. else
  86. {
  87. [mDict setObject:@"pk_agora" forKey:@"ctl"];
  88. }
  89. [mDict setObject:@"get_emcee_list" forKey:@"act"];
  90. self.userlist = [NSMutableArray array];
  91. FWWeakify(self)
  92. [self.httpsManager POSTWithParameters:mDict SuccessBlock:^(NSDictionary *responseJson) {
  93. FWStrongify(self)
  94. if ([responseJson toInt:@"status"] == 1)
  95. {
  96. NSArray *list = responseJson[@"list"];
  97. [self.userlist removeAllObjects];
  98. for (NSDictionary * bankerDic in list)
  99. {
  100. UserModel * model = [UserModel mj_objectWithKeyValues:bankerDic];
  101. [self.userlist addObject:model];
  102. }
  103. [self.tableview reloadData];
  104. }
  105. else
  106. {
  107. [[BGHUDHelper sharedInstance] tipMessage:responseJson[@"msg"]];
  108. }
  109. } FailureBlock:^(NSError *error) {
  110. }];
  111. }
  112. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  113. [self selectIndex:indexPath.row];
  114. }
  115. -(void)clockCloes:(UIButton *)sender{
  116. if(self.pDelegate && [self.pDelegate respondsToSelector:@selector(closeUserListView)])
  117. {
  118. [self.pDelegate closeUserListView];
  119. }
  120. }
  121. - (void)selectIndex:(NSInteger)index{
  122. //弹出时间选择框
  123. PKPopView *invicationPopView = [[PKPopView alloc]initWithType:PKPopViewTypeInvication];
  124. invicationPopView.frame = CGRectMake(0, kScreenH, kScreenW, 268);
  125. [invicationPopView show:self.view.superview];
  126. // [invicationPopView show:[UIApplication sharedApplication].keyWindow];
  127. //2020-1-4 最上方
  128. //[[UIApplication sharedApplication].keyWindow.viewController.view bringSubviewToFront:invicationPopView];
  129. FWWeakify(self)
  130. [invicationPopView setClickSetTimeBlcok:^{
  131. FWStrongify(self)
  132. // invicationPopView.top = kScreenH;
  133. PKPopView *timePopView = [[PKPopView alloc]initWithType:PKPopViewSelectTime];
  134. timePopView.frame = CGRectMake(0, kScreenH, kScreenW, 268);
  135. [timePopView setClickTimeCellBlock:^(PKTimeModel *model) {
  136. [invicationPopView setPkTimeModel:model];
  137. }];
  138. [timePopView show: self.view.superview];
  139. // [timePopView show:[UIApplication sharedApplication].keyWindow];
  140. //2020-1-4 最上方
  141. //[[UIApplication sharedApplication].keyWindow.viewController.view bringSubviewToFront:timePopView];
  142. }];
  143. [invicationPopView setClickPkBtnBlock:^(NSString * _Nonnull pk_list_id) {
  144. UserModel *user = self.userlist[index];
  145. // NSMutableDictionary *mDict = [NSMutableDictionary dictionary];
  146. // [mDict setObject:@"pk_tencent" forKey:@"ctl"];
  147. // [mDict setObject:@"request_pk" forKey:@"act"];
  148. // [mDict setObject:user.user_id forKey:@"pk_emcee_id"];
  149. // [mDict setObject:pk_list_id forKey:@"pk_list_id"];
  150. //
  151. __weak __typeof(self)weakSelf = self;
  152. // [self.httpsManager POSTWithParameters:mDict SuccessBlock:^(NSDictionary *responseJson) {
  153. //
  154. // if ([responseJson toInt:@"status"] == 1)
  155. // {
  156. // NSNumber *pk_id = [responseJson objectForKey:@"pk_id"];
  157. // user.pk_id = pk_id.stringValue;
  158. if([self.pDelegate respondsToSelector:@selector(PKUserClickItem:pk_id:)])
  159. {
  160. [weakSelf.pDelegate PKUserClickItem:user pk_id:pk_list_id];
  161. }
  162. // }
  163. // else
  164. // {
  165. // [[BGHUDHelper sharedInstance] tipMessage:responseJson[@"msg"]];
  166. // }
  167. //
  168. // } FailureBlock:^(NSError *error) {
  169. // }];
  170. }];
  171. }
  172. - (void)didReceiveMemoryWarning {
  173. [super didReceiveMemoryWarning];
  174. }
  175. /*
  176. #pragma mark - Navigation
  177. // In a storyboard-based application, you will often want to do a little preparation before navigation
  178. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  179. // Get the new view controller using [segue destinationViewController].
  180. // Pass the selected object to the new view controller.
  181. }
  182. */
  183. - (NSNumber *)xy_noDataViewCenterYOffset{
  184. return [NSNumber numberWithInt: - kScreenH/4 + 50 + 20];
  185. }
  186. @end