基础库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

38 rivejä
1.2 KiB

  1. import 'package:flutter/material.dart';
  2. import 'package:zhiying_comm/pages/login_page.dart';
  3. import 'package:zhiying_comm/zhiying_comm.dart';
  4. import 'package:provider/provider.dart';
  5. class RouterUtil {
  6. static Future route(Map<String, dynamic> model, BuildContext context) {
  7. // 唯一跳转标识
  8. String skipIdentifier = model['skip_identifier'].toString();
  9. // 需要登录
  10. String requiredLogin = model['required_login'].toString();
  11. // 需要淘宝授权
  12. String requiredTaobaoAuth = model['required_taobao_auth'].toString();
  13. if (requiredLogin == '1') {
  14. UserInfoModel user = Provider.of<UserInfoNotifier>(context, listen: false).getUserInfoModel();
  15. print(user.toString());
  16. if (user?.token == null || user.token == '') {
  17. print('need login...');
  18. return Navigator.of(context)
  19. .push(MaterialPageRoute(builder: (BuildContext context) {
  20. return LoginPage();
  21. }));
  22. }
  23. }
  24. return Navigator.of(context)
  25. .push(MaterialPageRoute(builder: (BuildContext context) {
  26. if (PageFactory.hasRegisted(skipIdentifier)) {
  27. return PageFactory.create(skipIdentifier, model);
  28. }
  29. return EmptyPage();
  30. }));
  31. }
  32. }