Browse Source

更新底部登录条件

tags/0.0.1
Weller 4 years ago
parent
commit
116c2fbe02
1 changed files with 23 additions and 4 deletions
  1. +23
    -4
      lib/pages/home_page/home_page.dart

+ 23
- 4
lib/pages/home_page/home_page.dart View File

@@ -3,6 +3,7 @@ import 'dart:convert' as convert;
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:zhiying_base_widget/utils/contants.dart';
import 'package:zhiying_comm/models/base/base_tab_model.dart';
import 'package:zhiying_comm/util/image_util.dart';
@@ -105,12 +106,30 @@ class _HomePageState extends State<HomePage> {
unselectedFontSize: 11,
currentIndex: _currentIndex,
elevation: 0,
onTap: ((index) {
setState(() {
_currentIndex = index;
});
onTap: ((index) async {
BaseTabModel model = BaseTabModel.fromJson(tabs[index]);
if (await _checkLimit(model)) {
setState(() {
_currentIndex = index;
});
}
}),
//底部导航栏
items: items);
}

Future<bool> _checkLimit(BaseTabModel model) async {
if (model.requiredLogin == '1') {
UserInfoModel user =
await Provider.of<UserInfoNotifier>(context, listen: false)
.getUserInfoModel();
print(user.toString());
if (user?.token == null || user.token == '') {
print('need login...');
RouterUtil.goLogin(context);
return false;
}
}
return true;
}
}

Loading…
Cancel
Save