AppDelegate.mm 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. //
  2. // AppDelegate.m
  3. // SLAiELTS
  4. //
  5. // Created by Gusont on 2023/2/27.
  6. //
  7. #import "AppDelegate.h"
  8. #import "IQKeyboardManager.h"
  9. #import "SLLoginVCViewController.h"
  10. #import "SLBaseTabBarController.h"
  11. #import "SLRoleLabelViewController.h"
  12. @interface AppDelegate ()
  13. @end
  14. @implementation AppDelegate
  15. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  16. // Override point for customization after application launch.
  17. self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  18. self.window.backgroundColor = [UIColor whiteColor];
  19. UIViewController *launchScreenVc = [[UIStoryboard storyboardWithName:@"LaunchScreen" bundle:nil] instantiateInitialViewController];
  20. self.window.rootViewController = launchScreenVc;
  21. // [SLHttpCenter SharedInstance].serverUrl = @"http://dlchat.zheke.com";
  22. // [SLHttpCenter SharedInstance].webSocketUrl = @"ws://dlchat.zheke.com/api/Chat/WebSocketConnect";
  23. [SLHttpCenter SharedInstance].serverUrl = @"http://115.238.47.235:8995";
  24. [SLHttpCenter SharedInstance].webSocketUrl = @"ws://115.238.47.235:8995/api/Chat/WebSocketConnect";
  25. // [SLHttpCenter SharedInstance].serverUrl = @"http://10.0.0.14:8088";
  26. NSString *userPhone = [[NSUserDefaults standardUserDefaults] objectForKey:@"SLUserPhone"];
  27. NSString *userPassword = [[NSUserDefaults standardUserDefaults] objectForKey:@"SLUserPassword"];
  28. if (userPhone.length && userPassword.length) {
  29. NSMutableDictionary *parameter = [NSMutableDictionary dictionaryWithDictionary:@{@"phone" : userPhone, @"password" : userPassword, @"code" : @"0", @"deviceBrand" : @"iPhone", @"deviceModel" : [NSString deviceModel]}];
  30. [self cacheLoginWhit:parameter];
  31. }else {
  32. [self setLoginVcWithRootWindow];
  33. }
  34. [self buildIQkeyBoard];
  35. return YES;
  36. }
  37. - (void)cacheLoginWhit:(NSDictionary *)parameter {
  38. [[SLHttpCenter SharedInstance] postWithUrl:@"/api/Token/LoginApp" parameter:parameter success:^(id responseObject) {
  39. NSDictionary *dataDict = [responseObject objectForKey:@"data"];
  40. SLLoginInfo *loginModel = [SLLoginInfo mj_objectWithKeyValues:dataDict];
  41. [SLGlobalInfo SharedInstance].loginInfo = loginModel;
  42. [SLUserModel requestUserRoleModel];
  43. if (!loginModel.isAiData) {
  44. [self setLoginVcWithRootWindow];
  45. }else {
  46. [self setTabWithRootWindow];
  47. }
  48. } failure:^(SPRequestError *error) {
  49. [self setLoginVcWithRootWindow];
  50. }];
  51. }
  52. - (void)setTabWithRootWindow {
  53. SLBaseTabBarController *tabBarContr = [[SLBaseTabBarController alloc] init];
  54. self.window.rootViewController = [[SLBaseNavigationController alloc] initWithRootViewController:tabBarContr];;
  55. [self.window makeKeyAndVisible];
  56. }
  57. - (void)setLoginVcWithRootWindow {
  58. [[NSUserDefaults standardUserDefaults] setObject:@"" forKey:@"SLUserPassword"];
  59. [[NSUserDefaults standardUserDefaults] synchronize];
  60. UIViewController *vc = [SLLoginVCViewController loadViewControllewWithNib];
  61. self.window.rootViewController = [[SLBaseNavigationController alloc] initWithRootViewController:vc];;
  62. [self.window makeKeyAndVisible];
  63. }
  64. #pragma MARK- IQ键盘初始化
  65. -(void)buildIQkeyBoard
  66. {
  67. IQKeyboardManager *manager = [IQKeyboardManager sharedManager];
  68. manager.enable = YES;//是否启用键盘管理
  69. manager.shouldResignOnTouchOutside = YES;//点击可编辑之外,是否自动隐藏键盘
  70. manager.enableAutoToolbar = NO;//控制是否显示键盘上的工具条
  71. manager.keyboardDistanceFromTextField = 20.f;
  72. manager.layoutIfNeededOnUpdate = YES;
  73. }
  74. @end