1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- //
- // AppDelegate.m
- // SLAiELTS
- //
- // Created by Gusont on 2023/2/27.
- //
- #import "AppDelegate.h"
- #import "IQKeyboardManager.h"
- #import "SLLoginVCViewController.h"
- #import "SLBaseTabBarController.h"
- #import "SLRoleLabelViewController.h"
- @interface AppDelegate ()
- @end
- @implementation AppDelegate
- - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
- // Override point for customization after application launch.
- self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
- self.window.backgroundColor = [UIColor whiteColor];
- UIViewController *launchScreenVc = [[UIStoryboard storyboardWithName:@"LaunchScreen" bundle:nil] instantiateInitialViewController];
- self.window.rootViewController = launchScreenVc;
- // [SLHttpCenter SharedInstance].serverUrl = @"http://dlchat.zheke.com";
- // [SLHttpCenter SharedInstance].webSocketUrl = @"ws://dlchat.zheke.com/api/Chat/WebSocketConnect";
- [SLHttpCenter SharedInstance].serverUrl = @"http://115.238.47.235:8995";
- [SLHttpCenter SharedInstance].webSocketUrl = @"ws://115.238.47.235:8995/api/Chat/WebSocketConnect";
- // [SLHttpCenter SharedInstance].serverUrl = @"http://10.0.0.14:8088";
- NSString *userPhone = [[NSUserDefaults standardUserDefaults] objectForKey:@"SLUserPhone"];
- NSString *userPassword = [[NSUserDefaults standardUserDefaults] objectForKey:@"SLUserPassword"];
- if (userPhone.length && userPassword.length) {
- NSMutableDictionary *parameter = [NSMutableDictionary dictionaryWithDictionary:@{@"phone" : userPhone, @"password" : userPassword, @"code" : @"0", @"deviceBrand" : @"iPhone", @"deviceModel" : [NSString deviceModel]}];
- [self cacheLoginWhit:parameter];
- }else {
- [self setLoginVcWithRootWindow];
- }
- [self buildIQkeyBoard];
- return YES;
- }
- - (void)cacheLoginWhit:(NSDictionary *)parameter {
- [[SLHttpCenter SharedInstance] postWithUrl:@"/api/Token/LoginApp" parameter:parameter success:^(id responseObject) {
- NSDictionary *dataDict = [responseObject objectForKey:@"data"];
- SLLoginInfo *loginModel = [SLLoginInfo mj_objectWithKeyValues:dataDict];
- [SLGlobalInfo SharedInstance].loginInfo = loginModel;
- [SLUserModel requestUserRoleModel];
- if (!loginModel.isAiData) {
- [self setLoginVcWithRootWindow];
- }else {
- [self setTabWithRootWindow];
- }
- } failure:^(SPRequestError *error) {
- [self setLoginVcWithRootWindow];
- }];
- }
- - (void)setTabWithRootWindow {
- SLBaseTabBarController *tabBarContr = [[SLBaseTabBarController alloc] init];
- self.window.rootViewController = [[SLBaseNavigationController alloc] initWithRootViewController:tabBarContr];;
- [self.window makeKeyAndVisible];
- }
- - (void)setLoginVcWithRootWindow {
- [[NSUserDefaults standardUserDefaults] setObject:@"" forKey:@"SLUserPassword"];
- [[NSUserDefaults standardUserDefaults] synchronize];
- UIViewController *vc = [SLLoginVCViewController loadViewControllewWithNib];
- self.window.rootViewController = [[SLBaseNavigationController alloc] initWithRootViewController:vc];;
- [self.window makeKeyAndVisible];
- }
- #pragma MARK- IQ键盘初始化
- -(void)buildIQkeyBoard
- {
- IQKeyboardManager *manager = [IQKeyboardManager sharedManager];
- manager.enable = YES;//是否启用键盘管理
- manager.shouldResignOnTouchOutside = YES;//点击可编辑之外,是否自动隐藏键盘
- manager.enableAutoToolbar = NO;//控制是否显示键盘上的工具条
- manager.keyboardDistanceFromTextField = 20.f;
- manager.layoutIfNeededOnUpdate = YES;
- }
- @end
|