welcome_page.dart 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. MyCookie().getLoginInformation().data == null ||
  32. MyCookie().getLoginInformation().data.token.isEmpty ||
  33. MyCookie().getLoginInformation().data.token == '') {
  34. MyTools().toPage(context, LoginPage(), (then) {}, noBack: true);
  35. } else {
  36. checkLogin((r, hE) {
  37. if (!hE) {
  38. MyTools().toPage(context, RootPage(), (then) {}, noBack: true);
  39. } else {
  40. String token = MyCookie().getToken();
  41. LoginInformationBeanEntity loginInformation =
  42. LoginInformationBeanEntity()
  43. .fromJson(json.decode(r.data.toString()));
  44. loginInformation.data.token = token;
  45. MyCookie().saveLoginInformationBeanEntity(loginInformation);
  46. MyTools().toPage(context, LoginPage(), (then) {}, noBack: true);
  47. }
  48. }, (e) {});
  49. }
  50. });
  51. }
  52. @override
  53. Widget build(BuildContext context) {
  54. return Scaffold(
  55. body: Stack(
  56. children: [
  57. Image.asset(
  58. 'images/we_bg.png',
  59. fit: BoxFit.cover,
  60. height: MediaQuery.of(context).size.height,
  61. width: MediaQuery.of(context).size.width,
  62. ),
  63. Image.asset(
  64. 'images/we_logo.png',
  65. height: 118,
  66. width: 118,
  67. )
  68. ],
  69. alignment: Alignment.center,
  70. ),
  71. );
  72. }
  73. }