adminLists.m 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. #import "adminLists.h"
  2. #import "adminCell.h"
  3. #import "fansModel.h"
  4. @interface adminLists ()<UITableViewDelegate,UITableViewDataSource,adminCellDelegate>
  5. @property(nonatomic,strong)NSArray *fansmodels;
  6. @property(nonatomic,strong)NSArray *allArray;
  7. @property(nonatomic,strong)UITableView *tableView;
  8. @property(nonatomic,strong)NSString *addAdmins;
  9. @end
  10. @implementation adminLists
  11. -(NSArray *)fansmodels{
  12. NSMutableArray *array = [NSMutableArray array];
  13. for (NSDictionary *dic in self.allArray) {
  14. fansModel *model = [fansModel modelWithDic:dic];
  15. [array addObject:model];
  16. }
  17. _fansmodels = array;
  18. return _fansmodels;
  19. }
  20. -(void)viewDidLoad{
  21. [super viewDidLoad];
  22. self.titleL.text = YZMsg(@"管理员列表");
  23. self.allArray = [NSArray array];
  24. self.fansmodels = [NSArray array];
  25. self.view.backgroundColor = [UIColor whiteColor];
  26. self.tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 64+statusbarHeight, _window_width, _window_height-64-statusbarHeight) style:UITableViewStyleGrouped];
  27. self.tableView.contentInset = UIEdgeInsetsMake(0, 0, ShowDiff, 0);
  28. self.tableView.delegate = self;
  29. self.tableView.dataSource = self;
  30. self.tableView.bounces = NO;
  31. [self.view addSubview:self.tableView];
  32. [self listMessage];
  33. }
  34. -(void)listMessage{
  35. NSDictionary *subdic = @{
  36. @"liveuid":[Config getOwnID]
  37. };
  38. [YBNetworking postWithUrl:@"Live.getAdminList" Dic:subdic Suc:^(int code, id info, NSString *msg) {
  39. if (code == 0) {
  40. self.allArray = [[info firstObject] valueForKey:@"list"];//关注信息复制给数据源
  41. self.addAdmins = [[info firstObject] valueForKey:@"total"];//总的管理员
  42. dispatch_async(dispatch_get_main_queue(), ^{
  43. [self.tableView reloadData];
  44. });
  45. }else {
  46. [MBProgressHUD showPop:msg];
  47. }
  48. } Fail:^(id fail) {
  49. }];
  50. }
  51. -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
  52. UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, _window_width, 30)];
  53. label.backgroundColor = [UIColor whiteColor];
  54. label.textColor = [UIColor blackColor];
  55. label.font = [UIFont systemFontOfSize:15];
  56. label.text = [NSString stringWithFormat:@" %@(%ld/%@)",YZMsg(@"当前管理员"),self.allArray.count,self.addAdmins];
  57. return label;
  58. }
  59. -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
  60. return 30;
  61. }
  62. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  63. return self.allArray.count;
  64. }
  65. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  66. {
  67. [self.tableView deselectRowAtIndexPath:indexPath animated:YES];
  68. adminCell *cell = [adminCell cellWithTableView:tableView];
  69. cell.delegate = self;
  70. fansModel *model = self.fansmodels[indexPath.row];
  71. cell.model = model;
  72. return cell;
  73. }
  74. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  75. //弹窗
  76. [self.tableView deselectRowAtIndexPath:indexPath animated:YES];
  77. }
  78. -(void)doGuanzhu:(NSString *)st{
  79. //关注
  80. [MBProgressHUD showMessage:@""];
  81. NSString *url = [NSString stringWithFormat:@"User.setAttention&uid=%@&showid=%@&token=%@",[Config getOwnID],st,[Config getOwnToken]];
  82. [YBNetworking postWithUrl:url Dic:nil Suc:^(int code, id info, NSString *msg) {
  83. [MBProgressHUD hideHUD];
  84. } Fail:^(id fail) {
  85. [MBProgressHUD hideHUD];
  86. }];
  87. }
  88. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  89. {
  90. return 50;
  91. }
  92. - (void)delateAdminUser:(fansModel *)model{
  93. YBWeakSelf;
  94. NSDictionary *contentDic = @{@"title":YZMsg(@"温馨提示"),@"msg":[NSString stringWithFormat:@"%@%@%@?",YZMsg(@"是否确定取消"),model.name,YZMsg(@"的管理员身份")],@"left":YZMsg(@"关闭"),@"right":YZMsg(@"确定")};
  95. [YBAlertView showAlertView:contentDic complete:^(int eventType) {
  96. if (eventType == 1) {
  97. [weakSelf clickSureBtn:model];
  98. }
  99. }];
  100. }
  101. -(void)clickSureBtn:(fansModel *)model {
  102. NSDictionary *setadmin = @{
  103. @"liveuid":[Config getOwnID],
  104. @"touid":model.uid,
  105. };
  106. [YBNetworking postWithUrl:@"Live.setAdmin" Dic:setadmin Suc:^(int code, id info, NSString *msg) {
  107. if (code == 0) {
  108. NSString *isadmin = [NSString stringWithFormat:@"%@",[[info firstObject] valueForKey:@"isadmin"]];
  109. [self.delegate setAdminSuccess:isadmin andName:model.name andID:model.uid];
  110. [self listMessage];
  111. }else{
  112. [MBProgressHUD showError:msg];
  113. }
  114. } Fail:^(id fail) {
  115. }];
  116. }
  117. @end