|
123456789101112131415161718192021222324252627282930313233343536373839 |
- import 'package:flutter/material.dart';
- import 'package:zhiying_comm/pages/login_page/login_page.dart';
- import 'package:zhiying_comm/zhiying_comm.dart';
- import 'package:provider/provider.dart';
-
- class RouterUtil {
- static Future route(Map<String, dynamic> model, BuildContext context) async {
- // 唯一跳转标识
- String skipIdentifier = model['skip_identifier'].toString();
- // 需要登录
- String requiredLogin = model['required_login'].toString();
- // 需要淘宝授权
- String requiredTaobaoAuth = model['required_taobao_auth'].toString();
-
- if (skipIdentifier == null || skipIdentifier == '') {
- print('skipIdentifier 参数不存在,无法跳转页面');
- return Future.error('skipIdentifier 参数不存在,无法跳转页面');
- }
- print('skipIdentifier: ${skipIdentifier}');
-
- if (requiredLogin == '1') {
- UserInfoModel user = await Provider.of<UserInfoNotifier>(context, listen: false).getUserInfoModel();
- print(user.toString());
- if (user?.token == null || user.token == '') {
- print('need login...');
- return Navigator.of(context).push(MaterialPageRoute(builder: (BuildContext context) {
- return LoginPage(model);
- }));
- }
- }
-
- return Navigator.of(context).push(MaterialPageRoute(builder: (BuildContext context) {
- if (PageFactory.hasRegisted(skipIdentifier)) {
- return PageFactory.create(skipIdentifier, model);
- }
- return EmptyPage();
- }));
- }
- }
|