|
|
|
//
|
|
|
|
// TabMessageViewController.m
|
|
|
|
// LekangGuard
|
|
|
|
//
|
|
|
|
// Created by ecell on 2023/6/7.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import "TabMessageViewController.h"
|
|
|
|
#import "TabMessageTableViewCell.h"
|
|
|
|
#import "MessageViewController.h"
|
|
|
|
#import "SchAndJobMessageViewController.h"
|
|
|
|
#import "ReadFlowerViewController.h"
|
|
|
|
|
|
|
|
@interface TabMessageViewController ()
|
|
|
|
|
|
|
|
@property (nonatomic ,strong) CommonTableView *msgTable;
|
|
|
|
|
|
|
|
@property (nonatomic ,strong) NSArray *titleArr;
|
|
|
|
@property (nonatomic ,strong) NSArray *imageArr;
|
|
|
|
|
|
|
|
@property (nonatomic ,strong) NSMutableArray *msgNumArr;
|
|
|
|
|
|
|
|
@property (nonatomic ,strong) NSNumber *msgTotalCount;///消息未读总数
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation TabMessageViewController
|
|
|
|
|
|
|
|
- (void)viewDidLoad {
|
|
|
|
[super viewDidLoad];
|
|
|
|
// Do any additional setup after loading the view.
|
|
|
|
self.zx_navTitle = @"消息";
|
|
|
|
self.view.backgroundColor = KKBackgroundGrey;
|
|
|
|
self.titleArr = @[@"校园通知",@"班级作业",@"设备消息",@"小红花"];
|
|
|
|
self.imageArr = @[@"msg_sch_icon",@"msg_job_icon",@"msg_device_icon",@"msg_device_icon"];
|
|
|
|
[self.view addSubview:self.msgTable];
|
|
|
|
[self.msgTable mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
make.left.right.equalTo(self.view);
|
|
|
|
make.top.equalTo(self.view).offset(iPhoneX_NavHeight);
|
|
|
|
make.bottom.equalTo(self.view);
|
|
|
|
}];
|
|
|
|
|
|
|
|
[[[NSNotificationCenter defaultCenter] rac_addObserverForName:@"XIAOHONGHUA" object:nil] subscribeNext:^(NSNotification *x) {
|
|
|
|
[self getHomeWorkCount];
|
|
|
|
[self getReadFlowerCount];
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (CommonTableView *)msgTable
|
|
|
|
{
|
|
|
|
if (!_msgTable)
|
|
|
|
{
|
|
|
|
|
|
|
|
_msgTable = [[CommonTableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain cellHeight:80 cellRow:self.titleArr.count isAdaptive:NO isLine:NO commonCell:TabMessageTableViewCell.class createCell:^(ZZTableViewCell * _Nonnull cells, NSIndexPath * _Nonnull indexPath) {
|
|
|
|
TabMessageTableViewCell *cell = (TabMessageTableViewCell *)cells;
|
|
|
|
cell.titleStr = self.titleArr[indexPath.row];
|
|
|
|
cell.imageStr = self.imageArr[indexPath.row];
|
|
|
|
cell.msgTotalCount = self.msgNumArr[indexPath.row];
|
|
|
|
|
|
|
|
} selectedCell:^(UITableView * _Nonnull tableView, NSIndexPath * _Nonnull indexPath) {
|
|
|
|
if (indexPath.row < 2)
|
|
|
|
{
|
|
|
|
SchAndJobMessageViewController *vc = [[SchAndJobMessageViewController alloc] init];
|
|
|
|
vc.navTitle = self.titleArr[indexPath.row];
|
|
|
|
vc.viewType = indexPath.row;
|
|
|
|
[self.navigationController pushViewController:vc animated:YES];
|
|
|
|
}
|
|
|
|
else if (indexPath.row == 2)
|
|
|
|
{
|
|
|
|
MessageViewController *vc = [MessageViewController new];
|
|
|
|
vc.selectedIndex = 0;
|
|
|
|
[self.navigationController pushViewController:vc animated:YES];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ReadFlowerViewController *vc = [[ReadFlowerViewController alloc] init];
|
|
|
|
[self.navigationController pushViewController:vc animated:YES];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} DidscrollView:^(UIScrollView * _Nonnull scrollView) {
|
|
|
|
|
|
|
|
}];
|
|
|
|
_msgTable.backgroundColor = KKClearColor;
|
|
|
|
}
|
|
|
|
return _msgTable;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)viewWillAppear:(BOOL)animated
|
|
|
|
{
|
|
|
|
[super viewWillAppear:animated];
|
|
|
|
[self getHomeWorkCount];
|
|
|
|
[self getUnReadTotal];
|
|
|
|
[self getReadFlowerCount];
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark 查询未读作业总数
|
|
|
|
/// 查询未读作业总数
|
|
|
|
- (void)getHomeWorkCount
|
|
|
|
{
|
|
|
|
kWeakSelf(self)
|
|
|
|
NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
|
|
|
|
[[[APIManager sharedManager] APGET:HomeWorkCount_GET_URL parameters:parameters resultClass:nil] subscribeNext:^(id _Nullable x) {
|
|
|
|
[UICommon HidenLoading];
|
|
|
|
NSNumber *campusCount = x[@"campusCount"];
|
|
|
|
NSNumber *homeWokeCount = x[@"homeWokeCount"];
|
|
|
|
[weakself.msgNumArr replaceObjectAtIndex:0 withObject:campusCount];
|
|
|
|
[weakself.msgNumArr replaceObjectAtIndex:1 withObject:homeWokeCount];
|
|
|
|
[weakself.msgTable reloadData];
|
|
|
|
} error:^(NSError * _Nullable error) {
|
|
|
|
NSDictionary *dic = error.userInfo;
|
|
|
|
[UICommon MessageErrorText:dic[NSLocalizedDescriptionKey]];
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark 查询未读消息数
|
|
|
|
/// 查询未读消息数
|
|
|
|
- (void)getUnReadTotal
|
|
|
|
{
|
|
|
|
kWeakSelf(self)
|
|
|
|
NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
|
|
|
|
[[[APIManager sharedManager] APGET:UnReadTotal_URL parameters:parameters resultClass:nil] subscribeNext:^(NSArray *arr) {
|
|
|
|
[UICommon HidenLoading];
|
|
|
|
if (ARRAYHASVALUE(arr))
|
|
|
|
{
|
|
|
|
[arr enumerateObjectsUsingBlock:^(NSDictionary *obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
|
|
|
weakself.msgTotalCount = obj[@"total"];
|
|
|
|
|
|
|
|
}];
|
|
|
|
[weakself.msgNumArr replaceObjectAtIndex:2 withObject:weakself.msgTotalCount];
|
|
|
|
[weakself.msgTable reloadData];
|
|
|
|
}
|
|
|
|
} error:^(NSError * _Nullable error) {
|
|
|
|
NSDictionary *dic = error.userInfo;
|
|
|
|
[UICommon MessageErrorText:dic[NSLocalizedDescriptionKey]];
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark 查询小红花未读总数
|
|
|
|
/// 查询小红花未读总数
|
|
|
|
- (void)getReadFlowerCount
|
|
|
|
{
|
|
|
|
kWeakSelf(self)
|
|
|
|
NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
|
|
|
|
[[[APIManager sharedManager] APGET:ReadFlowerCount_GET_URL parameters:parameters resultClass:nil] subscribeNext:^(id _Nullable x) {
|
|
|
|
[UICommon HidenLoading];
|
|
|
|
NSNumber *redTotalCount = x[@"totalCount"];
|
|
|
|
[weakself.msgNumArr replaceObjectAtIndex:3 withObject:redTotalCount];
|
|
|
|
[weakself.msgTable reloadData];
|
|
|
|
} error:^(NSError * _Nullable error) {
|
|
|
|
NSDictionary *dic = error.userInfo;
|
|
|
|
[UICommon MessageErrorText:dic[NSLocalizedDescriptionKey]];
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (NSMutableArray *)msgNumArr
|
|
|
|
{
|
|
|
|
if (!_msgNumArr)
|
|
|
|
{
|
|
|
|
_msgNumArr = [NSMutableArray new];
|
|
|
|
[_msgNumArr addObject:@"0"];
|
|
|
|
[_msgNumArr addObject:@"0"];
|
|
|
|
[_msgNumArr addObject:@"0"];
|
|
|
|
[_msgNumArr addObject:@"0"];
|
|
|
|
}
|
|
|
|
return _msgNumArr;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
#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
|