MyTDTopicUserMoveVC.m 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. //
  2. // MyTDTopicUserMoveVC.m
  3. // smartRhino
  4. //
  5. // Created by niuzhen on 2019/12/20.
  6. // Copyright © 2019 tederen. All rights reserved.
  7. //
  8. #import "MyTDTopicUserMoveVC.h"
  9. #import "TopicGroupManageModel.h"
  10. #import "TopicGroupManageCell.h"
  11. #import "MyTDGroupView.h"
  12. @interface MyTDTopicUserMoveVC ()<UITableViewDelegate, UITableViewDataSource>
  13. @property (weak, nonatomic) IBOutlet UITableView *tableView;
  14. @property (weak, nonatomic) IBOutlet UILabel *titleL;
  15. @property (nonatomic, strong) NSMutableArray *dataArray;
  16. @end
  17. @implementation MyTDTopicUserMoveVC
  18. +(MyTDTopicUserMoveVC *)initMyTDTopicUserMoveVC;
  19. {
  20. MyTDTopicUserMoveVC *controller = [StoryboardManager.shared.myTDTopicExtent instantiateViewControllerWithIdentifier:@"MyTDTopicUserMoveVC"];
  21. return controller;
  22. }
  23. - (void)viewDidLoad {
  24. [super viewDidLoad];
  25. self.fd_prefersNavigationBarHidden = YES;
  26. self.titleL.text = @"移动到";
  27. self.tableView.delegate = self;
  28. self.tableView.dataSource = self;
  29. [self getData];
  30. }
  31. - (void)getData
  32. {
  33. [self.dataArray removeAllObjects];
  34. WS(weakSelf);
  35. [[HttpManager sharedHttpManager] POSTUrl:Host(APP_Topic_Group) parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  36. NSLog(@"%@",responseObject);
  37. NSArray * array = responseObject;
  38. [array enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  39. NSDictionary * dict = (NSDictionary *)obj;
  40. TopicGroupManageModel * model = [TopicGroupManageModel modelWithDictionary:dict];
  41. [weakSelf.dataArray addObject:model];
  42. }];
  43. dispatch_async(dispatch_get_main_queue(), ^{
  44. [weakSelf.tableView reloadData];
  45. });
  46. } failure:^(NSError * _Nonnull error) {
  47. }];
  48. }
  49. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  50. {
  51. if (section == 0) {
  52. return 50.f;
  53. }
  54. return 0.01f;
  55. }
  56. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
  57. {
  58. if (section == 0) {
  59. UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 50)];
  60. MyTDGroupView * groupView = [[MyTDGroupView alloc] init];
  61. [view addSubview:groupView];
  62. view.backgroundColor = UIColorHex(FFFFFF);
  63. UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(pushSearchVC)];
  64. [view addGestureRecognizer:tap];
  65. view.userInteractionEnabled = YES;
  66. return view;
  67. }else{
  68. return [UIView new];
  69. }
  70. }
  71. - (void)pushSearchVC
  72. {
  73. }
  74. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  75. {
  76. return 50.f;
  77. }
  78. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  79. {
  80. return self.dataArray.count;
  81. }
  82. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  83. {
  84. TopicGroupManageModel * model = [self.dataArray objectAtIndex:indexPath.row];
  85. TopicGroupManageCell * cell = [TopicGroupManageCell configCell0:tableView indexPath:indexPath];
  86. cell.countL.hidden = YES;
  87. cell.rightImgV.hidden = YES;
  88. cell.nameL.text = model.Name;
  89. return cell;
  90. }
  91. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(nonnull NSIndexPath *)indexPath
  92. {
  93. TopicGroupManageModel * model = [self.dataArray objectAtIndex:indexPath.row];
  94. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  95. [self moveToindex:model.Id];
  96. }
  97. - (void)moveToindex:(NSInteger)toId
  98. {
  99. WS(weakSelf);
  100. SHOWLOADING
  101. [[HttpManager sharedHttpManager] PUTUrl:Host(APP_Topic_Move) parameters:@{@"TopicGroupId":@(toId),@"Ids":self.selectIdArray} responseStyle:DATA success:^(id _Nonnull responseObject) {
  102. REMOVESHOW
  103. SHOWSUCCESS(@"操作成功");
  104. for ( int i = 0; i< weakSelf.navigationController.viewControllers.count; i++) {
  105. if ([weakSelf.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"MyTDTopicGroupManageVC")]) {
  106. [weakSelf.navigationController popToViewController:self.navigationController.viewControllers[i] animated:YES];
  107. }
  108. }
  109. } failure:^(NSError * _Nonnull error) {
  110. REMOVESHOW
  111. SHOWERROR([ZYCTool handerResultData:error])
  112. }];
  113. }
  114. - (NSMutableArray *)dataArray
  115. {
  116. if (!_dataArray) {
  117. _dataArray = [NSMutableArray array];
  118. }
  119. return _dataArray;
  120. }
  121. @end