welcome_page.dart 2.6 KB

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