From c8891b84565dffc836c103ff1a20234eeb19b61e Mon Sep 17 00:00:00 2001 From: laiiihz Date: Tue, 30 Mar 2021 15:18:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=88=91=E7=9A=84=E9=A1=B5=E9=9D=A2=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E6=9D=83=E9=99=90=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/provider/app_provider.dart | 2 ++ lib/provider/user_provider.dart | 6 ++++++ lib/utils/login_util.dart | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/provider/app_provider.dart b/lib/provider/app_provider.dart index d698727f..29860aa4 100644 --- a/lib/provider/app_provider.dart +++ b/lib/provider/app_provider.dart @@ -184,6 +184,8 @@ class AppProvider extends ChangeNotifier { ///更新房屋列表 updateHouses(List items) { + if (items == null) return; + if (items.isEmpty) return; _houses = items; notifyListeners(); } diff --git a/lib/provider/user_provider.dart b/lib/provider/user_provider.dart index acb3cb9d..4baee0a5 100644 --- a/lib/provider/user_provider.dart +++ b/lib/provider/user_provider.dart @@ -1,3 +1,5 @@ +import 'package:akuCommunity/provider/app_provider.dart'; +import 'package:akuCommunity/ui/profile/house/house_func.dart'; import 'package:flutter/material.dart'; import 'package:flustars/flustars.dart'; @@ -10,12 +12,15 @@ import 'package:akuCommunity/utils/bee_parse.dart'; import 'package:akuCommunity/utils/hive_store.dart'; import 'package:akuCommunity/utils/network/base_model.dart'; import 'package:akuCommunity/utils/network/net_util.dart'; +import 'package:get/get.dart'; +import 'package:provider/provider.dart'; class UserProvider extends ChangeNotifier { bool _isLogin = false; bool get isLogin => _isLogin; bool get isNotLogin => !_isLogin; Future setLogin(int token) async { + final appProvider = Provider.of(Get.context,listen: false); _isLogin = true; NetUtil().dio.options.headers.putIfAbsent('App-Admin-Token', () => token); HiveStore.appBox.put('token', token); @@ -25,6 +30,7 @@ class UserProvider extends ChangeNotifier { await setCurrentHouse((_userDetailModel?.estateNames?.isEmpty ?? true) ? '' : _userDetailModel?.estateNames?.first); + await appProvider.updateHouses(await HouseFunc.houses); notifyListeners(); } diff --git a/lib/utils/login_util.dart b/lib/utils/login_util.dart index 8b1018ab..a97aeac4 100644 --- a/lib/utils/login_util.dart +++ b/lib/utils/login_util.dart @@ -32,7 +32,7 @@ class LoginUtil { static bool get isNotLogin => !isLogin; static bool haveRoom(String name) { - if (!name.contains(RegExp('访客邀请|报事报修|建议咨询|生活缴费|物品出门|投诉表扬'))) return true; + if (!name.contains(RegExp('访客邀请|报事报修|建议咨询|生活缴费|物品出门|投诉表扬|我的访客|我的报修'))) return true; final appProvider = Provider.of(Get.context, listen: false); if (appProvider.selectedHouse == null) { BotToast.showText(text: '请先添加房屋');