自定义短信模板

master
戴余标 2 years ago
parent 09f93e1996
commit d93f50e318

@ -6,12 +6,11 @@ class API {
///HOST ///HOST
static String get host { static String get host {
if (DevEV.instance.dev) { if (DevEV.instance.dev) {
// return 'http://10.0.2.2:8088/'; return 'http://10.0.2.2:8088/';
return 'http://api.dxbs.vip'; // return 'http://api.dxbs.vip';
} else { } else {
// return 'http://10.0.2.2:8088/'; return 'http://10.0.2.2:8088/';
// return 'http://api.dxbs.vip/';
return 'http://api.dxbs.vip/';
} }
} }
@ -48,6 +47,8 @@ class _App {
String get delete => '/app/user/content/delete'; String get delete => '/app/user/content/delete';
/// ///
String get checked => '/app/user/content/checked'; String get checked => '/app/user/content/checked';
///
String get find => '/app/user/content/find';
///VIP ///VIP
String get updateVip => '/app/user/updateVip'; String get updateVip => '/app/user/updateVip';
} }

@ -74,7 +74,7 @@ class _MyAppState extends State<MyApp> {
// final service = FlutterBackgroundService(); // final service = FlutterBackgroundService();
_Getpermission(); _Getpermission();
registerWxApi( registerWxApi(
appId: "wxd930ea5d5a228f5f", appId: "wx3a0b41d12afef4e2",
// universalLink:"http://api.dxbs.vip/ " // universalLink:"http://api.dxbs.vip/ "
); );
} }

@ -10,11 +10,13 @@ import '../utils/toast/cloud_toast.dart';
class UserProvider extends ChangeNotifier { class UserProvider extends ChangeNotifier {
bool _isLogin = false; bool _isLogin = false;
bool get isLogin => _isLogin; bool get isLogin => _isLogin;
late UserInfoModel _userInfo; late UserInfoModel _userInfo;
UserInfoModel get userInfo => _userInfo; UserInfoModel get userInfo => _userInfo;
late String _contentCon;
String get contentCon=>_contentCon;
late String _contentRef;
String get contentRef=>_contentRef;
Future<bool> init() async { Future<bool> init() async {
if (HiveStore.appBox?.containsKey('token') ?? false) { if (HiveStore.appBox?.containsKey('token') ?? false) {
@ -29,14 +31,14 @@ class UserProvider extends ChangeNotifier {
} }
} }
Future setToken(String token, {User? user}) async { Future setToken(String token, {User? user}) async {
apiClient.setToken(token); apiClient.setToken(token);
await HiveStore.appBox!.put('token', token); await HiveStore.appBox!.put('token', token);
_isLogin = true; _isLogin = true;
//app //app
await updateUserInfo(); await updateUserInfo();
await updateConSms();
await updateRefSms();
} }
Future logout() async { Future logout() async {
@ -55,4 +57,24 @@ class UserProvider extends ChangeNotifier {
} }
notifyListeners(); 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();
}
} }

@ -8,6 +8,7 @@ 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:permission_handler/permission_handler.dart'; import 'package:permission_handler/permission_handler.dart';
import 'package:permission_handler_platform_interface/permission_handler_platform_interface.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'; import 'package:telephony/telephony.dart';
@ -53,7 +54,7 @@ void onStart(ServiceInstance service ) async {
Timer.periodic(const Duration(seconds: 1), (timer) async { Timer.periodic(const Duration(seconds: 1), (timer) async {
CallState state = await Telephony.instance.callState; CallState state = await Telephony.instance.callState;
callState = state.name; callState = state.name;
// print(callState!+" $flag"); print(123);
if (callState == "IDLE") { if (callState == "IDLE") {
if (flag != 0) { if (flag != 0) {
flag = 0; flag = 0;
@ -68,7 +69,7 @@ void onStart(ServiceInstance service ) async {
Telephony.backgroundInstance.sendSms(to: phoneNum!, message: "接通了"); Telephony.backgroundInstance.sendSms(to: phoneNum!, message: "接通了");
}else{ }else{
print("没接通"); print("没接通");
Telephony.backgroundInstance.sendSms(to: phoneNum!, message: "没接通"); Telephony.backgroundInstance.sendSms(to: phoneNum!, message: UserTool.userProvider.contentCon);
// print('DATE : ${DateTime.fromMillisecondsSinceEpoch(entry.first.timestamp!)}');// // print('DATE : ${DateTime.fromMillisecondsSinceEpoch(entry.first.timestamp!)}');//
// print("你好$phoneNum"); // print("你好$phoneNum");
// // final inbox = telephony.getInboxSms(); // // final inbox = telephony.getInboxSms();
@ -83,6 +84,7 @@ void onStart(ServiceInstance service ) async {
// print('flag $flag'); // print('flag $flag');
} else if (callState == "OFFHOOK") { } else if (callState == "OFFHOOK") {
flag++; flag++;
flag*=-1;
// print('flag $flag'); // print('flag $flag');
} }
}); });

@ -111,6 +111,7 @@ class _ContentConnectPageState extends State<ContentConnectPage> {
if (res.code == 0) { if (res.code == 0) {
setState(() {}); setState(() {});
UserTool.userProvider.updateUserInfo(); UserTool.userProvider.updateUserInfo();
UserTool.userProvider.updateConSms();
_easyRefreshController.callRefresh(); _easyRefreshController.callRefresh();
} else { } else {
CloudToast.show(res.msg); CloudToast.show(res.msg);

@ -112,6 +112,7 @@ class _ContentRefusePageState extends State<ContentRefusePage> {
if (res.code == 0) { if (res.code == 0) {
setState(() {}); setState(() {});
userProvider.updateUserInfo(); userProvider.updateUserInfo();
userProvider.updateRefSms();
_easyRefreshController.callRefresh(); _easyRefreshController.callRefresh();
} else { } else {
CloudToast.show(res.msg); CloudToast.show(res.msg);

@ -36,16 +36,12 @@ class _LoadingState extends State<Loading> {
Future.delayed(const Duration(milliseconds: 1000), () async { Future.delayed(const Duration(milliseconds: 1000), () async {
await initialAll(); await initialAll();
if (!await userProvider.init()) { if (!await userProvider.init()) {
await Get.offAll(() => const LoginPage()); await Get.offAll(() => const TabNavigator());
// await Get.offAll(() => const LoginPage());
} else { } else {
await Get.offAll(() => const TabNavigator()); await Get.offAll(() => const TabNavigator());
} }
}); });
Future.delayed(const Duration(seconds: 3),(){
//3
Navigator.of(context).pushReplacementNamed("/TabNavigator");
});
} }
@override @override

@ -36,7 +36,7 @@ final Telephony telephony = Telephony.instance;
class _UserPageState extends State<UserPage> { class _UserPageState extends State<UserPage> {
// bool vle = PermissionStatus.denied.isGranted; // bool vle = PermissionStatus.denied.isGranted;
//bool vle =PermissionStatus.denied.isGranted; //bool vle =PermissionStatus.denied.isGranted;
// 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;

@ -36,11 +36,7 @@ class SortWidget extends StatelessWidget {
required this.childAspectRatio, required this.childAspectRatio,
this.haveButton = false, this.haveButton = false,
required this.pickItem}); required this.pickItem});
// @override
// void initState() {
// super.initState();
// }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {

Loading…
Cancel
Save