| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252 |
- //
- // AppDelegate.m
- // HappyJob
- //
- // Created by Bob on 2019/3/11.
- // Copyright © 2019 Bob. All rights reserved.
- //
- #import "AppDelegate.h"
- #import "HJLoginViewController.h"
- #import "HJMainViewController.h"
- #import "FBNetworkingConfig.h"
- #import "HJWeiXinAPIManager.h"
- #import "HJUserInfoModel.h"
- #import "UIButton+HJGradientButton.h"
- #import <IQKeyboardManager/IQKeyboardManager.h>
- #import <WXApi.h>
- #import <XHLaunchAd/XHLaunchAd.h>
- #import "HJWelcomeViewController.h"
- #import <AMapFoundationKit/AMapFoundationKit.h>
- #import <Bugly/Bugly.h>
- #import "BMainViewController.h"//自发布的
- #import "BReleaseJobsViewController.h"//发布工作
- #import "HJLoginViewController.h"//登录
- @interface AppDelegate () <HJWelcomeViewDelegate,UITabBarControllerDelegate>
- @property (nonatomic, strong) BMainViewController *bTabBarC;//自发布
- @property (nonatomic, strong) HJMainViewController *CTabBarC;
- @property (nonatomic, assign) int lastIndex;//tabBar选中的上一个的视图索引
- @end
- @implementation AppDelegate
- - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
-
- //配置Bugly
- [Bugly startWithAppId:kBuglyAppID];
-
- //配置广告数据
- [self setupAd];
-
- // 高德地图
- [AMapServices sharedServices].apiKey = kGAODEAPIKey;
-
- // 微信授权
- [WXApi registerApp:kWeiXinAPIKey];
-
- // 配置接口调用
- [FBNetworkingConfig sharedConfig].baseURL = kHJBaseURL;
-
- // DDTTYLogger,你的日志语句将被发送到Xcode控制台
- [DDLog addLogger:[DDTTYLogger sharedInstance]];
-
- // 设置键盘监听管理
- IQKeyboardManager *keyboardManager = [IQKeyboardManager sharedManager];
- keyboardManager.toolbarDoneBarButtonItemText = @"完成";
- keyboardManager.shouldResignOnTouchOutside = YES;
-
- self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
- self.window.backgroundColor = [UIColor whiteColor];
- //引导页
- HJWelcomeViewController *welcomeViewController = [[HJWelcomeViewController alloc] init];
- welcomeViewController.delegate = self;
- if (welcomeViewController.isShow)
- {
- self.window.rootViewController = welcomeViewController;
- }
- else
- {
- self.window.rootViewController = [self setupFirstViewController];
- }
- [self.window makeKeyAndVisible];
-
- // //设置状态栏为白色的
- // [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:NO];
- return YES;
- }
- /* iOS 9 之前用 */
- - (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
-
- return [WXApi handleOpenURL:url delegate:[HJWeiXinAPIManager sharedManager]];
- }
- - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
-
- return [WXApi handleOpenURL:url delegate:[HJWeiXinAPIManager sharedManager]];
- }
- /* iOS 9之后用 */
- - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
-
- return [WXApi handleOpenURL:url delegate:[HJWeiXinAPIManager sharedManager]];
- }
- #pragma mark - HJWelcomeViewDelegate
- - (void)skipWelcomeView:(HJWelcomeViewController *)welcomeView {
-
- self.window.rootViewController = [self setupFirstViewController];
- }
- #pragma mark - event response
- - (void)launchStartButtonClicked:(UIButton *)sender {
-
- [XHLaunchAd removeAndAnimated:YES];
- }
- #pragma mark - private methods
- - (UIViewController *)setupFirstViewController {
-
- if ([HJMemberInfoModel memberInfo].memberId == nil || [[HJMemberInfoModel memberInfo].memberId isEqualToString: @""])
- { //c端
- _CTabBarC = [[HJMainViewController alloc] init];
- _CTabBarC.delegate = self;
- return _CTabBarC;
- }
- else
- {
- if (USERTYPE)
- { //自发布
- _bTabBarC = [[BMainViewController alloc]init];
- _bTabBarC.delegate = self;
- return _bTabBarC;
- }
- else
- { //c端
- _CTabBarC = [[HJMainViewController alloc] init];
- _CTabBarC.delegate = self;
- return _CTabBarC;
- }
- }
- }
- /* 推出登录 */
- -(void)pushLoginViewController {
-
- HJLoginViewController *loginVC=[[HJLoginViewController alloc]init];
- UINavigationController *navi=[[UINavigationController alloc]initWithRootViewController:loginVC];
- [self.window.rootViewController presentViewController:navi animated:YES completion:nil];
- }
- /* 切换身份 */
- - (void)switchTabBar {
-
- self.window.rootViewController = [self setupFirstViewController];
- }
- #pragma mark - UITabBarControllerDelegate 代理
- - (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
- {
- if (tabBarController == _bTabBarC)
- {
- if (_bTabBarC.tabBar.selectedItem.tag == 2 && [[HJCompanyInfoModel companyInfo].authenticationStatus integerValue] == 0)
- {//取消tabBar的点击事件
- return NO;
- }
- else
- {
- _lastIndex = (int)tabBarController.selectedIndex;
- return YES;
- }
- }
- else
- {
- _lastIndex = (int)tabBarController.selectedIndex;
- return YES;
- }
- }
- - (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
- {
- if (tabBarController == _bTabBarC)
- {//自发布
- if (tabBarController.selectedIndex == 2)
- {
- if ([[HJCompanyInfoModel companyInfo].authenticationStatus integerValue] == 3 || [[HJCompanyInfoModel companyInfo].authenticationStatus integerValue] == 2 || [[HJCompanyInfoModel companyInfo].authenticationStatus integerValue] == 1)
- {
- tabBarController.selectedIndex = _lastIndex ;
- BReleaseJobsViewController *certification=[[BReleaseJobsViewController alloc]init];
- UINavigationController *navi=[[UINavigationController alloc]initWithRootViewController:certification];
- [self.window.rootViewController presentViewController:navi animated:YES completion:nil];
- }
- else
- {
- tabBarController.selectedIndex = _lastIndex ;
- }
- }
- }
- else
- {
- if ([HJMemberInfoModel memberInfo].memberId == nil || [[HJMemberInfoModel memberInfo].memberId isEqualToString: @""])
- {
- if( tabBarController.selectedIndex == 2 || tabBarController.selectedIndex == 3)
- {
- tabBarController.selectedIndex = _lastIndex ;
- [self pushLoginViewController];
- }
- }
- }
- }
- /* 配置启动页 */
- - (void)setupAd {
-
- //设置你工程的启动页使用的是:LaunchImage 还是 LaunchScreen.storyboard(不设置默认:LaunchImage)
- [XHLaunchAd setLaunchSourceType:SourceTypeLaunchScreen];
-
- CGFloat width = HJHorizontalScale(180);
- CGFloat height = 42;
- UIButton *launchStartButton = [UIButton hj_createGradientButtonWithTitle:@"开启加薪之旅"];
- launchStartButton.titleLabel.font = [UIFont systemFontOfSize:HJHorizontalScale(16)];
- launchStartButton.frame = CGRectMake((SCREEN_WIDTH-width)/2, (SCREEN_HEIGHT-height-90), width, height);
- [launchStartButton addTarget:self action:@selector(launchStartButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
-
- UILabel *launchVersionLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, (SCREEN_HEIGHT-45), SCREEN_WIDTH, 20)];
- launchVersionLabel.text = [NSString stringWithFormat:@"v%@", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]];
- launchVersionLabel.textColor = [UIColor colorWithRed:102/255.0 green:102/255.0 blue:102/255.0 alpha:1.0];
- launchVersionLabel.font = [UIFont systemFontOfSize:11];
- launchVersionLabel.textAlignment = NSTextAlignmentCenter;
-
- XHLaunchImageAdConfiguration *imageAdconfiguration = [XHLaunchImageAdConfiguration defaultConfiguration];
- imageAdconfiguration.duration = 1;
- imageAdconfiguration.subViews = @[launchVersionLabel, launchStartButton];
- imageAdconfiguration.skipButtonType = SkipTypeNone;
- imageAdconfiguration.showFinishAnimate = ShowFinishAnimateLite;
- [XHLaunchAd imageAdWithImageAdConfiguration:imageAdconfiguration delegate:self];
- }
- - (void)applicationWillResignActive:(UIApplication *)application {
-
- }
- - (void)applicationDidEnterBackground:(UIApplication *)application {
-
- }
- - (void)applicationWillEnterForeground:(UIApplication *)application {
-
- }
- - (void)applicationDidBecomeActive:(UIApplication *)application {
-
- }
- - (void)applicationWillTerminate:(UIApplication *)application {
- // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
- }
- @end
|