提交更改

master
王亚玲 2 years ago
parent ddab5f862c
commit 1f93ac76cc

@ -5,6 +5,7 @@ import 'package:bot_toast/bot_toast.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_background_service/flutter_background_service.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
@ -45,8 +46,7 @@ void main() async {
// }; // };
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
// await initializeService(); // await initializeService();
// Workmanager().initialize(
// Workmanager().initialize(
// callbackDispatcher, // The top level function, aka callbackDispatcher // 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 // isInDebugMode: true // If enabled it will post a notification whenever the task is running. Handy for debugging tasks
// ); // );

@ -79,7 +79,8 @@ class UserProvider extends ChangeNotifier {
var base = await apiClient.request(API.app.find, data: {'status': 1}); var base = await apiClient.request(API.app.find, data: {'status': 1});
if (base.code == 0) { if (base.code == 0) {
await prefs.remove('conSms'); 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']}"); .data['content']}");
service.invoke("stopService"); service.invoke("stopService");
if(prefs.getBool('kg')!){ if(prefs.getBool('kg')!){
@ -100,7 +101,8 @@ class UserProvider extends ChangeNotifier {
var base = await apiClient.request(API.app.find, data: {'status': 2}); var base = await apiClient.request(API.app.find, data: {'status': 2});
if (base.code == 0) { if (base.code == 0) {
await prefs.remove('refSms'); 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']}" ); .data['content']}" );
service.invoke("stopService"); service.invoke("stopService");
if(prefs.getBool('kg')!){ if(prefs.getBool('kg')!){

@ -5,13 +5,17 @@ import 'package:call_log/call_log.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter_background_service/flutter_background_service.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:shared_preferences/shared_preferences.dart';
import 'package:telephony/telephony.dart'; import 'package:telephony/telephony.dart';
Future<void> initializeService() async { Future<void> initializeService() async {
// SharedPreferences preferences = await SharedPreferences.getInstance(); // SharedPreferences preferences = await SharedPreferences.getInstance();
final service = FlutterBackgroundService(); final service = FlutterBackgroundService();
await service.configure( await service.configure(
androidConfiguration: AndroidConfiguration( androidConfiguration: AndroidConfiguration(
// this will be executed when app is in foreground or background in separated isolate // 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.on('stopService').listen((event) {
service.stopSelf(); service.stopSelf();
}); });
// setForegroundNotificationInfo(title: "你好", content: "再见");
// AndroidServiceInstance.
// service.setNotificationInfo("").listen((event){
//
// });
// Telephony.backgroundInstance.sendSms(to: "13486828191", message: "123123"); // Telephony.backgroundInstance.sendSms(to: "13486828191", message: "123123");
Timer.periodic(const Duration(seconds: 1), (timer) async { Timer.periodic(const Duration(seconds: 1), (timer) async {
final SharedPreferences prefs = await SharedPreferences.getInstance(); final SharedPreferences prefs = await SharedPreferences.getInstance();
@ -79,7 +88,7 @@ void onStart(ServiceInstance service) async {
print('通话'); print('通话');
} else if (callState == "OFFHOOK") { } else if (callState == "OFFHOOK") {
if (flag > 0) flag *= -1; if (flag > 0) flag *= -1;
print(''); print('');
} }
}); });
} }

@ -27,7 +27,7 @@ class _ContentConnectPageState extends State<ContentConnectPage> {
List<String> textListSMS = []; List<String> textListSMS = [];
int isCheck=0; int isCheck=0;
// final userProvider = Provider.of<UserProvider>(Get.context!, listen: false); final userProvider = Provider.of<UserProvider>(Get.context!, listen: false);
final EasyRefreshController _easyRefreshController = EasyRefreshController(); final EasyRefreshController _easyRefreshController = EasyRefreshController();
@override @override
@ -94,6 +94,7 @@ class _ContentConnectPageState extends State<ContentConnectPage> {
controller: _easyRefreshController, controller: _easyRefreshController,
onRefresh: () async { onRefresh: () async {
await UserTool.userProvider.updateUserInfo(); await UserTool.userProvider.updateUserInfo();
userProvider.updateConSms();
updateList(); updateList();
setState(() {}); setState(() {});
}, },

@ -94,6 +94,7 @@ class _ContentRefusePageState extends State<ContentRefusePage> {
controller: _easyRefreshController, controller: _easyRefreshController,
onRefresh: () async { onRefresh: () async {
await userProvider.updateUserInfo(); await userProvider.updateUserInfo();
userProvider.updateRefSms();
updateList(); updateList();
setState(() {}); setState(() {});
}, },
@ -128,6 +129,7 @@ class _ContentRefusePageState extends State<ContentRefusePage> {
Get.to(AddSmsPage( Get.to(AddSmsPage(
status: 2, status: 2,
ploneBack: (String textContent) { ploneBack: (String textContent) {
_easyRefreshController.callRefresh(); _easyRefreshController.callRefresh();
}, },
)); ));

@ -1,6 +1,8 @@
import 'dart:async'; import 'dart:async';
import 'package:bot_toast/bot_toast.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_background_service/flutter_background_service.dart';
import 'package:permission_handler/permission_handler.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_connect_page.dart';
import 'package:project_telephony/ui/home/content_refuse_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 'package:project_telephony/utils/headers.dart';
import '../tab_navigator.dart';
import '../user/privacy_rights_page.dart'; import '../user/privacy_rights_page.dart';
class HomePage extends StatefulWidget { class HomePage extends StatefulWidget {
@ -20,7 +23,8 @@ class HomePage extends StatefulWidget {
bool sms = false; bool sms = false;
bool plone = false; bool plone = false;
bool kg=false;
final service = FlutterBackgroundService();
@override @override
class _HomePageState extends State<HomePage> with WidgetsBindingObserver { class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
@override @override
@ -43,6 +47,7 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
sms = await Permission.sms.request().isGranted; sms = await Permission.sms.request().isGranted;
plone = await Permission.phone.request().isGranted; plone = await Permission.phone.request().isGranted;
callLog = await Permission.callLog.request().isGranted; callLog = await Permission.callLog.request().isGranted;
kg = await service.isRunning();
setState(() {}); setState(() {});
} }
@ -90,16 +95,38 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
// return false; // return false;
// } // }
// } // }
// String _text(){
// if(!(sms && plone && callLog && kg)){
// if(!(sms && plone && callLog )){
// return "";
// // return "必须权限没有授予本APP无法正常使用";
// }if(!kg){
// return "功能开关未开启";
// }
// }else{
// return "";
// }
// }
_warning() { _warning() {
return Offstage( return Offstage(
offstage: (sms && plone && callLog), offstage: (sms && plone && callLog && kg),
child: GestureDetector( child: GestureDetector(
onTap: () { onTap: () {
if(!(sms && plone && callLog && kg)){
if(!kg){
BotToast.showText(text: '功能开关未开启');
Get.to(()=>const TabNavigator(index: 1,));
}else{
Get.to(()=>const PrivacyRightsPage(name: "权限说明"));
}
}
// print(); // print();
openAppSettings(); // openAppSettings();
}, },
child: Container( child:
margin: EdgeInsets.symmetric(horizontal: 64.w), 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), padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 20.w),
height: 88.w, height: 88.w,
decoration: BoxDecoration( decoration: BoxDecoration(
@ -115,7 +142,7 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
), ),
16.wb, 16.wb,
Text( Text(
"必须权限没有授予本APP无法正常使用", !kg ? "功能开关未开启":"必须权限没有授予本APP无法正常使用",
style: style:
TextStyle(color: const Color(0xFFFF3F3F), fontSize: 24.sp), TextStyle(color: const Color(0xFFFF3F3F), fontSize: 24.sp),
), ),

@ -17,6 +17,7 @@ import '../../providers/user_provider.dart';
import '../../utils/toast/cloud_toast.dart'; import '../../utils/toast/cloud_toast.dart';
import '../../utils/user_tool.dart'; import '../../utils/user_tool.dart';
import '../tab_navigator.dart'; import '../tab_navigator.dart';
import '../user/content_authority_page.dart';
import '../widget/image_scaffold.dart'; import '../widget/image_scaffold.dart';
import '../widget/plone_bottom.dart'; import '../widget/plone_bottom.dart';
@ -334,26 +335,30 @@ class _LoginPageState extends State<LoginPage> {
: const Icon(CupertinoIcons.checkmark_circle, : const Icon(CupertinoIcons.checkmark_circle,
size: 18, color: Colors.blue), size: 18, color: Colors.blue),
), ),
RichText(
GestureDetector(onTap: (){
Get.to(()=>const ContentAuthorityPage());
},child: RichText(
text: TextSpan( text: TextSpan(
text: "我已阅读并同意", text: "我已阅读并同意",
style: TextStyle( style: TextStyle(
color: BaseStyle.colorcccccc, fontSize: 12 * 2.sp), color: BaseStyle.colorcccccc, fontSize: 12 * 2.sp),
children: [ children: [
TextSpan( // TextSpan(
text: '《用户服务协议》', // text: '《用户服务协议》',
style: TextStyle(color: kPrimaryColor, fontSize: 12 * 2.sp), // style: TextStyle(color: kPrimaryColor, fontSize: 12 * 2.sp),
recognizer: _recognizer(context, 2)), // recognizer: _recognizer(context, 2)),
TextSpan( // TextSpan(
text: "", // text: "",
style: TextStyle( // style: TextStyle(
color: BaseStyle.colorcccccc, fontSize: 12 * 2.sp), // color: BaseStyle.colorcccccc, fontSize: 12 * 2.sp),
), // ),
TextSpan( TextSpan(
text: '《隐私协议》', text: '《隐私协议》',
style: TextStyle(color: kPrimaryColor, fontSize: 12 * 2.sp), style: TextStyle(color: kPrimaryColor, fontSize: 12 * 2.sp),
recognizer: _recognizer(context, 1)), recognizer: _recognizer(context, 1)),
])), ])),)
,
], ],
), ),
); );

@ -72,7 +72,7 @@ class _TabNavigatorState extends State<TabNavigator>
const Duration(seconds: 1)) { const Duration(seconds: 1)) {
//1 //1
_lastPressed = DateTime.now(); _lastPressed = DateTime.now();
BotToast.showText(text: '再按一次即可退出程序(退出不回影响短信自动回复,但是不要在后台关闭本应用)'); BotToast.showText(text: '再按一次即可退出程序');
return false; return false;
} }
// APP // APP

@ -1,4 +1,4 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';

@ -34,11 +34,11 @@ List<dynamic>? data;
final List<ChooseItems> _piceList = [ final List<ChooseItems> _piceList = [
ChooseItems( ChooseItems(
month: 12, month: 12,
pice: 10, pice: 0.1,
), ),
ChooseItems( ChooseItems(
month: 1, month: 1,
pice: 1, pice: 0.01,
), ),
]; ];
ChooseItems? _chooseItem = _piceList[0]; ChooseItems? _chooseItem = _piceList[0];
@ -52,7 +52,7 @@ List payWay = [
]; ];
class _MembersPageState extends State<MembersPage> { class _MembersPageState extends State<MembersPage> {
int nowPrice = 1; double nowPrice = 0.01;
final EasyRefreshController _easyRefreshController = EasyRefreshController(); final EasyRefreshController _easyRefreshController = EasyRefreshController();
@override @override
@ -61,6 +61,20 @@ class _MembersPageState extends State<MembersPage> {
super.dispose(); super.dispose();
} }
@override
void initState(){
PayUtil().wxPayAddListener(
paySuccess:_paySuccess,
payError: (event) {
BotToast.closeAllLoading();
}
);
super.initState();
}
void _paySuccess() {
_easyRefreshController.callRefresh();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
@ -107,7 +121,8 @@ class _MembersPageState extends State<MembersPage> {
Get.snackbar('提示', "请先选择充值月份"); Get.snackbar('提示', "请先选择充值月份");
} else { } else {
if (_selectIndex == 0) { if (_selectIndex == 0) {
_wxPayFunc(); print("这是数据${_piceList[_selectIndex].pice}");
_wxPayFunc(_piceList[_selectIndex].pice);
} else { } else {
var result = var result =
await isAliPayInstalled(); // await isAliPayInstalled(); //
@ -234,14 +249,14 @@ class _MembersPageState extends State<MembersPage> {
); );
} }
Future _wxPayFunc() async { Future _wxPayFunc(double pay) async {
bool isInstalled = await fluwx.isWeChatInstalled; bool isInstalled = await fluwx.isWeChatInstalled;
if (!isInstalled) { if (!isInstalled) {
BotToast.showText(text: "请先安装微信"); BotToast.showText(text: "请先安装微信");
return; return;
} }
// //
_wxPay(); _wxPay(pay);
// var wxPayModel = WxPayModel.fromJson({ // var wxPayModel = WxPayModel.fromJson({
// "prepayId": "wx121434071826969924754d7d3309520000", // "prepayId": "wx121434071826969924754d7d3309520000",
// "partnerId": "1622850618", // "partnerId": "1622850618",
@ -278,8 +293,8 @@ class _MembersPageState extends State<MembersPage> {
// //
Future _aliPay() async { Future _aliPay() async {
var base = await apiClient.request(API.pay.alipay, data: { var base = await apiClient.request(API.pay.alipay, data: {
// 'amount': nowPrice,// 'amount': nowPrice,//
'amount': 0.01, // 'amount': 0.01,
}); });
if (base.code == 0) { if (base.code == 0) {
await PayUtil().callAliPay(base.data); await PayUtil().callAliPay(base.data);
@ -289,10 +304,10 @@ class _MembersPageState extends State<MembersPage> {
} }
} }
Future _wxPay() async { Future _wxPay(double pay) async {
var base = await apiClient.request(API.pay.wxpay, data: { var base = await apiClient.request(API.pay.wxpay, data: {
// 'amount': nowPrice,// 'amount': pay,//
'amount': 0.01, // 'amount': 0.01,
}); });
if (base.code == 0) { if (base.code == 0) {
var wxPayModel = WxPayModel.fromJson(base.data); var wxPayModel = WxPayModel.fromJson(base.data);

@ -49,9 +49,7 @@ class _UserPageState extends State<UserPage> {
late bool vle = false; late bool vle = false;
_load() async {
vle = await service.isRunning();
}
final EasyRefreshController _easyRefreshController = EasyRefreshController(); final EasyRefreshController _easyRefreshController = EasyRefreshController();
@ -60,33 +58,34 @@ class _UserPageState extends State<UserPage> {
_easyRefreshController.dispose(); _easyRefreshController.dispose();
super.dispose(); super.dispose();
} }
// _load() async {
// vle = await service.isRunning();
// }
@override @override
void initState() { void initState() {
super.initState(); super.initState();
UserTool.userProvider.updateUserInfo(); UserTool.userProvider.updateUserInfo();
Future.delayed( Future.delayed(
const Duration(milliseconds: 0), const Duration(milliseconds: 0),
() => setState(() { () => setState(() async{
if (UserTool.userProvider.isLogin) { if (UserTool.userProvider.isLogin) {
print(UserTool.userProvider.userInfo.end * 1000); // print(UserTool.userProvider.userInfo.end * 1000);
print(DateTime.now().millisecondsSinceEpoch); // print(DateTime.now().millisecondsSinceEpoch);
if (UserTool.userProvider.userInfo.end * 1000 > if (UserTool.userProvider.userInfo.isVip != 1) {
DateTime.now().microsecondsSinceEpoch) { isVip = false;
isVip = false; vle = false;
vle = false; } else {
} else { isVip = true;
isVip = true; vle = await service.isRunning();
_load(); }
} //service.isRunning() as bool;
//service.isRunning() as bool; endDate = DateUtil.formatDateMs(
endDate = DateUtil.formatDateMs( UserTool.userProvider.userInfo.end * 1000,
UserTool.userProvider.userInfo.end * 1000, format: DateFormats.y_mo_d);
format: DateFormats.y_mo_d); } else {
} else { vle = false;
vle = false; }
} }));
}));
} }
@override @override
@ -359,7 +358,6 @@ class _UserPageState extends State<UserPage> {
prefs.remove("kg"); prefs.remove("kg");
prefs.setBool("kg", vle); prefs.setBool("kg", vle);
service.invoke("stopService"); service.invoke("stopService");
/// ///
// exit(0); // exit(0);
// UserTool.userProvider.setKg(vle); // UserTool.userProvider.setKg(vle);
@ -370,7 +368,7 @@ class _UserPageState extends State<UserPage> {
// print("这是数据${prefs.getBool("kg")}"); // print("这是数据${prefs.getBool("kg")}");
} }
} else { } else {
BotToast.showText(text: "还没有开通会员,不可使用功能"); BotToast.showText(text: "还没有开通会员,不可使用功能");
} }
}); });
}), }),

@ -6,7 +6,7 @@ typedef ItemCallback = Function(ChooseItems item, int index);
class ChooseItems { class ChooseItems {
int month; int month;
int pice; double pice;
bool isChoose; bool isChoose;
ChooseItems({ ChooseItems({

Loading…
Cancel
Save