| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 |
- //
- // MainTabVC.m
- // IBOSS
- //
- // Created by iHope on 14-6-5.
- // Copyright (c) 2017年 沈阳东科云信软件有限公司. All rights reserved.
- //
- #import "MainTabVC.h"
- #import "BusinessInfoViewController.h"
- #import "UITabBar+badge.h"
- @interface MainTabVC ()
- @end
- // MainTabVC对象
- static MainTabVC *gHomeCtrl = nil;
- @implementation MainTabVC
- #pragma 公共函数
- /**
- 初始化
-
- @param nibNameOrNil <#nibNameOrNil description#>
- @param nibBundleOrNil <#nibBundleOrNil description#>
- @return <#return value description#>
- */
- - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
- {
- self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
- if (self) {
- gHomeCtrl = self;
- }
- return self;
- }
- /**
- uicontroller
-
- @return <#return value description#>
- */
- + (UIViewController *)mRootCtrl {
- return gHomeCtrl;
- }
- /**
- viewDidLoad事件
- */
- - (void)viewDidLoad
- {
- [super viewDidLoad];
- // 业务处理
- self.businessvc = [[BusinessInfoViewController alloc] init];
- self.businessnavvc = [[BusinessNavVC alloc]initWithRootViewController:self.businessvc];
- self.businessnavvc.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName: [UIColor whiteColor],NSFontAttributeName : [UIFont boldSystemFontOfSize:16]};
- self.businessnavvc.navigationBar.barTintColor = NavigationBarTintColor;
- self.businessnavvc.navigationBar.translucent=NO;
- [self.businessnavvc.navigationBar setBackgroundImage:[UIImage new] forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
- UITabBarItem *messageItem= [[UITabBarItem alloc] initWithTitle: @"业务处理" image: nil tag: 0];
-
- messageItem.image= [UIImage imageNamed:@"icon_business@2x.png"];
-
- UIImage *businessPressedImg= [UIImage imageNamed:@"icon_business_pressed@2x.png"];
- businessPressedImg = [businessPressedImg imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
- [messageItem setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor colorWithRed:0.654 green:0 blue:0.027 alpha:1]} forState:UIControlStateSelected];
- messageItem.selectedImage= businessPressedImg;
- self.businessnavvc.tabBarItem = messageItem;
-
- //服务回执
- self.receiptvc = [[ReceiptInfoViewController alloc] init];
- self.receiptnavvc = [[ReceiptNavVC alloc]initWithRootViewController:self.receiptvc];
- self.receiptnavvc.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName: [UIColor whiteColor],NSFontAttributeName : [UIFont boldSystemFontOfSize:16]};
- self.receiptnavvc.navigationBar.barTintColor = NavigationBarTintColor;
- self.receiptnavvc.navigationBar.translucent=NO;
- [self.receiptnavvc.navigationBar setShadowImage:[UIImage new]];
- [self.receiptnavvc.navigationBar setBackgroundImage:[UIImage new] forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
- UITabBarItem *receiptItem= [[UITabBarItem alloc] initWithTitle: @"服务回执" image: nil tag: 0];
-
- receiptItem.image= [UIImage imageNamed:@"receipt"];
-
- UIImage *receiptPressedImg= [UIImage imageNamed:@"receipt_pressed"];
- receiptPressedImg = [receiptPressedImg imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
- [receiptItem setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor colorWithRed:0.654 green:0 blue:0.027 alpha:1]} forState:UIControlStateSelected];
- receiptItem.selectedImage= receiptPressedImg;
- self.receiptnavvc.tabBarItem = receiptItem;
-
-
- // 业务报表
- self.reportvc = [[ReportInfoViewController alloc] init];
- self.reportnavvc = [[ReportNavVC alloc] initWithRootViewController: self.reportvc];
- self.reportnavvc.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName: [UIColor whiteColor],NSFontAttributeName : [UIFont boldSystemFontOfSize:16]};
- self.reportnavvc.navigationBar.barTintColor = NavigationBarTintColor;
- self.reportnavvc.navigationBar.translucent=NO;
- [self.reportnavvc.navigationBar setShadowImage:[UIImage new]];
- [self.reportnavvc.navigationBar setBackgroundImage:[UIImage new] forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
- UITabBarItem *customerItem = [[UITabBarItem alloc] initWithTitle: @"业务报表" image: nil tag: 1];
- customerItem.image = [UIImage imageNamed:@"icon_report@2x.png"];
- UIImage *reportPressedImg= [UIImage imageNamed:@"icon_report_pressed@2x.png"];
- reportPressedImg = [reportPressedImg imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
- [customerItem setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor colorWithRed:0.654 green:0 blue:0.027 alpha:1]} forState:UIControlStateSelected];
- customerItem.selectedImage=reportPressedImg;
- self.reportvc.tabBarItem = customerItem;
-
- // 我的
- self.setvc = [[SettingViewController alloc] init];
- self.minenavvc = [[MineInfoNavVC alloc]initWithRootViewController:self.setvc];
- self.minenavvc.navigationBar.translucent=NO;
- [self.minenavvc.navigationBar setShadowImage:[UIImage new]];
- [self.minenavvc.navigationBar setBackgroundImage:[UIImage new] forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
- self.minenavvc.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName: [UIColor whiteColor],NSFontAttributeName : [UIFont boldSystemFontOfSize:16]};
- self.minenavvc.navigationBar.barTintColor = NavigationBarTintColor;
- UITabBarItem *moreinfoItem= [[UITabBarItem alloc] initWithTitle: @"我的" image: nil tag: 2];
-
- moreinfoItem.image = [UIImage imageNamed:@"icon_mine@2x.png"];
- UIImage *minePressedImg= [UIImage imageNamed:@"icon_mine_pressed@2x.png"];
- minePressedImg = [minePressedImg imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
- [moreinfoItem setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor colorWithRed:0.654 green:0 blue:0.027 alpha:1]} forState:UIControlStateSelected];
- moreinfoItem.selectedImage=minePressedImg;
- self.minenavvc.tabBarItem = moreinfoItem;
- [[UITabBar appearance] setBarTintColor:[UIColor whiteColor]];
- NSArray *array = [NSArray arrayWithObjects:self.businessnavvc,self.receiptnavvc,self.reportnavvc,self.minenavvc,nil];
- self.viewControllers = array;
- NSString *currentDate= [DateFormat getCurrentDate];
-
- if([kkCurrentDate isEqualToString:@""]||kkCurrentDate==nil)
-
- {
- if(kkOldAmountValue!=nil&&kkOldAmountValue.length>0)
- {
- self.selectedIndex = 3;
- kkCurrentDate=currentDate;
- }
-
- else
- {
- self.selectedIndex = 0;
- }
- }
- else
- {
- if([currentDate isEqualToString:kkCurrentDate])
- {
- self.selectedIndex = 0;
- }
- else{
- self.selectedIndex = 3;
- }
- kkCurrentDate=currentDate;
- }
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(notificationHandler:) name:@"approveChange" object:nil];
- [self getApproveCount];
- }
- /**
- didReceiveMemoryWarning事件
- */
- - (void)didReceiveMemoryWarning
- {
- [super didReceiveMemoryWarning];
- }
- //!!!重点在viewWillAppear方法里调用下面两个方法
- -(void)viewWillAppear:(BOOL)animated{
- [self preferredStatusBarStyle];
- [self setStatusBarBackgroundColor:NavigationBarColor];
- }
- //设置状态栏颜色
- - (void)setStatusBarBackgroundColor:(UIColor *)color {
- self.selectedIndex = 3;
- if (@available(iOS 13.0, *)) {
- // iOS 13 弃用keyWindow属性 从所有windowl数组中取
- UIView *statusBar = [[UIView alloc]initWithFrame:[UIApplication sharedApplication].keyWindow.windowScene.statusBarManager.statusBarFrame] ;
- statusBar.backgroundColor = color;
- [[UIApplication sharedApplication].keyWindow addSubview:statusBar];
- } else{
- UIView *statusBar = [[[UIApplication sharedApplication] valueForKey:@"statusBarWindow"] valueForKey:@"statusBar"];
- if ([statusBar respondsToSelector:@selector(setBackgroundColor:)]) {
- statusBar.backgroundColor = color;
- }
- }
- self.selectedIndex = 0;
- }
- - (void)setNeedsStatusBarAppearanceUpdate{
- [super setNeedsStatusBarAppearanceUpdate];
- }
- //设置状态栏的白色
- -(UIStatusBarStyle)preferredStatusBarStyle
- {
- return UIStatusBarStyleLightContent;
- }
- #pragma 委托函数
- /**
- 数据加载成功函数
-
- @param sender <#sender description#>
- */
- - (void)onLoadFinish:(ASIDownManager *)sender {
- RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:sender.mWebStr];
- int status= resultModel.status;
- NSString *message=resultModel.message;
- if(status==0){
- NSArray *arrResult=(NSArray*)resultModel.result;
- if(arrResult.count==0){
- [self.tabBar hideBadgeOnItemIndex:0];
- }
- else{
- [self.tabBar showBadgeOnItemIndex:0];
- }
- }
-
- }
- /**
- 数据加载失败函数
- @param sender sender description
- */
- - (void)onLoadFail:(ASIDownManager *)sender{
- [self showAlertViewText:@"网络异常"];
- }
- #pragma 私有函数
- /**
- 加载审批数据
- */
- - (void)getApproveCount{
- self.mDownManager = [[ASIDownManager alloc] init];
- _mDownManager.delegate = self;
- _mDownManager.onRequestSuccess = @selector(onLoadFinish:);
- _mDownManager.onRequestFail = @selector(onLoadFail:);
- NSString *urlStr = ServerURL;
- NSMutableDictionary *dict = [NSMutableDictionary dictionary];
- [dict setObject:@"GetAuditList" forKey:@"Action"];
- [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"];
- [dict setObject:kkUserCode forKey:@"UserCode"];
- [dict setObject:kkUserPwd forKey:@"UserPassword"];
- [dict setObject:kkSessionKey forKey:@"SessionKey"];
- [_mDownManager postHttpRequest:urlStr dic:dict path:nil fileName:nil];
-
- }
- /**
- 显示消息
-
- @param text <#text description#>
- */
- - (void)showAlertViewText:(NSString *)text
- {
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:text preferredStyle:UIAlertControllerStyleAlert ];
- [alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){
-
- }]];
- // 3.显示alertController:presentViewController
- [self presentViewController:alert animated:YES completion:nil];
- }
- /**
- 自定义接收信息和处理的方法
- @param notification <#notification description#>
- */
- - (void) notificationHandler:(NSNotification *) notification{
-
- [self getApproveCount];
-
- }
- @end
|