welcome_page.dart 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import 'dart:async';
  2. import 'dart:convert';
  3. import 'package:bbyyy/beans/login_information_bean_entity.dart';
  4. import 'package:bbyyy/https/my_request.dart';
  5. import 'package:bbyyy/my_tools/easy_loading/easy_loading.dart';
  6. import 'package:bbyyy/my_tools/my_cookie.dart';
  7. import 'package:bbyyy/my_tools/my_tools.dart';
  8. import 'package:bbyyy/paegs/login_page/login_page.dart';
  9. import 'package:bbyyy/paegs/root_page/root_page.dart';
  10. import 'package:flutter/material.dart';
  11. class WelcomePage extends StatefulWidget {
  12. @override
  13. _WelcomePageState createState() => _WelcomePageState();
  14. }
  15. class _WelcomePageState extends State<WelcomePage> {
  16. @override
  17. void initState() {
  18. super.initState();
  19. EasyLoading.instance
  20. ..displayDuration = const Duration(milliseconds: 1500)
  21. ..indicatorType = EasyLoadingIndicatorType.ring
  22. ..loadingStyle = EasyLoadingStyle.light
  23. ..maskType = EasyLoadingMaskType.black
  24. ..indicatorSize = 45.0
  25. ..radius = 10.0
  26. ..textPadding = EdgeInsets.all(0)
  27. ..contentPadding = EdgeInsets.fromLTRB(20, 12, 20, 12)
  28. ..userInteractions = false;
  29. Timer(Duration(seconds: 1), () {
  30. if (MyCookie().getLoginInformation() == null) {
  31. MyTools().toPage(context, LoginPage(), (then) {}, noBack: true);
  32. } else {
  33. // MyTools().toPage(context, RootPage(), (then){},noBack: true);
  34. checkLogin((r, hE) {
  35. if (!hE) {
  36. MyTools().toPage(context, RootPage(), (then) {}, noBack: true);
  37. } else {
  38. String token = MyCookie().getToken();
  39. LoginInformationBeanEntity loginInformation =
  40. LoginInformationBeanEntity()
  41. .fromJson(json.decode(r.data.toString()));
  42. loginInformation.data.token = token;
  43. MyCookie().saveLoginInformationBeanEntity(loginInformation);
  44. MyTools().toPage(context, LoginPage(), (then) {}, noBack: true);
  45. }
  46. }, (e) {});
  47. }
  48. });
  49. }
  50. @override
  51. Widget build(BuildContext context) {
  52. return Scaffold(
  53. body: Stack(
  54. children: [
  55. Image.asset(
  56. 'images/we_bg.png',
  57. fit: BoxFit.cover,
  58. height: MediaQuery.of(context).size.height,
  59. width: MediaQuery.of(context).size.width,
  60. ),
  61. Image.asset(
  62. 'images/we_logo.png',
  63. height: 118,
  64. width: 118,
  65. )
  66. ],
  67. alignment: Alignment.center,
  68. ),
  69. );
  70. }
  71. }