// // YOUPAILCSeenVC.m // LiveChat // // Created by 张灿 on 2018/8/26. // Copyright © 2018年 caicai. All rights reserved. // #import "YOUPAILCSeenVC.h" #import "YOUPAILCRelationCell.h" #import "YOUPAILZUserShowVC.h" @interface YOUPAILCSeenVC () @property(nonatomic,assign)NSInteger youpaipcurrentPage; @property(nonatomic,assign)NSInteger youpaiptotalPage; @property(nonatomic,strong)NSMutableArray* youpaipuserArray; @property(nonatomic,strong)NSMutableArray* youpaipuserIdArray; @end @implementation YOUPAILCSeenVC - (void)viewDidLoad { [super viewDidLoad]; [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(youpaifchangeFollowStateNotification:) name:@"ChangeFollowState" object:nil];; self.title = @"最近来访"; self.view.backgroundColor = [UIColor whiteColor]; self.youpaipuserArray = [NSMutableArray array]; self.youpaipuserIdArray = [NSMutableArray array]; [self youpaifsetupTableView]; self.tableView.backgroundColor = [UIColor clearColor]; [self.tableView.mj_header beginRefreshing]; } - (void)youpaifchangeFollowStateNotification:(NSNotification *)notification{ NSDictionary *dict = [notification userInfo]; NSString *idStr = dict[@"follow_uid"]; NSInteger isfollow = [dict[@"is_follow"] intValue]; NSArray *arr = self.youpaipuserArray; NSMutableArray *arrM = [NSMutableArray new]; if (arr.count>0) { NSIndexPath *index; for (int i = 0; i=self.youpaiptotalPage) { [self.tableView.mj_footer endRefreshingWithNoMoreData]; self.tableView.mj_footer.hidden = YES; } if (self.youpaipuserArray.count != 0) { [self.tableView lz_hideEmptyView]; }else{ [self.tableView lz_showEmptyViewWithImage:[UIImage imageNamed:@"vqu_images_not_home_data"] content:@"暂无数据"]; } [self.tableView.mj_header endRefreshing]; }else{ [self.tableView.mj_header endRefreshing]; } } failure:^(NSError *error) { [self.tableView.mj_header endRefreshing]; }]; } - (void)youpaifloadMoreData{ [self.tableView.mj_header endRefreshing]; self.tableView.mj_footer.hidden = YES; [self.tableView.mj_footer endRefreshing]; self.youpaipcurrentPage+=1; [LCHttpHelper requestWithURLString:SeenList parameters:@{@"page":@(self.youpaipcurrentPage)} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) { NSDictionary* dict = (NSDictionary*)responseObject; NSInteger code = [[dict objectForKey:@"code"] integerValue]; if (code==0) {//成功 NSArray* array = [[dict objectForKey:@"data"]objectForKey:@"list"]; NSMutableArray* modelArray = [YOUPAILCRelationModel mj_objectArrayWithKeyValuesArray:array]; NSMutableArray* tempArray = [NSMutableArray arrayWithArray:(NSArray*)modelArray]; for (YOUPAILCRelationModel* model in modelArray) { if ([self.youpaipuserArray containsObject:model.youpaipuserid]) { [tempArray removeObject:model]; }else{ [self.youpaipuserIdArray addObject:model.youpaipuserid]; } } [self.youpaipuserArray addObjectsFromArray:tempArray]; self.youpaiptotalPage = [[[dict objectForKey:@"data"]objectForKey:@"total_page"]integerValue]; self.youpaipcurrentPage = [[[dict objectForKey:@"data"]objectForKey:@"page"]integerValue]; [self.tableView reloadData]; if (self.youpaipcurrentPage>=self.youpaiptotalPage) { [self.tableView.mj_footer endRefreshingWithNoMoreData]; self.tableView.mj_footer.hidden = YES; } [self.tableView.mj_header endRefreshing]; }else{ [self.tableView.mj_header endRefreshing]; } } failure:^(NSError *error) { [self.tableView.mj_header endRefreshing]; }]; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ return 70; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return self.youpaipuserArray.count; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ YOUPAILCRelationCell* cell = [[YOUPAILCRelationCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"LCRelationCellfollow"]; YOUPAILCRelationModel* model = self.youpaipuserArray[indexPath.row]; cell.youpaiprelationType = @"seen"; cell.youpaiprelationModel = model; return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ YOUPAILCRelationModel* model = self.youpaipuserArray[indexPath.row]; model.youpaipis_watch = 1; [self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone]; // LCUserShowVC* userShow = [[LCUserShowVC alloc]init]; YOUPAILZUserShowVC *userShow = [[YOUPAILZUserShowVC alloc] init]; userShow.youpaipuserId = model.youpaipuserid; [self.navigationController pushViewController:userShow animated:YES]; } @end