splash_controller.dart 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. import 'package:get/get.dart';
  2. import 'package:app/jpush/jpush_receive.dart';
  3. import 'package:initializer/app_initializer.dart';
  4. import 'package:plugin_basic/constants/app_constant.dart';
  5. import 'package:plugin_basic/service/app_config_service.dart';
  6. import 'package:plugin_basic/service/user_service.dart';
  7. import 'package:plugin_platform/engine/sp/sp_util.dart';
  8. import 'package:plugin_platform/engine/toast/toast_engine.dart';
  9. import 'package:router/componentRouter/component_router_service.dart';
  10. import 'package:shared/utils/device_utils.dart';
  11. import 'package:shared/utils/log_utils.dart';
  12. import 'package:shared/utils/util.dart';
  13. class SplashController extends GetxController {
  14. @override
  15. void onReady() {
  16. super.onReady();
  17. UserService.to;
  18. _gotoNextPage();
  19. }
  20. }
  21. void _gotoNextPage() async {
  22. // await AppInitializer.delayInitialize(futureTasks: [
  23. // () async {
  24. // await FlutterBugly.init(
  25. // androidAppId: "12345678",
  26. // iOSAppId: "12345678",
  27. // );
  28. // },
  29. // ], normalTasks: [
  30. // () {
  31. // if (DeviceUtils.isIOS || DeviceUtils.isAndroid) {
  32. // jpush.init();
  33. // }
  34. // },
  35. // ]);
  36. // 先查询原生平台有没有保存需要跳转的子路由
  37. // String routerName = await AppChannel.getNativeRouterName();
  38. // Log.d('SplashController - 查询原生平台有没有保存需要跳转的子路由:$routerName');
  39. String? token = SPUtil.getString(AppConstant.storageToken);
  40. UserService.to.setToken(token);
  41. if (UserService.to.isLogin) {
  42. //去Attendance页面签到
  43. Log.d("去首页页面");
  44. if (ConfigService.to.selectCountry.value == 1) {
  45. //去新加坡首页
  46. ComponentRouterServices.sgService.startSGMainPage();
  47. } else if (ConfigService.to.selectCountry.value == 2) {
  48. //去英国首页
  49. ComponentRouterServices.ukService.startUKMainPage();
  50. } else if (ConfigService.to.selectCountry.value == 3) {
  51. //去马来首页
  52. ComponentRouterServices.msService.startMSMainPage();
  53. } else if (ConfigService.to.selectCountry.value == 4) {
  54. //去荷兰首页
  55. ComponentRouterServices.nlService.startNLMainPage();
  56. } else if (ConfigService.to.selectCountry.value == 5) {
  57. //去泰国首页
  58. ComponentRouterServices.thService.startTHMainPage();
  59. } else {
  60. //去越南首页
  61. ComponentRouterServices.vnService.startVNMainPage();
  62. }
  63. } else {
  64. //去登录页面
  65. Log.d("去登录页面");
  66. ComponentRouterServices.authService.startPopAllLoginPage();
  67. }
  68. // if (!Utils.isEmpty(routerName)) {
  69. // // 只跳转一次
  70. // Get.offAllNamed(routerName);
  71. // AppChannel.clearNativeRouterName();
  72. // } else {
  73. // // 如果没有经历过GUIDE页面,进入GUIDE,否则进入首页
  74. // MainPage.startWithPopAll();
  75. // }
  76. //跳转页面之后清除 Android 的 SplashScreen 库
  77. // if (Device.isAndroid) {
  78. // AppChannel.skipAndroidSplashScreen();
  79. // }
  80. }