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.
153 lines
5.4 KiB
153 lines
5.4 KiB
1 year ago
|
//
|
||
|
// MyChildViewController.m
|
||
|
// LekangGuard
|
||
|
//
|
||
|
// Created by ecell on 2023/7/27.
|
||
|
//
|
||
|
|
||
|
#import "MyChildViewController.h"
|
||
|
#import "CommMessageTableViewCell.h"
|
||
|
#import "CommMessageDetailsViewController.h"
|
||
|
|
||
|
@interface MyChildViewController ()<DZNEmptyDataSetSource,DZNEmptyDataSetDelegate>
|
||
|
|
||
|
|
||
|
@property (nonatomic ,strong) CommonTableView *msgTable;
|
||
|
|
||
|
@property (nonatomic ,assign) NSInteger page;
|
||
|
|
||
|
@end
|
||
|
|
||
|
@implementation MyChildViewController
|
||
|
|
||
|
- (void)viewDidLoad {
|
||
|
[super viewDidLoad];
|
||
|
// Do any additional setup after loading the view.
|
||
|
|
||
|
self.page = 1;
|
||
|
self.view.backgroundColor = KKBackgroundGrey;
|
||
|
[self.view addSubview:self.msgTable];
|
||
|
[self.msgTable mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
make.edges.equalTo(self.view);
|
||
|
}];
|
||
|
[UICommon MessageUpload:@"加载中"];
|
||
|
[self getMessageList:TableisReload_h];
|
||
|
}
|
||
|
|
||
|
- (CommonTableView *)msgTable
|
||
|
{
|
||
|
if (!_msgTable)
|
||
|
{
|
||
|
kWeakSelf(self)
|
||
|
_msgTable = [[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;
|
||
|
cell.redModel = self.modelListArr[indexPath.row];
|
||
|
|
||
|
} selectedCell:^(UITableView * _Nonnull tableView, NSIndexPath * _Nonnull indexPath) {
|
||
|
RedFlowerModel *redModel = self.modelListArr[indexPath.row];
|
||
|
if (redModel.receiveStatus == 0)
|
||
|
[weakself setMessageRead:redModel IndexPath:indexPath];
|
||
|
|
||
|
} DidscrollView:^(UIScrollView * _Nonnull scrollView) {
|
||
|
|
||
|
}];
|
||
|
_msgTable.backgroundColor = KKClearColor;
|
||
|
_msgTable.emptyDataSetSource = self;
|
||
|
_msgTable.emptyDataSetDelegate = self;
|
||
|
[_msgTable bindHeadRefreshHandler:^{
|
||
|
[UICommon feedbackGenerator];
|
||
|
[weakself getMessageList:TableisReload_h];
|
||
|
} themeColor:KKMainColor refreshStyle:KafkaRefreshStyleReplicatorWoody];
|
||
|
|
||
|
[_msgTable bindFootRefreshHandler:^{
|
||
|
[weakself getMessageList:TableisReload_f];
|
||
|
} themeColor:KKMainColor refreshStyle:KafkaRefreshStyleReplicatorWoody];
|
||
|
|
||
|
}
|
||
|
return _msgTable;
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
#pragma mark 获取校园通知
|
||
|
/// 获取校园通知
|
||
|
- (void)getMessageList:(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"];
|
||
|
[parameters setValue:@(1) forKey:@"flag"];
|
||
|
[[[APIManager sharedManager] APGET:ReadFlowerList_GET_URL parameters:parameters resultClass:BaseModel.class] subscribeNext:^(BaseModel *obj) {
|
||
|
[UICommon HidenLoading];
|
||
|
if (ARRAYHASVALUE(obj.records))
|
||
|
{
|
||
|
[weakself.msgTable.headRefreshControl endRefreshingWithAlertText:@"已为你加载最新数据~" completion:^{
|
||
|
|
||
|
}];
|
||
|
[weakself.msgTable.footRefreshControl endRefreshing];
|
||
|
[obj.records enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
||
|
|
||
|
RedFlowerModel *model = [RedFlowerModel yy_modelWithJSON:obj];
|
||
|
[self.modelListArr addObject:model];
|
||
|
|
||
|
}];
|
||
|
weakself.page++;
|
||
|
weakself.msgTable.footRefreshControl.hidden = obj.records.count < KSizeNO ? YES : NO;
|
||
|
weakself.msgTable.cellRow = self.modelListArr.count;
|
||
|
[weakself.msgTable reloadData];
|
||
|
}
|
||
|
|
||
|
|
||
|
} error:^(NSError * _Nullable error) {
|
||
|
NSDictionary *dic = error.userInfo;
|
||
|
[UICommon MessageErrorText:dic[NSLocalizedDescriptionKey]];
|
||
|
}];
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
#pragma mark 消息已读
|
||
|
/// 消息已读
|
||
|
- (void)setMessageRead:(RedFlowerModel *)redModel IndexPath:(NSIndexPath *_Nonnull)indexPath
|
||
|
{
|
||
|
NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
|
||
|
NSString *url = F(@"%@%@", ReadOwnFlowerStatus_GET_URL,redModel.Id);
|
||
|
[[[APIManager sharedManager] APGET:url parameters:parameters resultClass:BaseModel.class] subscribeNext:^(id _Nullable x) {
|
||
|
[UICommon HidenLoading];
|
||
|
for (int i = 0; i < self.modelListArr.count; i++)
|
||
|
{
|
||
|
RedFlowerModel *model = self.modelListArr[i];
|
||
|
if (model.Id == redModel.Id)
|
||
|
{
|
||
|
[self.modelListArr removeObject:model];
|
||
|
redModel.receiveStatus = 1;
|
||
|
[self.modelListArr replaceObjectAtIndex:i withObject:redModel];
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
[self.msgTable reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath, nil] withRowAnimation:UITableViewRowAnimationNone];
|
||
|
|
||
|
} 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
|