From 741c10316174b148f795a0442b7e7bd8ce709cec Mon Sep 17 00:00:00 2001 From: wylyl22 <2373073266@qq.com> Date: Fri, 16 Sep 2022 10:38:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/app/build.gradle | 16 ++++++++++ lib/providers/user_provider.dart | 4 +-- lib/ui/home/calling_idle_list.dart | 4 +-- lib/ui/home/set/phone_set_page.dart | 46 ++++++++++++++--------------- lib/ui/user/user_card_page.dart | 1 + lib/ui/user/user_page.dart | 25 +++++++++++++--- 6 files changed, 65 insertions(+), 31 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 22d2e51..a6bed65 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -19,7 +19,23 @@ if (flutterVersionCode == null) { def flutterVersionName = localProperties.getProperty('flutter.versionName') if (flutterVersionName == null) { flutterVersionName = '1.0' +}else{ + //截取版本号最后一段数字 + def tem1=Integer.parseInt(flutterVersionName.substring(flutterVersionName.lastIndexof(".")+1,flutterVersionName.length())) + tem1++ + //组成新的版本号,并更新localProperties对象和fluttervarsionName变量 + def newVersionName=flutterVersionName.substring(0,flutterVersionName.lastIndexof(".")+1)+tem1 + localProperties.setProperty("flutter.versionName",newVersionName) + flutterVersionName=newVersionName + //localproperyies对象转换成string,并更新local.properties文件 + def newLocalProperties=localProperties.toString() + newLocalProperties =newLocalProperties.replace(",","\n") + newLocalProperties =newLocalProperties.replace("{","") + newLocalProperties =newLocalProperties.replace("}","") + localPropertiesFile.write(newLocalProperties) + } + def keystoreProperties = new Properties() def keystorePropertiesFile = rootProject.file('key.properties') if (keystorePropertiesFile.exists()) { diff --git a/lib/providers/user_provider.dart b/lib/providers/user_provider.dart index 3bb9bc6..ba7e2e8 100644 --- a/lib/providers/user_provider.dart +++ b/lib/providers/user_provider.dart @@ -209,8 +209,8 @@ class UserProvider extends ChangeNotifier { for (int i = 0; i < numberList.length; i++) { numList.add(numberList[i].phone); } - await prefs.setStringList("specified", numList ?? []); - await prefs.setStringList("addressList", numbers ?? []); + await prefs.setStringList("specified", numList); + await prefs.setStringList("addressList", numbers); service.invoke("stopService"); if (prefs.getBool('kg')!) { diff --git a/lib/ui/home/calling_idle_list.dart b/lib/ui/home/calling_idle_list.dart index e22def4..e83d3e0 100644 --- a/lib/ui/home/calling_idle_list.dart +++ b/lib/ui/home/calling_idle_list.dart @@ -58,7 +58,7 @@ class _CallingIdleListState extends State Future getSwitch() async { final SharedPreferences prefs = await _prefs; - val = prefs.getBool(widget.name!)!; + val = prefs.getBool(widget.name!) ?? false; print(val); } @@ -180,7 +180,7 @@ class _CallingIdleListState extends State setState(() { val = value; prefs.remove(widget.name!); - prefs.setBool(widget.name!, val); + prefs.setBool(widget.name!, val ); }); service.invoke("stopService"); if (prefs.getBool('kg')!) { diff --git a/lib/ui/home/set/phone_set_page.dart b/lib/ui/home/set/phone_set_page.dart index 4a3d3d8..95706c3 100644 --- a/lib/ui/home/set/phone_set_page.dart +++ b/lib/ui/home/set/phone_set_page.dart @@ -192,18 +192,18 @@ class _PhoneSetPageState extends State { final service = FlutterBackgroundService(); return GestureDetector( onTap: () async { - // final SharedPreferences prefs = await SharedPreferences.getInstance(); - // select = index; - // await prefs.setInt("numIndex", index); - // service.invoke("stopService"); - // if (prefs.getBool('kg')!) { - // Future.delayed(const Duration(seconds: 1), () async { - // service.startService(); - // }); - // } - // - // UserTool.userProvider.viewLoading(); - // _refreshController.callRefresh(); + final SharedPreferences prefs = await SharedPreferences.getInstance(); + select = index; + await prefs.setInt("numIndex", index); + service.invoke("stopService"); + if (prefs.getBool('kg') ?? false) { + Future.delayed(const Duration(seconds: 1), () async { + service.startService(); + }); + } + + UserTool.userProvider.viewLoading(); + _refreshController.callRefresh(); // print(_selectIndex); setState(() {}); }, @@ -228,17 +228,17 @@ class _PhoneSetPageState extends State { height: 40.w, child: Radio( onChanged: (int? value) async{ - final SharedPreferences prefs = await SharedPreferences.getInstance(); - select = index; - await prefs.setInt("numIndex", index); - service.invoke("stopService"); - if (prefs.getBool('kg')!) { - Future.delayed(const Duration(seconds: 1), () async { - service.startService(); - }); - } - UserTool.userProvider.viewLoading(); - _refreshController.callRefresh(); + // final SharedPreferences prefs = await SharedPreferences.getInstance(); + // select = index; + // await prefs.setInt("numIndex", index); + // service.invoke("stopService"); + // if (prefs.getBool('kg')!) { + // Future.delayed(const Duration(seconds: 1), () async { + // service.startService(); + // }); + // } + // UserTool.userProvider.viewLoading(); + // _refreshController.callRefresh(); // select = index; // print(_selectIndex); setState(() {}); diff --git a/lib/ui/user/user_card_page.dart b/lib/ui/user/user_card_page.dart index e3ab8a6..4a444ce 100644 --- a/lib/ui/user/user_card_page.dart +++ b/lib/ui/user/user_card_page.dart @@ -75,6 +75,7 @@ class _UserCardPageState extends State { }else{ var res= await UserInfoFunc.getAddVip(cardMi); if(res){ + // Navigator.pop(context,true); Get.back(); } // CloudToast.show("卡密兑换成功"); diff --git a/lib/ui/user/user_page.dart b/lib/ui/user/user_page.dart index 8dd6305..ad9f939 100644 --- a/lib/ui/user/user_page.dart +++ b/lib/ui/user/user_page.dart @@ -122,6 +122,7 @@ class _UserPageState extends State { _getRequests(); // await UserTool.userProvider.updateUserInfo(); if (UserTool.userProvider.isLogin) { + // var res=await apiClient.request(API.app.trialVip); if (UserTool.userProvider.userInfo.isTrial == 0) { showDialog( @@ -145,7 +146,9 @@ class _UserPageState extends State { // UserTool.userProvider.userInfo.end * 1000, // format: DateFormats.y_mo_d); } else { + vle = false; + Get.to(()=>const LoginPage()); } setState(() {}); }, @@ -293,14 +296,17 @@ class _UserPageState extends State { } else { isVip = true; vle = await service.isRunning(); + _easyRefreshController.callRefresh(); } //service.isRunning() as bool; // endDate = DateUtil.formatDateMs( // UserTool.userProvider.userInfo.end * 1000, // format: DateFormats.y_mo_d); + } else { vle = false; } +// setState(() {}); } @@ -420,20 +426,25 @@ class _UserPageState extends State { print("true"); prefs.remove("kg"); prefs.setBool("kg", vle); + // Future.delayed(const Duration(seconds: 1), () async { + // service.startService(); + // }); service.startService(); // WidgetsFlutterBinding.ensureInitialized(); // initializeService(); // UserTool.userProvider.setKg(vle) // initializeService(); - initializeService(); + // initializeService(); BotToast.showText(text: " 你开启了该功能"); // initializeService(); // print("这是数据${prefs.getBool("kg")}"); } else { prefs.remove("kg"); prefs.setBool("kg", vle); + // Future.delayed(const Duration(seconds: 1), () async { + // service.invoke("stopService"); + // }); service.invoke("stopService"); - ///有问题?? // exit(0); // UserTool.userProvider.setKg(vle); @@ -476,18 +487,24 @@ class _UserPageState extends State { )); break; case "卡密兑换": - Navigator.of(context) .push( MaterialPageRoute(builder: (_) => const UserCardPage()), ) - .then((val) => _easyRefreshController.callRefresh()); + .then((val) => _getRequests() + + + // _easyRefreshController.callRefresh() + + + ); break; default: break; } } }, + child: Container( padding: EdgeInsets.symmetric(horizontal: 32.w), child: ListTile(