diff --git a/lib/main.dart b/lib/main.dart index 31155e0..f000de9 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -5,6 +5,7 @@ import 'package:bot_toast/bot_toast.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:flutter_background_service/flutter_background_service.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; @@ -45,8 +46,7 @@ void main() async { // }; WidgetsFlutterBinding.ensureInitialized(); // await initializeService(); - - // Workmanager().initialize( +// 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 a8cbc80..8af5941 100644 --- a/lib/providers/user_provider.dart +++ b/lib/providers/user_provider.dart @@ -79,7 +79,8 @@ class UserProvider extends ChangeNotifier { var base = await apiClient.request(API.app.find, data: {'status': 1}); if (base.code == 0) { await prefs.remove('conSms'); - await prefs.setString('conSms', "[${UserTool.userProvider.userInfo.tag}]${base + await prefs.setString('conSms', (UserTool.userProvider.userInfo.tag)==""?"${base + .data['content']}":"[${UserTool.userProvider.userInfo.tag}]${base .data['content']}"); service.invoke("stopService"); if(prefs.getBool('kg')!){ @@ -100,7 +101,8 @@ class UserProvider extends ChangeNotifier { var base = await apiClient.request(API.app.find, data: {'status': 2}); if (base.code == 0) { await prefs.remove('refSms'); - await prefs.setString('refSms', "[${UserTool.userProvider.userInfo.tag}]${base + await prefs.setString('refSms', (UserTool.userProvider.userInfo.tag)==""?"${base + .data['content']}":"[${UserTool.userProvider.userInfo.tag}]${base .data['content']}" ); service.invoke("stopService"); if(prefs.getBool('kg')!){ diff --git a/lib/ui/home/call.dart b/lib/ui/home/call.dart index 16df61b..9cb977a 100644 --- a/lib/ui/home/call.dart +++ b/lib/ui/home/call.dart @@ -5,13 +5,17 @@ import 'package:call_log/call_log.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter_background_service/flutter_background_service.dart'; +import 'package:flutter_background_service_android/flutter_background_service_android.dart'; +import 'package:project_telephony/utils/headers.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:telephony/telephony.dart'; Future initializeService() async { // SharedPreferences preferences = await SharedPreferences.getInstance(); + final service = FlutterBackgroundService(); + await service.configure( androidConfiguration: AndroidConfiguration( // this will be executed when app is in foreground or background in separated isolate @@ -48,6 +52,11 @@ void onStart(ServiceInstance service) async { service.on('stopService').listen((event) { service.stopSelf(); }); + // setForegroundNotificationInfo(title: "你好", content: "再见"); + // AndroidServiceInstance. + // service.setNotificationInfo("").listen((event){ + // + // }); // Telephony.backgroundInstance.sendSms(to: "13486828191", message: "123123"); Timer.periodic(const Duration(seconds: 1), (timer) async { final SharedPreferences prefs = await SharedPreferences.getInstance(); @@ -79,7 +88,7 @@ void onStart(ServiceInstance service) async { print('通话'); } else if (callState == "OFFHOOK") { if (flag > 0) flag *= -1; - print('不同话'); + print('不通话'); } }); } diff --git a/lib/ui/home/content_connect_page.dart b/lib/ui/home/content_connect_page.dart index e2c2393..67a5ddf 100644 --- a/lib/ui/home/content_connect_page.dart +++ b/lib/ui/home/content_connect_page.dart @@ -27,7 +27,7 @@ class _ContentConnectPageState extends State { List textListSMS = []; int isCheck=0; - // final userProvider = Provider.of(Get.context!, listen: false); + final userProvider = Provider.of(Get.context!, listen: false); final EasyRefreshController _easyRefreshController = EasyRefreshController(); @override @@ -94,6 +94,7 @@ class _ContentConnectPageState extends State { controller: _easyRefreshController, onRefresh: () async { await UserTool.userProvider.updateUserInfo(); + userProvider.updateConSms(); updateList(); setState(() {}); }, diff --git a/lib/ui/home/content_refuse_page.dart b/lib/ui/home/content_refuse_page.dart index ad8f6ec..8569dec 100644 --- a/lib/ui/home/content_refuse_page.dart +++ b/lib/ui/home/content_refuse_page.dart @@ -94,6 +94,7 @@ class _ContentRefusePageState extends State { controller: _easyRefreshController, onRefresh: () async { await userProvider.updateUserInfo(); + userProvider.updateRefSms(); updateList(); setState(() {}); }, @@ -128,6 +129,7 @@ class _ContentRefusePageState extends State { Get.to(AddSmsPage( status: 2, ploneBack: (String textContent) { + _easyRefreshController.callRefresh(); }, )); diff --git a/lib/ui/home/home_page.dart b/lib/ui/home/home_page.dart index 9202824..820128b 100644 --- a/lib/ui/home/home_page.dart +++ b/lib/ui/home/home_page.dart @@ -1,6 +1,8 @@ import 'dart:async'; +import 'package:bot_toast/bot_toast.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_background_service/flutter_background_service.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:project_telephony/ui/home/content_connect_page.dart'; import 'package:project_telephony/ui/home/content_refuse_page.dart'; @@ -9,6 +11,7 @@ import 'package:project_telephony/ui/user/privacy_rights_page.dart'; import 'package:project_telephony/utils/headers.dart'; +import '../tab_navigator.dart'; import '../user/privacy_rights_page.dart'; class HomePage extends StatefulWidget { @@ -20,7 +23,8 @@ class HomePage extends StatefulWidget { bool sms = false; bool plone = false; - +bool kg=false; +final service = FlutterBackgroundService(); @override class _HomePageState extends State with WidgetsBindingObserver { @override @@ -43,6 +47,7 @@ class _HomePageState extends State with WidgetsBindingObserver { sms = await Permission.sms.request().isGranted; plone = await Permission.phone.request().isGranted; callLog = await Permission.callLog.request().isGranted; + kg = await service.isRunning(); setState(() {}); } @@ -90,16 +95,38 @@ class _HomePageState extends State with WidgetsBindingObserver { // return false; // } // } + // String _text(){ + // if(!(sms && plone && callLog && kg)){ + // if(!(sms && plone && callLog )){ + // return ""; + // // return "必须权限没有授予,本APP无法正常使用"; + // }if(!kg){ + // return "功能开关未开启"; + // } + // }else{ + // return ""; + // } + // } _warning() { return Offstage( - offstage: (sms && plone && callLog), + offstage: (sms && plone && callLog && kg), child: GestureDetector( onTap: () { + if(!(sms && plone && callLog && kg)){ + if(!kg){ + BotToast.showText(text: '功能开关未开启'); + Get.to(()=>const TabNavigator(index: 1,)); + }else{ + Get.to(()=>const PrivacyRightsPage(name: "权限说明")); + } + } // print(); - openAppSettings(); + // openAppSettings(); }, - child: Container( - margin: EdgeInsets.symmetric(horizontal: 64.w), + child: + Container( + // width: 622.w, + margin: EdgeInsets.only(left:!kg? 200.w:64.w,right: 64.w), padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 20.w), height: 88.w, decoration: BoxDecoration( @@ -115,7 +142,7 @@ class _HomePageState extends State with WidgetsBindingObserver { ), 16.wb, Text( - "必须权限没有授予,本APP无法正常使用", + !kg ? "功能开关未开启":"必须权限没有授予,本APP无法正常使用", style: TextStyle(color: const Color(0xFFFF3F3F), fontSize: 24.sp), ), diff --git a/lib/ui/login/login_page.dart b/lib/ui/login/login_page.dart index ce70b7a..0cd7e42 100644 --- a/lib/ui/login/login_page.dart +++ b/lib/ui/login/login_page.dart @@ -17,6 +17,7 @@ import '../../providers/user_provider.dart'; import '../../utils/toast/cloud_toast.dart'; import '../../utils/user_tool.dart'; import '../tab_navigator.dart'; +import '../user/content_authority_page.dart'; import '../widget/image_scaffold.dart'; import '../widget/plone_bottom.dart'; @@ -334,26 +335,30 @@ class _LoginPageState extends State { : const Icon(CupertinoIcons.checkmark_circle, size: 18, color: Colors.blue), ), - RichText( + + GestureDetector(onTap: (){ + Get.to(()=>const ContentAuthorityPage()); + },child: RichText( text: TextSpan( text: "我已阅读并同意", style: TextStyle( color: BaseStyle.colorcccccc, fontSize: 12 * 2.sp), children: [ - TextSpan( - text: '《用户服务协议》', - style: TextStyle(color: kPrimaryColor, fontSize: 12 * 2.sp), - recognizer: _recognizer(context, 2)), - TextSpan( - text: "和", - style: TextStyle( - color: BaseStyle.colorcccccc, fontSize: 12 * 2.sp), - ), - TextSpan( - text: '《隐私协议》', - style: TextStyle(color: kPrimaryColor, fontSize: 12 * 2.sp), - recognizer: _recognizer(context, 1)), - ])), + // TextSpan( + // text: '《用户服务协议》', + // style: TextStyle(color: kPrimaryColor, fontSize: 12 * 2.sp), + // recognizer: _recognizer(context, 2)), + // TextSpan( + // text: "和", + // style: TextStyle( + // color: BaseStyle.colorcccccc, fontSize: 12 * 2.sp), + // ), + TextSpan( + text: '《隐私协议》', + style: TextStyle(color: kPrimaryColor, fontSize: 12 * 2.sp), + recognizer: _recognizer(context, 1)), + ])),) + , ], ), ); diff --git a/lib/ui/tab_navigator.dart b/lib/ui/tab_navigator.dart index 0a259c4..09c85dd 100644 --- a/lib/ui/tab_navigator.dart +++ b/lib/ui/tab_navigator.dart @@ -72,7 +72,7 @@ class _TabNavigatorState extends State const Duration(seconds: 1)) { //两次点击间隔超过1秒重新计算 _lastPressed = DateTime.now(); - BotToast.showText(text: '再按一次即可退出程序(退出不回影响短信自动回复,但是不要在后台关闭本应用)'); + BotToast.showText(text: '再按一次即可退出程序'); return false; } // 否则关闭APP diff --git a/lib/ui/user/content_authority_page.dart b/lib/ui/user/content_authority_page.dart index dfffd79..b2573f5 100644 --- a/lib/ui/user/content_authority_page.dart +++ b/lib/ui/user/content_authority_page.dart @@ -1,4 +1,4 @@ -import 'package:flutter/cupertino.dart'; + import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; diff --git a/lib/ui/user/members_page.dart b/lib/ui/user/members_page.dart index 4292d21..11312d9 100644 --- a/lib/ui/user/members_page.dart +++ b/lib/ui/user/members_page.dart @@ -34,11 +34,11 @@ List? data; final List _piceList = [ ChooseItems( month: 12, - pice: 10, + pice: 0.1, ), ChooseItems( month: 1, - pice: 1, + pice: 0.01, ), ]; ChooseItems? _chooseItem = _piceList[0]; @@ -52,7 +52,7 @@ List payWay = [ ]; class _MembersPageState extends State { - int nowPrice = 1; + double nowPrice = 0.01; final EasyRefreshController _easyRefreshController = EasyRefreshController(); @override @@ -61,6 +61,20 @@ class _MembersPageState extends State { super.dispose(); } + @override + void initState(){ + PayUtil().wxPayAddListener( + paySuccess:_paySuccess, + payError: (event) { + BotToast.closeAllLoading(); + } + + ); + super.initState(); + } + void _paySuccess() { + _easyRefreshController.callRefresh(); + } @override Widget build(BuildContext context) { return Scaffold( @@ -107,7 +121,8 @@ class _MembersPageState extends State { Get.snackbar('提示', "请先选择充值月份"); } else { if (_selectIndex == 0) { - _wxPayFunc(); + print("这是数据${_piceList[_selectIndex].pice}"); + _wxPayFunc(_piceList[_selectIndex].pice); } else { var result = await isAliPayInstalled(); // 这里判断是否安装支付宝 @@ -234,14 +249,14 @@ class _MembersPageState extends State { ); } - Future _wxPayFunc() async { + Future _wxPayFunc(double pay) async { bool isInstalled = await fluwx.isWeChatInstalled; if (!isInstalled) { BotToast.showText(text: "请先安装微信"); return; } //调起支付 - _wxPay(); + _wxPay(pay); // var wxPayModel = WxPayModel.fromJson({ // "prepayId": "wx121434071826969924754d7d3309520000", // "partnerId": "1622850618", @@ -278,8 +293,8 @@ class _MembersPageState extends State { // Future _aliPay() async { var base = await apiClient.request(API.pay.alipay, data: { - // 'amount': nowPrice,//注释 - 'amount': 0.01, + 'amount': nowPrice,//注释 + // 'amount': 0.01, }); if (base.code == 0) { await PayUtil().callAliPay(base.data); @@ -289,10 +304,10 @@ class _MembersPageState extends State { } } - Future _wxPay() async { + Future _wxPay(double pay) async { var base = await apiClient.request(API.pay.wxpay, data: { - // 'amount': nowPrice,//注释 - 'amount': 0.01, + 'amount': pay,//注释 + // 'amount': 0.01, }); if (base.code == 0) { var wxPayModel = WxPayModel.fromJson(base.data); diff --git a/lib/ui/user/user_page.dart b/lib/ui/user/user_page.dart index 3b79573..24b394f 100644 --- a/lib/ui/user/user_page.dart +++ b/lib/ui/user/user_page.dart @@ -49,9 +49,7 @@ class _UserPageState extends State { late bool vle = false; - _load() async { - vle = await service.isRunning(); - } + final EasyRefreshController _easyRefreshController = EasyRefreshController(); @@ -60,33 +58,34 @@ class _UserPageState extends State { _easyRefreshController.dispose(); super.dispose(); } - + // _load() async { + // vle = await service.isRunning(); + // } @override void initState() { super.initState(); UserTool.userProvider.updateUserInfo(); Future.delayed( const Duration(milliseconds: 0), - () => setState(() { - if (UserTool.userProvider.isLogin) { - print(UserTool.userProvider.userInfo.end * 1000); - print(DateTime.now().millisecondsSinceEpoch); - if (UserTool.userProvider.userInfo.end * 1000 > - DateTime.now().microsecondsSinceEpoch) { - isVip = false; - vle = false; - } else { - isVip = true; - _load(); - } - //service.isRunning() as bool; - endDate = DateUtil.formatDateMs( - UserTool.userProvider.userInfo.end * 1000, - format: DateFormats.y_mo_d); - } else { - vle = false; - } - })); + () => setState(() async{ + if (UserTool.userProvider.isLogin) { + // print(UserTool.userProvider.userInfo.end * 1000); + // print(DateTime.now().millisecondsSinceEpoch); + if (UserTool.userProvider.userInfo.isVip != 1) { + isVip = false; + vle = false; + } else { + isVip = true; + vle = await service.isRunning(); + } + //service.isRunning() as bool; + endDate = DateUtil.formatDateMs( + UserTool.userProvider.userInfo.end * 1000, + format: DateFormats.y_mo_d); + } else { + vle = false; + } + })); } @override @@ -359,7 +358,6 @@ class _UserPageState extends State { prefs.remove("kg"); prefs.setBool("kg", vle); service.invoke("stopService"); - ///有问题?? // exit(0); // UserTool.userProvider.setKg(vle); @@ -370,7 +368,7 @@ class _UserPageState extends State { // print("这是数据${prefs.getBool("kg")}"); } } else { - BotToast.showText(text: "还没有开通会员,不可使用改功能"); + BotToast.showText(text: "还没有开通会员,不可使用该功能"); } }); }), diff --git a/lib/ui/widget/putup_widget.dart b/lib/ui/widget/putup_widget.dart index e136a81..5e7026d 100644 --- a/lib/ui/widget/putup_widget.dart +++ b/lib/ui/widget/putup_widget.dart @@ -6,7 +6,7 @@ typedef ItemCallback = Function(ChooseItems item, int index); class ChooseItems { int month; - int pice; + double pice; bool isChoose; ChooseItems({