ClickOKViewController.m 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. //
  2. // ClickOKViewController.m
  3. // smartRhino
  4. //
  5. // Created by tederen on 2019/10/26.
  6. // Copyright © 2019 tederen. All rights reserved.
  7. //
  8. #import "ClickOKViewController.h"
  9. #import "ClickOKCell.h"
  10. #import "DrawerView.h"
  11. #import "MailListDetailVC.h"
  12. #import "MyZanCell.h"
  13. @interface ClickOKViewController ()<UITableViewDelegate,UITableViewDataSource>
  14. @property (weak, nonatomic) IBOutlet UITableView *myTableView;
  15. @property (nonatomic, strong)IBOutlet UILabel *titleLabel;
  16. @property (nonatomic, assign) NSUInteger currentPage;
  17. @property (nonatomic, strong) NSMutableArray<MyNoteBookZanSubModel *> *sourceNoteZanData;
  18. @property (nonatomic, strong)MyNodeBookZanModel *currentZanModel;
  19. @end
  20. @implementation ClickOKViewController
  21. +(ClickOKViewController *)initClickOKViewController{
  22. ClickOKViewController *controller = [StoryboardManager.shared.myNoteBook instantiateViewControllerWithIdentifier:@"ClickOKViewController"];
  23. return controller;
  24. }
  25. - (void)viewDidLoad {
  26. [super viewDidLoad];
  27. self.fd_prefersNavigationBarHidden = YES;
  28. [self.myTableView registerNib:[UINib nibWithNibName:@"MyZanCell" bundle:nil] forCellReuseIdentifier:@"MyZanCell"];
  29. [self headRefresh];
  30. [self setTableViewRefresh];
  31. }
  32. - (void)setTableViewRefresh{
  33. WS(weakSelf);
  34. self.myTableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
  35. [weakSelf headRefresh];
  36. }];
  37. self.myTableView.mj_footer = [MJRefreshBackStateFooter footerWithRefreshingBlock:^{
  38. [weakSelf footerRefresh];
  39. }];
  40. }
  41. - (void)headRefresh{
  42. [self.sourceNoteZanData removeAllObjects];
  43. self.currentPage = 1;
  44. [self getData];
  45. [self.myTableView.mj_header endRefreshing];
  46. }
  47. - (void)footerRefresh{
  48. self.currentPage += 1;
  49. if (self.sourceNoteZanData.count == self.currentZanModel.Total) {
  50. self.myTableView.mj_footer.hidden = YES;
  51. [self.myTableView.mj_footer resetNoMoreData];
  52. return;
  53. }
  54. [self.myTableView.mj_footer endRefreshing];
  55. }
  56. - (void)getData{
  57. SHOWLOADING
  58. self.titleLabel.text = [NSString stringWithFormat:@"%ld人赞过",(long)self.zanToTal];
  59. NSLog(@"赞过的文章列表 %ld",(long)self.indexId);
  60. WS(weakSelf);
  61. NSDictionary * AnaParaDict = @{@"SourceId":@(self.indexId),
  62. @"TypeValue":@(self.type),//话题 1
  63. @"Page":@(self.currentPage),
  64. @"PerPage":@(20),
  65. @"sort":@""
  66. };
  67. SHOWLOADING
  68. [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Analyze_List) parameters:AnaParaDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
  69. NSLog(@"点赞列表%@",responseObject);
  70. REMOVESHOW
  71. weakSelf.currentZanModel = [[MyNodeBookZanModel alloc]initWithDictionary:responseObject error:nil];
  72. [weakSelf.sourceNoteZanData addObjectsFromArray:weakSelf.currentZanModel.Items];
  73. dispatch_async(dispatch_get_main_queue(), ^{
  74. [weakSelf.myTableView reloadData];
  75. });
  76. } failure:^(NSError * _Nonnull error) {
  77. SHOWERROR([ZYCTool handerResultData:error]);
  78. weakSelf.currentPage -= 1;
  79. REMOVESHOW
  80. }];
  81. }
  82. #pragma mark - tableViewDelegate
  83. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  84. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  85. MailListDetailVC *vc = [MailListDetailVC initMailListDetailVC];
  86. vc.indexId = self.sourceNoteZanData[indexPath.row].UserId;
  87. [self.navigationController pushViewController:vc animated:YES];
  88. }
  89. #pragma mark - tableviewDataSource
  90. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  91. return 1;
  92. }
  93. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  94. return self.sourceNoteZanData.count;
  95. }
  96. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  97. return 70;
  98. }
  99. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  100. MyZanCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MyZanCell"];
  101. MyNoteBookZanSubModel *model = self.sourceNoteZanData[indexPath.row];
  102. [cell.zanImageView setImageWithURL:[NSURL URLWithString:model.AvatarUrl] placeholder:IMG(@"zhujun")];
  103. cell.zanNamelabel.text = model.UserName;
  104. cell.zanNameDescriptlabel.text = model.DepartmentName;
  105. cell.zanTimelabel.text = [ZYCTool monthAndDayAndHoursAndMinutes:model.CreatedDate];
  106. return cell;
  107. }
  108. #pragma mark - setter
  109. - (UILabel *)titleLabel{
  110. if (!_titleLabel) {
  111. _titleLabel = [[UILabel alloc]init];
  112. _titleLabel.font = [UIFont systemFontOfSize:17.f];
  113. _titleLabel.textColor =[UIColor hexStringToColor:@"333333" ];
  114. }
  115. return _titleLabel;
  116. }
  117. - (NSMutableArray<MyNoteBookZanSubModel *> *)sourceNoteZanData{
  118. if (!_sourceNoteZanData) {
  119. _sourceNoteZanData = [NSMutableArray new];
  120. }
  121. return _sourceNoteZanData;
  122. }
  123. ///按照时段可分为“凌晨/上午/下午/晚上”,
  124. ///今天的显示“时段+时:分”如“上午+10:49”,
  125. ///昨天的显示“昨天+时:分”,如“昨天+20:38”;
  126. ///超过一天但是在本周之内(自然周)显示“星期+时:分”,如“星期二 02:30”;
  127. ///本周之前但是在 今年之内显示“月-日 时:分”,如“09-24 21:03”;
  128. ///今年之前显示“年月日”,如“2017-12-08”
  129. //- (NSString *)getCurrentTimeStr:(NSString *)time1{
  130. // // 1.确定时间
  131. //// NSString *time1 = @"2015-06-23 12:18:15";
  132. //// NSString *time2 = @"2015-06-28 10:10:10";
  133. // // 2.将时间转换为date
  134. // NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
  135. // formatter.dateFormat = @"yyyy-MM-dd HH:mm:ss";
  136. // NSDate *date1 = [formatter dateFromString:time1];
  137. // NSDate *date2;
  138. // if (@available(iOS 13.0, *)) {
  139. // date2 = [NSDate now];
  140. // } else {
  141. // date2 =[NSDate date];
  142. // }
  143. // // 3.创建日历
  144. // NSCalendar *calendar = [NSCalendar currentCalendar];
  145. // NSCalendarUnit type = NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay | NSCalendarUnitHour | NSCalendarUnitMinute | NSCalendarUnitSecond;
  146. // // 4.利用日历对象比较两个时间的差值
  147. // NSDateComponents *cmps = [calendar components:type fromDate:date1 toDate:date2 options:0];
  148. // // 5.输出结果
  149. // NSLog(@"两个时间相差%ld年%ld月%ld日%ld小时%ld分钟%ld秒", cmps.year, cmps.month, cmps.day, cmps.hour, cmps.minute, cmps.second);
  150. // if (cmps.year > 0) {
  151. // return
  152. // }
  153. //
  154. //
  155. //
  156. // return @";;";
  157. //}
  158. @end