From d93f50e3187cfb912fde63fd663426eb18dc6753 Mon Sep 17 00:00:00 2001 From: datang Date: Wed, 24 Aug 2022 15:07:31 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E7=9F=AD=E4=BF=A1?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/constants/api.dart | 11 +++++----- lib/main.dart | 2 +- lib/providers/user_provider.dart | 30 +++++++++++++++++++++++---- lib/ui/home/call.dart | 6 ++++-- lib/ui/home/content_connect_page.dart | 1 + lib/ui/home/content_refuse_page.dart | 1 + lib/ui/loading.dart | 8 ++----- lib/ui/user/user_page.dart | 2 +- lib/ui/widget/putup_widget.dart | 4 ---- 9 files changed, 42 insertions(+), 23 deletions(-) diff --git a/lib/constants/api.dart b/lib/constants/api.dart index c8dc7e2..a149a82 100644 --- a/lib/constants/api.dart +++ b/lib/constants/api.dart @@ -6,12 +6,11 @@ class API { ///HOST static String get host { if (DevEV.instance.dev) { - // return 'http://10.0.2.2:8088/'; - return 'http://api.dxbs.vip'; + return 'http://10.0.2.2:8088/'; + // return 'http://api.dxbs.vip'; } else { - // return 'http://10.0.2.2:8088/'; - - return 'http://api.dxbs.vip/'; + return 'http://10.0.2.2:8088/'; + // return 'http://api.dxbs.vip/'; } } @@ -48,6 +47,8 @@ class _App { String get delete => '/app/user/content/delete'; ///选择自定义短信 String get checked => '/app/user/content/checked'; + ///查找短信 + String get find => '/app/user/content/find'; ///更新VIP状态(已合并至用户信息) String get updateVip => '/app/user/updateVip'; } diff --git a/lib/main.dart b/lib/main.dart index ef1c58f..fde5f4f 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -74,7 +74,7 @@ class _MyAppState extends State { // final service = FlutterBackgroundService(); _Getpermission(); registerWxApi( - appId: "wxd930ea5d5a228f5f", + appId: "wx3a0b41d12afef4e2", // universalLink:"http://api.dxbs.vip/ " ); } diff --git a/lib/providers/user_provider.dart b/lib/providers/user_provider.dart index 1601a47..b7fa798 100644 --- a/lib/providers/user_provider.dart +++ b/lib/providers/user_provider.dart @@ -10,11 +10,13 @@ import '../utils/toast/cloud_toast.dart'; class UserProvider extends ChangeNotifier { bool _isLogin = false; - bool get isLogin => _isLogin; late UserInfoModel _userInfo; - UserInfoModel get userInfo => _userInfo; + late String _contentCon; + String get contentCon=>_contentCon; + late String _contentRef; + String get contentRef=>_contentRef; Future init() async { if (HiveStore.appBox?.containsKey('token') ?? false) { @@ -29,14 +31,14 @@ class UserProvider extends ChangeNotifier { } } - - Future setToken(String token, {User? user}) async { apiClient.setToken(token); await HiveStore.appBox!.put('token', token); _isLogin = true; //每次打开app更新用户信息 await updateUserInfo(); + await updateConSms(); + await updateRefSms(); } Future logout() async { @@ -55,4 +57,24 @@ class UserProvider extends ChangeNotifier { } notifyListeners(); } + + Future updateConSms() async { + var base = await apiClient.request(API.app.find,data: {'status': 1}); + if (base.code == 0) { + _contentCon = base.data['content']; + } else { + CloudToast.show(base.msg); + } + notifyListeners(); + } + + Future updateRefSms() async { + var base = await apiClient.request(API.app.find,data: {'status': 2}); + if (base.code == 0) { + _contentRef = base.data['content']; + } else { + CloudToast.show(base.msg); + } + notifyListeners(); + } } diff --git a/lib/ui/home/call.dart b/lib/ui/home/call.dart index 012b409..f53fd17 100644 --- a/lib/ui/home/call.dart +++ b/lib/ui/home/call.dart @@ -8,6 +8,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter_background_service/flutter_background_service.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:permission_handler_platform_interface/permission_handler_platform_interface.dart'; +import 'package:project_telephony/utils/user_tool.dart'; import 'package:telephony/telephony.dart'; @@ -53,7 +54,7 @@ void onStart(ServiceInstance service ) async { Timer.periodic(const Duration(seconds: 1), (timer) async { CallState state = await Telephony.instance.callState; callState = state.name; - // print(callState!+" $flag"); + print(123); if (callState == "IDLE") { if (flag != 0) { flag = 0; @@ -68,7 +69,7 @@ void onStart(ServiceInstance service ) async { Telephony.backgroundInstance.sendSms(to: phoneNum!, message: "接通了"); }else{ print("没接通"); - Telephony.backgroundInstance.sendSms(to: phoneNum!, message: "没接通"); + Telephony.backgroundInstance.sendSms(to: phoneNum!, message: UserTool.userProvider.contentCon); // print('DATE : ${DateTime.fromMillisecondsSinceEpoch(entry.first.timestamp!)}');//拨通时间 // print("你好$phoneNum"); // // final inbox = telephony.getInboxSms(); @@ -83,6 +84,7 @@ void onStart(ServiceInstance service ) async { // print('flag $flag'); } else if (callState == "OFFHOOK") { flag++; + flag*=-1; // print('flag $flag'); } }); diff --git a/lib/ui/home/content_connect_page.dart b/lib/ui/home/content_connect_page.dart index dccd62d..8222e88 100644 --- a/lib/ui/home/content_connect_page.dart +++ b/lib/ui/home/content_connect_page.dart @@ -111,6 +111,7 @@ class _ContentConnectPageState extends State { if (res.code == 0) { setState(() {}); UserTool.userProvider.updateUserInfo(); + UserTool.userProvider.updateConSms(); _easyRefreshController.callRefresh(); } else { CloudToast.show(res.msg); diff --git a/lib/ui/home/content_refuse_page.dart b/lib/ui/home/content_refuse_page.dart index 09a97cf..a31c829 100644 --- a/lib/ui/home/content_refuse_page.dart +++ b/lib/ui/home/content_refuse_page.dart @@ -112,6 +112,7 @@ class _ContentRefusePageState extends State { if (res.code == 0) { setState(() {}); userProvider.updateUserInfo(); + userProvider.updateRefSms(); _easyRefreshController.callRefresh(); } else { CloudToast.show(res.msg); diff --git a/lib/ui/loading.dart b/lib/ui/loading.dart index 71bac28..263f102 100644 --- a/lib/ui/loading.dart +++ b/lib/ui/loading.dart @@ -36,16 +36,12 @@ class _LoadingState extends State { Future.delayed(const Duration(milliseconds: 1000), () async { await initialAll(); if (!await userProvider.init()) { - await Get.offAll(() => const LoginPage()); + await Get.offAll(() => const TabNavigator()); + // await Get.offAll(() => const LoginPage()); } else { await Get.offAll(() => const TabNavigator()); } }); - Future.delayed(const Duration(seconds: 3),(){ - //3秒后跳转到其他路由 - Navigator.of(context).pushReplacementNamed("/TabNavigator"); - }); - } @override diff --git a/lib/ui/user/user_page.dart b/lib/ui/user/user_page.dart index 9ca90a8..689ba31 100644 --- a/lib/ui/user/user_page.dart +++ b/lib/ui/user/user_page.dart @@ -36,7 +36,7 @@ final Telephony telephony = Telephony.instance; class _UserPageState extends State { // bool vle = PermissionStatus.denied.isGranted; //bool vle =PermissionStatus.denied.isGranted; - // final userProvider = Provider.of(Get.context!, listen: false); + final userProvider = Provider.of(Get.context!, listen: false); bool isVip = false; String? endDate; diff --git a/lib/ui/widget/putup_widget.dart b/lib/ui/widget/putup_widget.dart index b11b38f..e136a81 100644 --- a/lib/ui/widget/putup_widget.dart +++ b/lib/ui/widget/putup_widget.dart @@ -36,11 +36,7 @@ class SortWidget extends StatelessWidget { required this.childAspectRatio, this.haveButton = false, required this.pickItem}); -// @override -// void initState() { -// super.initState(); -// } @override Widget build(BuildContext context) {