123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- //
- // SLMomentsNewsVc.m
- // SLAiELTS
- //
- // Created by Gusont on 2023/5/30.
- //
- #import "SLMomentsNewsVc.h"
- #import "SLMomentsNewsCell.h"
- #import "SLMomentsNewsModel.h"
- #import "SLMomentDetailTableVc.h"
- #import "SDTimeLineCellModel.h"
- @interface SLMomentsNewsVc ()<UITableViewDelegate, UITableViewDataSource>
- @property (weak, nonatomic) IBOutlet UITableView *tableView;
- @property (nonatomic, strong) NSMutableArray *newsModels;
- @end
- @implementation SLMomentsNewsVc
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view from its nib.
- self.title = NSLocalizedString(@"消息", nil);
- if (@available(iOS 11.0, *)) {
- self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
- } else {
- self.automaticallyAdjustsScrollViewInsets = NO;
- }
- [self.tableView registerNibCellWithReuseIdentifierClass:SLMomentsNewsCell.class];
- [[SLHttpCenter SharedInstance] getWithUrl:@"/api/Friend/MessageItemFriend" parameter:@{} success:^(id responseObject) {
- NSDictionary *dataArr = [responseObject objectForKey:@"data"];
- self.newsModels = [SLMomentsNewsModel mj_objectArrayWithKeyValuesArray:dataArr];
- [self.tableView reloadData];
- } failure:^(SPRequestError *error) {
- }];
- }
- - (void)rightBarBtnClick {
-
- }
- - (nonnull UITableViewCell *)tableView:(nonnull UITableView *)tableView cellForRowAtIndexPath:(nonnull NSIndexPath *)indexPath {
- SLMomentsNewsCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SLMomentsNewsCell"];
- SLMomentsNewsModel *model = [self.newsModels objectAtIndex:indexPath.row];
- [cell confignNewsCell:model];
- return cell;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
- SLMomentsNewsModel *model = [self.newsModels objectAtIndex:indexPath.row];
- return [model.interType isEqualToString:@"0"] ? 108 : 120;
- }
- - (NSInteger)tableView:(nonnull UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- return self.newsModels.count;
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
- [tableView deselectRowAtIndexPath:indexPath animated:YES];
- SLMomentsNewsModel *model = [self.newsModels objectAtIndex:indexPath.row];
- [[SLHttpCenter SharedInstance] getWithUrl:@"/api/Friend/GetFriendById" parameter:@{@"friendId" : model.friendId} success:^(id responseObject) {
- NSDictionary *dict = [responseObject objectForKey:@"data"];
- SDTimeLineCellModel *model = [SDTimeLineCellModel mj_objectWithKeyValues:dict];
- model.likeItemsArray = [NSMutableArray new];
- [model.likeStr enumerateObjectsUsingBlock:^(id _Nonnull obj1, NSUInteger idx1, BOOL * _Nonnull stop) {
- SDTimeLineCellLikeItemModel *model1 = [[SDTimeLineCellLikeItemModel alloc] init];
- model1.userName = obj1;
- model1.userId = @"1111";
- [model.likeItemsArray addObject:model1];
- }];
- SLMomentDetailTableVc *vc = [SLMomentsVc loadViewControllewWithNib];
- object_setClass(vc, SLMomentDetailTableVc.class);
- vc.isDetail = YES;
- vc.dataArray = [NSMutableArray arrayWithObject:model];
- [vc.tableView reloadData];
- [self navPushViewController:vc animated:YES];
- } failure:^(SPRequestError *error) {
- }];
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
- return 0.001f;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
- return 0.001f;
- }
- - (NSMutableArray *)newsModels {
- if (!_newsModels) {
- _newsModels = [NSMutableArray array];
- }
- return _newsModels;
- }
- @end
|