diff --git a/lib/main.dart b/lib/main.dart index 927e763..70d9169 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -46,6 +46,7 @@ void main() async { WidgetsFlutterBinding.ensureInitialized(); // await initializeService(); + // Workmanager().initialize( // callbackDispatcher, // The top level function, aka callbackDispatcher // isInDebugMode: true // If enabled it will post a notification whenever the task is running. Handy for debugging tasks diff --git a/lib/providers/user_provider.dart b/lib/providers/user_provider.dart index cf36f3f..7be7364 100644 --- a/lib/providers/user_provider.dart +++ b/lib/providers/user_provider.dart @@ -94,9 +94,9 @@ class UserProvider extends ChangeNotifier { var base = await apiClient.request(API.app.find, data: {'status': 2}); if (base.code == 0) { // await prefs.remove('refSms'); - print(base.data['content']); + // print(base.data['content']); await prefs.setString('refSms', base.data['content']); - print(prefs.getString('refSms')); + // print(prefs.getString('refSms')); service.startService(); // _contentRef = base.data['content']; } else { diff --git a/lib/ui/home/call.dart b/lib/ui/home/call.dart index 45cd796..035746b 100644 --- a/lib/ui/home/call.dart +++ b/lib/ui/home/call.dart @@ -60,9 +60,10 @@ void onStart(ServiceInstance service) async { final SharedPreferences prefs = await SharedPreferences.getInstance(); CallState state = await Telephony.instance.callState; callState = state.name; - print(callState+"$flag"); + // print(callState+"$flag"); String? ref = prefs.getString('refSms'); String? con = prefs.getString('conSms'); + print("没接通$ref,接通$con"); if (callState == "IDLE") { if (flag != 0) { // print("object"); @@ -75,9 +76,9 @@ void onStart(ServiceInstance service) async { // if(callRecords!=0){ // // if(kg!){ if (flag > 0) { - Telephony.backgroundInstance.sendSms(to: phoneNum!, message: ref!); + Telephony.backgroundInstance.sendSms(to: phoneNum!, message: ref!);//没接通 } else { - Telephony.backgroundInstance.sendSms(to: phoneNum!, message: con!); + Telephony.backgroundInstance.sendSms(to: phoneNum!, message: con!);//接通 } // // } // }else{ diff --git a/lib/ui/user/user_page.dart b/lib/ui/user/user_page.dart index 6a360d0..2ad5cc9 100644 --- a/lib/ui/user/user_page.dart +++ b/lib/ui/user/user_page.dart @@ -44,18 +44,18 @@ class _UserPageState extends State { final userProvider = Provider.of(Get.context!, listen: false); bool isVip = false; String? endDate; - late bool vle; + late bool vle=false; @override void initState() { super.initState(); if ( UserTool.userProvider.isLogin) { print(UserTool.userProvider.userInfo.end*1000); print(DateTime.now().millisecondsSinceEpoch); + if (UserTool.userProvider.userInfo.end*1000<=DateTime.now().millisecondsSinceEpoch ) { isVip = false; vle =false; } else { - vle =true; isVip = true; } endDate=DateUtil.formatDateMs(UserTool.userProvider.userInfo.end * 1000, format: DateFormats.y_mo_d); @@ -290,6 +290,10 @@ class _UserPageState extends State { onChanged: (value) async { final service = FlutterBackgroundService(); final SharedPreferences prefs = await _prefs; + // if(value){ + // WidgetsFlutterBinding.ensureInitialized(); + // await initializeService(); + // } // if(!value){ // // } @@ -305,12 +309,13 @@ class _UserPageState extends State { print("true"); prefs.remove("kg"); prefs.setBool("kg", vle); - service.startService(); + + // service.startService(); // WidgetsFlutterBinding.ensureInitialized(); - // initializeService(); + initializeService(); // UserTool.userProvider.setKg(vle) // initializeService(); - initializeService(); + // initializeService(); BotToast.showText(text: " 你开启了该功能"); // initializeService(); // print("这是数据${prefs.getBool("kg")}");