From 232e53aa508660def5da1b6045717517a882a64a Mon Sep 17 00:00:00 2001 From: datang Date: Thu, 25 Aug 2022 10:20:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E6=94=B9=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/providers/user_provider.dart | 19 +++++++++++++------ lib/ui/home/content_connect_page.dart | 4 ++-- lib/ui/home/content_refuse_page.dart | 4 ++-- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/lib/providers/user_provider.dart b/lib/providers/user_provider.dart index ff7a714..ae301d9 100644 --- a/lib/providers/user_provider.dart +++ b/lib/providers/user_provider.dart @@ -27,7 +27,6 @@ class UserProvider extends ChangeNotifier { String get contentRef => _contentRef; - Future init() async { if (HiveStore.appBox?.containsKey('token') ?? false) { final token = HiveStore.appBox?.get('token') as String; @@ -75,29 +74,37 @@ class UserProvider extends ChangeNotifier { Future updateConSms() async { final prefs = await SharedPreferences.getInstance(); - final service=FlutterBackgroundService(); + final service = FlutterBackgroundService(); var base = await apiClient.request(API.app.find, data: {'status': 1}); if (base.code == 0) { await prefs.remove('conSms'); await prefs.setString('conSms', base.data['content']); service.invoke("stopService"); + if(prefs.getBool('kg')!){ + Future.delayed(const Duration(seconds: 1), () async { + service.startService(); + }); + } } else { CloudToast.show(base.msg); } + notifyListeners(); } Future updateRefSms() async { final prefs = await SharedPreferences.getInstance(); - final service=FlutterBackgroundService(); + final service = FlutterBackgroundService(); var base = await apiClient.request(API.app.find, data: {'status': 2}); if (base.code == 0) { await prefs.remove('refSms'); - print(base.data['content']); await prefs.setString('refSms', base.data['content']); - print(prefs.getString('refSms')); service.invoke("stopService"); - + if(prefs.getBool('kg')!){ + Future.delayed(const Duration(seconds: 1), () async { + service.startService(); + }); + } } else { CloudToast.show(base.msg); } diff --git a/lib/ui/home/content_connect_page.dart b/lib/ui/home/content_connect_page.dart index 8222e88..226420a 100644 --- a/lib/ui/home/content_connect_page.dart +++ b/lib/ui/home/content_connect_page.dart @@ -117,7 +117,7 @@ class _ContentConnectPageState extends State { CloudToast.show(res.msg); } } else { - if (UserTool.userProvider.isLogin) { + if (UserTool.userProvider.userInfo.isVip==1) { if (textListSMS.length > 5) { BotToast.showText(text: '自定义数量已达上限,请先删除不需要的短信'); } else { @@ -129,7 +129,7 @@ class _ContentConnectPageState extends State { )); } } else { - BotToast.showText(text: '请先登录'); + BotToast.showText(text: '请先开通会员'); } } setState(() {}); diff --git a/lib/ui/home/content_refuse_page.dart b/lib/ui/home/content_refuse_page.dart index a31c829..3b45a5f 100644 --- a/lib/ui/home/content_refuse_page.dart +++ b/lib/ui/home/content_refuse_page.dart @@ -118,7 +118,7 @@ class _ContentRefusePageState extends State { CloudToast.show(res.msg); } } else { - if (userProvider.isLogin) { + if (userProvider.userInfo.isVip==1) { if (textListSMS.length > 5) { BotToast.showText(text: '自定义数量已达上限,请先删除不需要的短信'); } else { @@ -130,7 +130,7 @@ class _ContentRefusePageState extends State { )); } } else { - BotToast.showText(text: '请先登录'); + BotToast.showText(text: '请先开通会员'); } } setState(() {});