ReplayMeLikeVC.m 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. //
  2. // ReplayMeLikeVC.m
  3. // smartRhino
  4. //
  5. // Created by niuzhen on 2020/6/11.
  6. // Copyright © 2020 tederen. All rights reserved.
  7. //
  8. #import "ReplayMeLikeVC.h"
  9. #import "MyTDGroupView.h"
  10. #import "ReplayMeCell.h"
  11. #import "ReplayLikeSearchVC.h"
  12. @interface ReplayMeLikeVC ()<UITableViewDelegate,UITableViewDataSource>
  13. @property (weak, nonatomic) IBOutlet UIView *navBar;
  14. @property (weak, nonatomic) IBOutlet UIView *HeadView;
  15. @property (weak, nonatomic) IBOutlet UITableView *tableView;
  16. @property (weak, nonatomic) IBOutlet UILabel *titleL;
  17. @property (strong, nonatomic) MyTDGroupView *SearchView;
  18. @property (strong, nonatomic) NSMutableArray *dataArray;
  19. @end
  20. @implementation ReplayMeLikeVC
  21. +(ReplayMeLikeVC *)initReplayMeLikeVC{
  22. ReplayMeLikeVC *controller = [StoryboardManager.shared.Source instantiateViewControllerWithIdentifier:@"ReplayMeLikeVC"];
  23. return controller;
  24. }
  25. -(NSMutableArray *)dataArray{
  26. if(!_dataArray){
  27. _dataArray = [NSMutableArray array];
  28. }
  29. return _dataArray;
  30. }
  31. - (MyTDGroupView *)SearchView
  32. {
  33. if (!_SearchView) {
  34. _SearchView = [[MyTDGroupView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 36)];
  35. }
  36. return _SearchView;
  37. }
  38. - (void)viewDidLoad {
  39. [super viewDidLoad];
  40. self.fd_prefersNavigationBarHidden = YES;
  41. self.tableView.delegate = self;
  42. self.tableView.dataSource = self;
  43. [self.HeadView addSubview:self.SearchView];
  44. [self.SearchView mas_makeConstraints:^(MASConstraintMaker *make) {
  45. make.top.mas_offset(6);
  46. make.left.right.mas_equalTo(self.HeadView);
  47. make.height.mas_offset(36);
  48. }];
  49. self.titleL.text = @"共收到赞";
  50. WS(weakSelf);
  51. [self.SearchView.button setAction:^{
  52. ReplayLikeSearchVC * vc = [[ReplayLikeSearchVC alloc] init];
  53. [weakSelf.navigationController pushViewController:vc animated:YES];
  54. }];
  55. [self getData];
  56. }
  57. - (void)getData
  58. {
  59. [self.dataArray removeAllObjects];
  60. NSDictionary * paraDict = @{@"KeyWord":@"",
  61. @"TypeValue":@(0),
  62. };
  63. WS(weakSelf);
  64. SHOWLOADING
  65. [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Reply_Praise) parameters:paraDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
  66. REMOVESHOW
  67. if ([responseObject isKindOfClass:[NSArray class]]) {
  68. for (NSDictionary * dict in responseObject) {
  69. ReplyModel * model = [ReplyModel modelWithDictionary:dict];
  70. [weakSelf.dataArray addObject:model];
  71. }
  72. }
  73. dispatch_async(dispatch_get_main_queue(), ^{
  74. if (weakSelf.dataArray.count > 0) {
  75. weakSelf.titleL.text = [NSString stringWithFormat:@"共收到赞(%ld)",weakSelf.dataArray.count];
  76. }else{
  77. weakSelf.titleL.text = @"共收到赞";
  78. }
  79. [weakSelf.tableView reloadData];
  80. });
  81. } failure:^(NSError * _Nonnull error) {
  82. REMOVESHOW
  83. }];
  84. }
  85. #pragma mark -UITableViewDelegate
  86. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  87. {
  88. return self.dataArray.count;
  89. }
  90. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  91. {
  92. return UITableViewAutomaticDimension;
  93. }
  94. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  95. {
  96. ReplyModel * model = [self.dataArray objectAtIndex:indexPath.row];
  97. if (model.IsComment) {
  98. ReplayMeCell * cell = [ReplayMeCell configCell0:tableView indexPath:indexPath];
  99. cell.redV.hidden = model.IsRead;
  100. [cell setDataCommentModel:model];
  101. return cell;
  102. }else{
  103. ReplayMeCell * cell = [ReplayMeCell configCell1:tableView indexPath:indexPath];
  104. cell.redV.hidden = model.IsRead;
  105. [cell setDataModel:model];
  106. return cell;
  107. }
  108. }
  109. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  110. {
  111. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  112. ReplyModel * model = [self.dataArray objectAtIndex:indexPath.row];
  113. model.IsRead = YES;
  114. dispatch_async(dispatch_get_main_queue(), ^{
  115. [tableView reloadRowAtIndexPath:indexPath withRowAnimation:UITableViewRowAnimationAutomatic];
  116. });
  117. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  118. vc.type = model.TypeValue;
  119. vc.Id = model.SourceId;
  120. [self.navigationController pushViewController:vc animated:YES];
  121. }
  122. @end