You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
139 lines
5.1 KiB
139 lines
5.1 KiB
// |
|
// SchMessageViewController.m |
|
// LekangGuard |
|
// |
|
// Created by ecell on 2023/6/7. |
|
// |
|
|
|
#import "SchAndJobMessageViewController.h" |
|
#import "CommMessageTableViewCell.h" |
|
#import "CommMessageDetailsViewController.h" |
|
|
|
@interface SchAndJobMessageViewController ()<DZNEmptyDataSetSource,DZNEmptyDataSetDelegate> |
|
|
|
|
|
@property (nonatomic ,strong) CommonTableView *schMsgTable; |
|
|
|
@property (nonatomic ,assign) NSInteger page; |
|
|
|
@end |
|
|
|
@implementation SchAndJobMessageViewController |
|
|
|
- (void)viewDidLoad { |
|
[super viewDidLoad]; |
|
// Do any additional setup after loading the view. |
|
self.zx_navTitle = self.navTitle; |
|
self.emptyText = F(@"暂无%@", self.navTitle); |
|
self.page = 1; |
|
self.view.backgroundColor = KKBackgroundGrey; |
|
[self.view addSubview:self.schMsgTable]; |
|
[self.schMsgTable mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.left.right.equalTo(self.view); |
|
make.top.equalTo(self.view).offset(iPhoneX_NavHeight); |
|
make.bottom.equalTo(self.view); |
|
}]; |
|
[UICommon MessageUpload:@"加载中"]; |
|
[self GetSchMessageList:TableisReload_h]; |
|
} |
|
|
|
- (CommonTableView *)schMsgTable |
|
{ |
|
if (!_schMsgTable) |
|
{ |
|
kWeakSelf(self) |
|
_schMsgTable = [[CommonTableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain cellHeight:50 cellRow:0 isAdaptive:YES isLine:NO commonCell:CommMessageTableViewCell.class createCell:^(ZZTableViewCell * _Nonnull cells, NSIndexPath * _Nonnull indexPath) { |
|
CommMessageTableViewCell *cell = (CommMessageTableViewCell *)cells; |
|
if (self.viewType == 0) |
|
cell.schModel = self.modelListArr[indexPath.row]; |
|
else |
|
cell.jobModel = self.modelListArr[indexPath.row]; |
|
|
|
} selectedCell:^(UITableView * _Nonnull tableView, NSIndexPath * _Nonnull indexPath) { |
|
|
|
CommMessageDetailsViewController *vc = [[CommMessageDetailsViewController alloc] init]; |
|
vc.viewType = self.viewType; |
|
if (self.viewType == 0) |
|
vc.schModel = self.modelListArr[indexPath.row]; |
|
else |
|
vc.jobModel = self.modelListArr[indexPath.row]; |
|
[self.navigationController pushViewController:vc animated:YES]; |
|
|
|
} DidscrollView:^(UIScrollView * _Nonnull scrollView) { |
|
|
|
}]; |
|
_schMsgTable.backgroundColor = KKClearColor; |
|
_schMsgTable.emptyDataSetSource = self; |
|
_schMsgTable.emptyDataSetDelegate = self; |
|
[_schMsgTable bindHeadRefreshHandler:^{ |
|
[UICommon feedbackGenerator]; |
|
[weakself GetSchMessageList:TableisReload_h]; |
|
} themeColor:KKMainColor refreshStyle:KafkaRefreshStyleReplicatorWoody]; |
|
|
|
[_schMsgTable bindFootRefreshHandler:^{ |
|
[weakself GetSchMessageList:TableisReload_f]; |
|
} themeColor:KKMainColor refreshStyle:KafkaRefreshStyleReplicatorWoody]; |
|
|
|
} |
|
return _schMsgTable; |
|
} |
|
|
|
|
|
|
|
#pragma mark 获取校园通知 |
|
/// 获取校园通知 |
|
- (void)GetSchMessageList:(TableisReload)isReload |
|
{ |
|
kWeakSelf(self) |
|
if (isReload == TableisReload_h) |
|
{ |
|
self.page = 1; |
|
[self.modelListArr removeAllObjects]; |
|
} |
|
NSMutableDictionary *parameters = [NSMutableDictionary dictionary]; |
|
[parameters setValue:@(self.page) forKey:@"current"]; |
|
[parameters setValue:@(20) forKey:@"pageSize"]; |
|
[[[APIManager sharedManager] APGET:self.viewType == 0 ? CampusPage_GET_URL : HomeWorkPage_GET_URL parameters:parameters resultClass:BaseModel.class] subscribeNext:^(BaseModel *obj) { |
|
[UICommon HidenLoading]; |
|
if (ARRAYHASVALUE(obj.records)) |
|
{ |
|
[weakself.schMsgTable.headRefreshControl endRefreshingWithAlertText:@"已为你加载最新数据~" completion:^{ |
|
|
|
}]; |
|
[weakself.schMsgTable.footRefreshControl endRefreshing]; |
|
[obj.records enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { |
|
if (weakself.viewType == 0) |
|
{ |
|
SchModel *model = [SchModel yy_modelWithJSON:obj]; |
|
[self.modelListArr addObject:model]; |
|
} |
|
else |
|
{ |
|
JobModel *model = [JobModel yy_modelWithJSON:obj]; |
|
[self.modelListArr addObject:model]; |
|
} |
|
}]; |
|
weakself.page++; |
|
weakself.schMsgTable.footRefreshControl.hidden = obj.records.count < KSizeNO ? YES : NO; |
|
weakself.schMsgTable.cellRow = self.modelListArr.count; |
|
[weakself.schMsgTable reloadData]; |
|
} |
|
|
|
|
|
} error:^(NSError * _Nullable error) { |
|
NSDictionary *dic = error.userInfo; |
|
[UICommon MessageErrorText:dic[NSLocalizedDescriptionKey]]; |
|
}]; |
|
} |
|
|
|
/* |
|
#pragma mark - Navigation |
|
|
|
// In a storyboard-based application, you will often want to do a little preparation before navigation |
|
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { |
|
// Get the new view controller using [segue destinationViewController]. |
|
// Pass the selected object to the new view controller. |
|
} |
|
*/ |
|
|
|
@end
|
|
|