|
|
@ -1,7 +1,10 @@
|
|
|
|
|
|
|
|
import 'dart:io';
|
|
|
|
|
|
|
|
|
|
|
|
import 'package:bot_toast/bot_toast.dart';
|
|
|
|
import 'package:bot_toast/bot_toast.dart';
|
|
|
|
import 'package:flustars/flustars.dart';
|
|
|
|
import 'package:flustars/flustars.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:permission_handler/permission_handler.dart';
|
|
|
|
import 'package:permission_handler/permission_handler.dart';
|
|
|
|
import 'package:project_telephony/base/base_style.dart';
|
|
|
|
import 'package:project_telephony/base/base_style.dart';
|
|
|
|
import 'package:project_telephony/ui/login/login_page.dart';
|
|
|
|
import 'package:project_telephony/ui/login/login_page.dart';
|
|
|
@ -43,17 +46,21 @@ class _UserPageState extends State<UserPage> {
|
|
|
|
final userProvider = Provider.of<UserProvider>(Get.context!, listen: false);
|
|
|
|
final userProvider = Provider.of<UserProvider>(Get.context!, listen: false);
|
|
|
|
bool isVip = false;
|
|
|
|
bool isVip = false;
|
|
|
|
String? endDate;
|
|
|
|
String? endDate;
|
|
|
|
bool vle = UserTool.userProvider.userInfo.isVip==1;
|
|
|
|
late bool vle;
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
super.initState();
|
|
|
|
if ( UserTool.userProvider.isLogin) {
|
|
|
|
if ( UserTool.userProvider.isLogin) {
|
|
|
|
if (UserTool.userProvider.userInfo.end<=DateTime.now().millisecondsSinceEpoch ) {
|
|
|
|
if (UserTool.userProvider.userInfo.end<=DateTime.now().millisecondsSinceEpoch ) {
|
|
|
|
isVip = false;
|
|
|
|
isVip = false;
|
|
|
|
|
|
|
|
vle =false;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
|
|
|
|
vle =true;
|
|
|
|
isVip = true;
|
|
|
|
isVip = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
endDate=DateUtil.formatDateMs(UserTool.userProvider.userInfo.end * 1000, format: DateFormats.y_mo_d);
|
|
|
|
endDate=DateUtil.formatDateMs(UserTool.userProvider.userInfo.end * 1000, format: DateFormats.y_mo_d);
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
vle = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -261,6 +268,9 @@ class _UserPageState extends State<UserPage> {
|
|
|
|
|
|
|
|
|
|
|
|
//内容
|
|
|
|
//内容
|
|
|
|
_getSwitch2(){
|
|
|
|
_getSwitch2(){
|
|
|
|
|
|
|
|
// final service=FlutterBackgroundService();
|
|
|
|
|
|
|
|
// ServiceInstance service;
|
|
|
|
|
|
|
|
|
|
|
|
return Container(
|
|
|
|
return Container(
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 32.w),
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 32.w),
|
|
|
|
child: ListTile(
|
|
|
|
child: ListTile(
|
|
|
@ -281,24 +291,46 @@ class _UserPageState extends State<UserPage> {
|
|
|
|
trailing: Switch(
|
|
|
|
trailing: Switch(
|
|
|
|
value: vle,
|
|
|
|
value: vle,
|
|
|
|
onChanged: (value) async {
|
|
|
|
onChanged: (value) async {
|
|
|
|
|
|
|
|
final service = FlutterBackgroundService();
|
|
|
|
|
|
|
|
var isRunning = await service.isRunning();
|
|
|
|
final SharedPreferences prefs = await _prefs;
|
|
|
|
final SharedPreferences prefs = await _prefs;
|
|
|
|
await prefs.setBool("kg", value);
|
|
|
|
// if(!value){
|
|
|
|
print("这是数据${prefs.getBool("kg")}");
|
|
|
|
//
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// await prefs.setBool("kg", value);
|
|
|
|
|
|
|
|
// print("这是数据${prefs.getBool("kg")}");
|
|
|
|
setState(() {
|
|
|
|
setState(() {
|
|
|
|
if(!isVip){
|
|
|
|
if(!isVip){
|
|
|
|
vle=value;
|
|
|
|
vle=value;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// prefs.setBool("kg", vle);
|
|
|
|
|
|
|
|
// initializeService();
|
|
|
|
if(vle){
|
|
|
|
if(vle){
|
|
|
|
print("true");
|
|
|
|
print("true");
|
|
|
|
UserTool.userProvider.setKg(vle);
|
|
|
|
prefs.remove("kg");
|
|
|
|
// prefs.setBool("kg", vle);
|
|
|
|
prefs.setBool("kg", vle);
|
|
|
|
|
|
|
|
service.startService();
|
|
|
|
|
|
|
|
// WidgetsFlutterBinding.ensureInitialized();
|
|
|
|
|
|
|
|
// initializeService();
|
|
|
|
|
|
|
|
// UserTool.userProvider.setKg(vle)
|
|
|
|
|
|
|
|
// initializeService();
|
|
|
|
|
|
|
|
// initializeService();
|
|
|
|
BotToast.showText(text: " 你开启了该功能");
|
|
|
|
BotToast.showText(text: " 你开启了该功能");
|
|
|
|
|
|
|
|
// initializeService();
|
|
|
|
// print("这是数据${prefs.getBool("kg")}");
|
|
|
|
// print("这是数据${prefs.getBool("kg")}");
|
|
|
|
}else{
|
|
|
|
}else{
|
|
|
|
print("false");
|
|
|
|
print("false");
|
|
|
|
UserTool.userProvider.setKg(vle);
|
|
|
|
prefs.remove("kg");
|
|
|
|
// prefs.setBool("kg", vle);
|
|
|
|
prefs.setBool("kg", vle);
|
|
|
|
|
|
|
|
service.invoke("stopService");
|
|
|
|
|
|
|
|
// exit(0);
|
|
|
|
|
|
|
|
// UserTool.userProvider.setKg(vle);
|
|
|
|
|
|
|
|
// prefs.setBool("kg", false);
|
|
|
|
|
|
|
|
// initializeService();
|
|
|
|
|
|
|
|
|
|
|
|
BotToast.showText(text: "你已经关闭该功能");
|
|
|
|
BotToast.showText(text: "你已经关闭该功能");
|
|
|
|
// print("这是数据${prefs.getBool("kg")}");
|
|
|
|
|
|
|
|
|
|
|
|
// print("这是数据${UserTool.userProvider.kg}");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
}else{
|
|
|
|
BotToast.showText(text: "还没有开通会员,不可使用改功能");
|
|
|
|
BotToast.showText(text: "还没有开通会员,不可使用改功能");
|
|
|
|