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.
 
 
 

163 lines
4.8 KiB

//
// MessageViewController.m
// LekangGuard
//
// Created by ecell on 2022/12/28.
//
#import "MessageViewController.h"
#import "MCPageView.h"
#import "RemindMessageViewController.h"
#import "AttentionMessageViewController.h"
#import "SystermMessageViewController.h"
#import "CallMessageViewController.h"
@interface MessageViewController ()<MCPageViewDelegate>
@property (nonatomic , strong) MCPageView * PageView;
@property (nonatomic ,strong) NSMutableArray *controllers;
@end
@implementation MessageViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.zx_navTitle = GJText(@"设备消息");
self.controllers = [NSMutableArray array];
[self zx_setRightBtnWithImg:ImageName_(@"icon_delect_1") clickedBlock:^(ZXNavItemBtn * _Nonnull btn) {
[self setDeleteModel];
}];
NSMutableArray *titles = [NSMutableArray array];
[titles addObject:GJText(@"提醒")];
[titles addObject:GJText(@"通知")];
RemindMessageViewController *vc = [RemindMessageViewController new];
SystermMessageViewController *vc2 = [SystermMessageViewController new];
[self.controllers addObject:vc];
[self.controllers addObject:vc2];
self.PageView = [[MCPageView alloc]initWithFrame:CGRectMake(0, iPhoneX_NavHeight, SCREEN_WIDTH,SCREEN_HEIGHT-iPhoneX_NavHeight) titles:titles controllers:self.controllers];
self.PageView.delegate = self;
//self.PageView.titleButtonWidth = Adapted(94);
self.PageView.backgroundColor = KKWhiteColorColor;
self.PageView.lineWitdhScale = 0.65;
self.PageView.lineColor = KKMainColor;
self.PageView.selectTitleFont = FontBoldADA_(16);
self.PageView.defaultTitleFont = FontADA_(14);
self.PageView.defaultTitleColor = KKTextBlackColor;
self.PageView.selectTitleColor = KKMainColor;
self.PageView.lastItemBackgroundColor = KKClearColor;
[self.view addSubview:self.PageView];
[self zx_setPopGestureCompatibleScrollViews:@[self.PageView.titleScroll,self.PageView.contentCollection]];
[self.PageView selectIndex:self.selectedIndex];
[[[NSNotificationCenter defaultCenter] rac_addObserverForName:KK_UPDATE_ALL_NEWS_MESSAGE object:nil] subscribeNext:^(NSNotification *x) {
[self GetUnReadTotal];
}];
}
-(void)setDeleteModel
{
if (self.selectedIndex == 0)
{
RemindMessageViewController *vc = self.controllers[0];
[vc deletAction];
}
else if (self.selectedIndex == 1)
{
SystermMessageViewController *vc = self.controllers[1];
[vc deletAction];
}
}
- (void)updataSystermMessage
{
SystermMessageViewController *vc = self.controllers[1];
[vc GetNotifyList:TableisReload_h];
}
- (void)updataRemindMessage
{
RemindMessageViewController *vc = self.controllers[0];
[vc GetRemindList:TableisReload_h];
}
- (void)MCPageView:(MCPageView *)MCPageView didSelectIndex:(NSInteger)Index
{
NSLog(@"%ld",Index);
//MarketEntrustTableView *vc = self.controllers[Index];
self.selectedIndex = Index;
//self.viewPage = Index;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self GetUnReadTotal];
}
#pragma mark 查询未读消息数
/// 查询未读消息数
- (void)GetUnReadTotal
{
kWeakSelf(self)
[UICommon MessageUpload:@"加载中"];
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) {
NSInteger total = [obj[@"total"] integerValue];
NSInteger type = [obj[@"type"] integerValue];
[weakself.PageView setBadgeWithIndex:type-1 badge:total];
}];
}
} 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
/*
#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.
}
*/