From 0c0c244e99b3461ec661152bab01b6f556568a62 Mon Sep 17 00:00:00 2001 From: datang Date: Thu, 25 Aug 2022 09:29:49 +0800 Subject: [PATCH] update --- lib/providers/user_provider.dart | 13 ++++++------- lib/ui/home/call.dart | 28 ++-------------------------- lib/ui/user/user_page.dart | 3 +-- 3 files changed, 9 insertions(+), 35 deletions(-) diff --git a/lib/providers/user_provider.dart b/lib/providers/user_provider.dart index cf36f3f..ff7a714 100644 --- a/lib/providers/user_provider.dart +++ b/lib/providers/user_provider.dart @@ -75,13 +75,12 @@ class UserProvider extends ChangeNotifier { Future updateConSms() async { final prefs = await SharedPreferences.getInstance(); + final service=FlutterBackgroundService(); var base = await apiClient.request(API.app.find, data: {'status': 1}); if (base.code == 0) { - await prefs.remove('refSms'); + await prefs.remove('conSms'); await prefs.setString('conSms', base.data['content']); - print(prefs.getString('action')); - - // _contentCon = base.data['content']; + service.invoke("stopService"); } else { CloudToast.show(base.msg); } @@ -93,12 +92,12 @@ class UserProvider extends ChangeNotifier { final service=FlutterBackgroundService(); var base = await apiClient.request(API.app.find, data: {'status': 2}); if (base.code == 0) { - // await prefs.remove('refSms'); + await prefs.remove('refSms'); print(base.data['content']); await prefs.setString('refSms', base.data['content']); print(prefs.getString('refSms')); - service.startService(); - // _contentRef = base.data['content']; + service.invoke("stopService"); + } else { CloudToast.show(base.msg); } diff --git a/lib/ui/home/call.dart b/lib/ui/home/call.dart index 45cd796..8d12466 100644 --- a/lib/ui/home/call.dart +++ b/lib/ui/home/call.dart @@ -63,42 +63,18 @@ void onStart(ServiceInstance service) async { print(callState+"$flag"); String? ref = prefs.getString('refSms'); String? con = prefs.getString('conSms'); + print(con); + if (callState == "IDLE") { if (flag != 0) { - // print("object"); final Iterable entry = await CallLog.query(); phoneNum = entry.first.number; callRecords = entry.first.duration; -// print(prefs.getString('action')); - // DateTime.fromMillisecondsSinceEpoch(entry.first.timestamp!) - // print('DURATION : ${entry.first.duration}');///通话时长 - // if(callRecords!=0){ - // // if(kg!){ if (flag > 0) { Telephony.backgroundInstance.sendSms(to: phoneNum!, message: ref!); } else { Telephony.backgroundInstance.sendSms(to: phoneNum!, message: con!); } - // // } - // }else{ - // print("没接通"); - // if (callRecords != 0) { - // print("接通了"); - // Telephony.backgroundInstance.sendSms(to: phoneNum!, message: "接通了"); - // } else { - // print("没接通"); - // Telephony.backgroundInstance.sendSms(to: phoneNum!, message: "接通了"); - // if(kg!) { - // Telephony.backgroundInstance.sendSms(to: phoneNum!, message: "没接通"); - // } - // print('DATE : ${DateTime.fromMillisecondsSinceEpoch(entry.first.timestamp!)}');//拨通时间 - // print("你好$phoneNum"); - // // final inbox = telephony.getInboxSms(); - // Telephony.backgroundInstance.sendSms(to: phoneNum!, message: "啦啦啦啦啦"); - // telephony.sendSms(to: phoneNum, message: "感谢来电"); - // _sendSMS('',[phoneNum]); - // print("你好123123$phoneNum"); - // } flag = 0; } } else if (callState == "RINGING") { diff --git a/lib/ui/user/user_page.dart b/lib/ui/user/user_page.dart index 6a360d0..768efbe 100644 --- a/lib/ui/user/user_page.dart +++ b/lib/ui/user/user_page.dart @@ -44,7 +44,7 @@ class _UserPageState extends State { final userProvider = Provider.of(Get.context!, listen: false); bool isVip = false; String? endDate; - late bool vle; + bool vle=false; @override void initState() { super.initState(); @@ -55,7 +55,6 @@ class _UserPageState extends State { isVip = false; vle =false; } else { - vle =true; isVip = true; } endDate=DateUtil.formatDateMs(UserTool.userProvider.userInfo.end * 1000, format: DateFormats.y_mo_d);