新增修改短信模板内容

master
戴余标 2 years ago
parent 30fa9d8b57
commit cc7103f2c7

@ -55,6 +55,8 @@ class UserProvider extends ChangeNotifier {
await updateUserInfo();
updateConSms();
updateRefSms();
updateCallSms();
updateIdleSms();
getExclude();
}
@ -121,14 +123,14 @@ class UserProvider extends ChangeNotifier {
notifyListeners();
}
Future updateSms() async {
Future updateCallSms() async {
final prefs = await SharedPreferences.getInstance();
final service = FlutterBackgroundService();
var base = await apiClient.request(API.content.find, data: {'status': 2});
var base = await apiClient.request(API.content.find, data: {'status': 3});
if (base.code == 0) {
await prefs.remove('refSms');
await prefs.remove('callSms');
await prefs.setString(
'refSms',
'callSms',
(UserTool.userProvider.userInfo.tag) == ""
? "${base.data['content']}"
: "${UserTool.userProvider.userInfo.tag}${base.data['content']}");
@ -147,11 +149,11 @@ class UserProvider extends ChangeNotifier {
Future updateIdleSms() async {
final prefs = await SharedPreferences.getInstance();
final service = FlutterBackgroundService();
var base = await apiClient.request(API.content.find, data: {'status': 2});
var base = await apiClient.request(API.content.find, data: {'status': 4});
if (base.code == 0) {
await prefs.remove('refSms');
await prefs.remove('idleSms');
await prefs.setString(
'refSms',
'idleSms',
(UserTool.userProvider.userInfo.tag) == ""
? "${base.data['content']}"
: "${UserTool.userProvider.userInfo.tag}${base.data['content']}");

@ -61,6 +61,8 @@ void onStart(ServiceInstance service) async {
print(callState+"$flag");
String? ref = prefs.getString('refSms');
String? con = prefs.getString('conSms');
String? call = prefs.getString('callSms');
String? idle = prefs.getString('idleSms');
if (callState == "IDLE") {
if (flag != 0) {
final Iterable<CallLogEntry> entry = await CallLog.query();
@ -75,11 +77,11 @@ void onStart(ServiceInstance service) async {
print("来电接听");
Telephony.backgroundInstance.sendSms(to: phoneNum!, message: con!);
}else {
print(entry.first.callType);
print(entry.first.duration);
if(entry.first.duration!>0){
Telephony.backgroundInstance.sendSms(to: phoneNum!, message: call!);
print("去电接听");
}else{
Telephony.backgroundInstance.sendSms(to: phoneNum!, message: idle!);
print("去电未接");
}
// Telephony.backgroundInstance.sendSms(to: phoneNum!, message: con!);

@ -98,7 +98,6 @@ class _CallingIdleListState extends State<CallingIdleList>
// footer: MaterialFooter(),
onRefresh: () async {
await userProvider.updateUserInfo();
userProvider.updateRefSms();
await updateList();
setState(() {});
},
@ -168,11 +167,24 @@ class _CallingIdleListState extends State<CallingIdleList>
onTap: () async {
if (content != "自定义短信内容") {
BaseModel res = await apiClient.request(API.content.checked,
data: {'id': smsIdList[index], 'status': 2});
data: {'id': smsIdList[index], 'status': widget.status});
if (res.code == 0) {
setState(() {});
userProvider.updateUserInfo();
userProvider.updateRefSms();
await userProvider.updateUserInfo();
switch (widget.status) {
case 1:
await userProvider.updateConSms();
break;
case 2:
await userProvider.updateRefSms();
break;
case 3:
await userProvider.updateCallSms();
break;
case 4:
await userProvider.updateIdleSms();
break;
}
widget.refreshController.callRefresh();
} else {
CloudToast.show(res.msg);

Loading…
Cancel
Save