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.
203 lines
7.2 KiB
203 lines
7.2 KiB
![]()
2 years ago
|
//
|
||
|
// 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];
|
||
|
|
||
![]()
2 years ago
|
[self setMessageRead:self.modelListArr[indexPath.row] IndexPath:indexPath];
|
||
|
|
||
![]()
2 years ago
|
} 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))
|
||
|
{
|
||
![]()
2 years ago
|
[weakself.schMsgTable.headRefreshControl endRefreshingWithAlertText:@"已为你加载最新数据~" completion:^{}];
|
||
![]()
2 years ago
|
[weakself.schMsgTable.footRefreshControl endRefreshing];
|
||
![]()
2 years ago
|
|
||
|
for (NSDictionary *dic in obj.records)
|
||
|
{
|
||
![]()
2 years ago
|
if (weakself.viewType == 0)
|
||
|
{
|
||
![]()
2 years ago
|
SchModel *model = [SchModel yy_modelWithJSON:dic];
|
||
![]()
2 years ago
|
[self.modelListArr addObject:model];
|
||
|
}
|
||
|
else
|
||
|
{
|
||
![]()
2 years ago
|
JobModel *model = [JobModel yy_modelWithJSON:dic];
|
||
![]()
2 years ago
|
[self.modelListArr addObject:model];
|
||
|
}
|
||
![]()
2 years ago
|
}
|
||
![]()
2 years ago
|
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]];
|
||
|
}];
|
||
|
}
|
||
|
|
||
![]()
2 years ago
|
|
||
|
#pragma mark 消息已读
|
||
|
/// 消息已读
|
||
|
- (void)setMessageRead:(id)Models IndexPath:(NSIndexPath *_Nonnull)indexPath
|
||
|
{
|
||
|
[UICommon MessageUpload:@"加载中"];
|
||
|
NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
|
||
|
NSString *url;
|
||
|
if (self.viewType == 0)
|
||
|
{
|
||
|
SchModel *schModel = Models;
|
||
|
url = F(@"%@%@", IsReade_GET_URL,schModel.noticeId);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
JobModel *jobModel = Models;
|
||
|
url = HomeworkIsReade_GET_URL;
|
||
|
[parameters setValue:jobModel.Id forKey:@"homeWorkId"];
|
||
|
[parameters setValue:APIManager.sharedManager.userModel.userId forKey:@"stuOrFatherId"];
|
||
|
}
|
||
|
[[[APIManager sharedManager] APGET:url parameters:parameters resultClass:BaseModel.class] subscribeNext:^(id _Nullable x) {
|
||
|
[UICommon HidenLoading];
|
||
|
|
||
|
for (int i = 0; i < self.modelListArr.count; i++)
|
||
|
{
|
||
|
if (self.viewType == 0)
|
||
|
{
|
||
|
SchModel *schModel = Models;
|
||
|
|
||
|
SchModel *model = self.modelListArr[i];
|
||
|
if (model.noticeId == schModel.noticeId)
|
||
|
{
|
||
|
[self.modelListArr removeObject:model];
|
||
|
schModel.sendReadStatus = 3;
|
||
|
[self.modelListArr replaceObjectAtIndex:i withObject:schModel];
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
JobModel *jobModel = Models;
|
||
|
|
||
|
JobModel *model = self.modelListArr[i];
|
||
|
if (model.Id == jobModel.Id)
|
||
|
{
|
||
|
[self.modelListArr removeObject:model];
|
||
|
jobModel.receiveStatus = 3;
|
||
|
[self.modelListArr replaceObjectAtIndex:i withObject:jobModel];
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
[self.schMsgTable reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath, nil] withRowAnimation:UITableViewRowAnimationNone];
|
||
|
|
||
|
} error:^(NSError * _Nullable error) {
|
||
|
NSDictionary *dic = error.userInfo;
|
||
|
[UICommon MessageErrorText:dic[NSLocalizedDescriptionKey]];
|
||
|
}];
|
||
|
}
|
||
|
|
||
![]()
2 years ago
|
/*
|
||
|
#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
|