// // ClickOKViewController.m // smartRhino // // Created by tederen on 2019/10/26. // Copyright © 2019 tederen. All rights reserved. // #import "ClickOKViewController.h" #import "ClickOKCell.h" #import "DrawerView.h" #import "MailListDetailVC.h" #import "MyZanCell.h" @interface ClickOKViewController () @property (weak, nonatomic) IBOutlet UITableView *myTableView; @property (nonatomic, strong)IBOutlet UILabel *titleLabel; @property (nonatomic, assign) NSUInteger currentPage; @property (nonatomic, strong) NSMutableArray *sourceNoteZanData; @property (nonatomic, strong)MyNodeBookZanModel *currentZanModel; @end @implementation ClickOKViewController +(ClickOKViewController *)initClickOKViewController{ ClickOKViewController *controller = [StoryboardManager.shared.myNoteBook instantiateViewControllerWithIdentifier:@"ClickOKViewController"]; return controller; } - (void)viewDidLoad { [super viewDidLoad]; self.fd_prefersNavigationBarHidden = YES; [self.myTableView registerNib:[UINib nibWithNibName:@"MyZanCell" bundle:nil] forCellReuseIdentifier:@"MyZanCell"]; [self headRefresh]; [self setTableViewRefresh]; } - (void)setTableViewRefresh{ WS(weakSelf); self.myTableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{ [weakSelf headRefresh]; }]; self.myTableView.mj_footer = [MJRefreshBackStateFooter footerWithRefreshingBlock:^{ [weakSelf footerRefresh]; }]; } - (void)headRefresh{ [self.sourceNoteZanData removeAllObjects]; self.currentPage = 1; [self getData]; [self.myTableView.mj_header endRefreshing]; } - (void)footerRefresh{ self.currentPage += 1; if (self.sourceNoteZanData.count == self.currentZanModel.Total) { self.myTableView.mj_footer.hidden = YES; [self.myTableView.mj_footer resetNoMoreData]; return; } [self.myTableView.mj_footer endRefreshing]; } - (void)getData{ SHOWLOADING self.titleLabel.text = [NSString stringWithFormat:@"%ld人赞过",(long)self.zanToTal]; NSLog(@"赞过的文章列表 %ld",(long)self.indexId); WS(weakSelf); NSDictionary * AnaParaDict = @{@"SourceId":@(self.indexId), @"TypeValue":@(self.type),//话题 1 @"Page":@(self.currentPage), @"PerPage":@(20), @"sort":@"" }; SHOWLOADING [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Analyze_List) parameters:AnaParaDict responseStyle:JOSN success:^(id _Nonnull responseObject) { NSLog(@"点赞列表%@",responseObject); REMOVESHOW weakSelf.currentZanModel = [[MyNodeBookZanModel alloc]initWithDictionary:responseObject error:nil]; [weakSelf.sourceNoteZanData addObjectsFromArray:weakSelf.currentZanModel.Items]; dispatch_async(dispatch_get_main_queue(), ^{ [weakSelf.myTableView reloadData]; }); } failure:^(NSError * _Nonnull error) { SHOWERROR([ZYCTool handerResultData:error]); weakSelf.currentPage -= 1; REMOVESHOW }]; } #pragma mark - tableViewDelegate - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ [tableView deselectRowAtIndexPath:indexPath animated:YES]; MailListDetailVC *vc = [MailListDetailVC initMailListDetailVC]; vc.indexId = self.sourceNoteZanData[indexPath.row].UserId; [self.navigationController pushViewController:vc animated:YES]; } #pragma mark - tableviewDataSource - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return self.sourceNoteZanData.count; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ return 70; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ MyZanCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MyZanCell"]; MyNoteBookZanSubModel *model = self.sourceNoteZanData[indexPath.row]; [cell.zanImageView setImageWithURL:[NSURL URLWithString:model.AvatarUrl] placeholder:IMG(@"zhujun")]; cell.zanNamelabel.text = model.UserName; cell.zanNameDescriptlabel.text = model.DepartmentName; cell.zanTimelabel.text = [ZYCTool monthAndDayAndHoursAndMinutes:model.CreatedDate]; return cell; } #pragma mark - setter - (UILabel *)titleLabel{ if (!_titleLabel) { _titleLabel = [[UILabel alloc]init]; _titleLabel.font = [UIFont systemFontOfSize:17.f]; _titleLabel.textColor =[UIColor hexStringToColor:@"333333" ]; } return _titleLabel; } - (NSMutableArray *)sourceNoteZanData{ if (!_sourceNoteZanData) { _sourceNoteZanData = [NSMutableArray new]; } return _sourceNoteZanData; } ///按照时段可分为“凌晨/上午/下午/晚上”, ///今天的显示“时段+时:分”如“上午+10:49”, ///昨天的显示“昨天+时:分”,如“昨天+20:38”; ///超过一天但是在本周之内(自然周)显示“星期+时:分”,如“星期二 02:30”; ///本周之前但是在 今年之内显示“月-日 时:分”,如“09-24 21:03”; ///今年之前显示“年月日”,如“2017-12-08” //- (NSString *)getCurrentTimeStr:(NSString *)time1{ // // 1.确定时间 //// NSString *time1 = @"2015-06-23 12:18:15"; //// NSString *time2 = @"2015-06-28 10:10:10"; // // 2.将时间转换为date // NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; // formatter.dateFormat = @"yyyy-MM-dd HH:mm:ss"; // NSDate *date1 = [formatter dateFromString:time1]; // NSDate *date2; // if (@available(iOS 13.0, *)) { // date2 = [NSDate now]; // } else { // date2 =[NSDate date]; // } // // 3.创建日历 // NSCalendar *calendar = [NSCalendar currentCalendar]; // NSCalendarUnit type = NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay | NSCalendarUnitHour | NSCalendarUnitMinute | NSCalendarUnitSecond; // // 4.利用日历对象比较两个时间的差值 // NSDateComponents *cmps = [calendar components:type fromDate:date1 toDate:date2 options:0]; // // 5.输出结果 // NSLog(@"两个时间相差%ld年%ld月%ld日%ld小时%ld分钟%ld秒", cmps.year, cmps.month, cmps.day, cmps.hour, cmps.minute, cmps.second); // if (cmps.year > 0) { // return // } // // // // return @";;"; //} @end