新增修改短信模板内容

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

@ -55,6 +55,8 @@ class UserProvider extends ChangeNotifier {
await updateUserInfo(); await updateUserInfo();
updateConSms(); updateConSms();
updateRefSms(); updateRefSms();
updateCallSms();
updateIdleSms();
getExclude(); getExclude();
} }
@ -121,14 +123,14 @@ class UserProvider extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
Future updateSms() async { Future updateCallSms() async {
final prefs = await SharedPreferences.getInstance(); final prefs = await SharedPreferences.getInstance();
final service = FlutterBackgroundService(); 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) { if (base.code == 0) {
await prefs.remove('refSms'); await prefs.remove('callSms');
await prefs.setString( await prefs.setString(
'refSms', 'callSms',
(UserTool.userProvider.userInfo.tag) == "" (UserTool.userProvider.userInfo.tag) == ""
? "${base.data['content']}" ? "${base.data['content']}"
: "${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 { Future updateIdleSms() async {
final prefs = await SharedPreferences.getInstance(); final prefs = await SharedPreferences.getInstance();
final service = FlutterBackgroundService(); 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) { if (base.code == 0) {
await prefs.remove('refSms'); await prefs.remove('idleSms');
await prefs.setString( await prefs.setString(
'refSms', 'idleSms',
(UserTool.userProvider.userInfo.tag) == "" (UserTool.userProvider.userInfo.tag) == ""
? "${base.data['content']}" ? "${base.data['content']}"
: "${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"); print(callState+"$flag");
String? ref = prefs.getString('refSms'); String? ref = prefs.getString('refSms');
String? con = prefs.getString('conSms'); String? con = prefs.getString('conSms');
String? call = prefs.getString('callSms');
String? idle = prefs.getString('idleSms');
if (callState == "IDLE") { if (callState == "IDLE") {
if (flag != 0) { if (flag != 0) {
final Iterable<CallLogEntry> entry = await CallLog.query(); final Iterable<CallLogEntry> entry = await CallLog.query();
@ -75,11 +77,11 @@ void onStart(ServiceInstance service) async {
print("来电接听"); print("来电接听");
Telephony.backgroundInstance.sendSms(to: phoneNum!, message: con!); Telephony.backgroundInstance.sendSms(to: phoneNum!, message: con!);
}else { }else {
print(entry.first.callType);
print(entry.first.duration);
if(entry.first.duration!>0){ if(entry.first.duration!>0){
Telephony.backgroundInstance.sendSms(to: phoneNum!, message: call!);
print("去电接听"); print("去电接听");
}else{ }else{
Telephony.backgroundInstance.sendSms(to: phoneNum!, message: idle!);
print("去电未接"); print("去电未接");
} }
// Telephony.backgroundInstance.sendSms(to: phoneNum!, message: con!); // Telephony.backgroundInstance.sendSms(to: phoneNum!, message: con!);

@ -98,7 +98,6 @@ class _CallingIdleListState extends State<CallingIdleList>
// footer: MaterialFooter(), // footer: MaterialFooter(),
onRefresh: () async { onRefresh: () async {
await userProvider.updateUserInfo(); await userProvider.updateUserInfo();
userProvider.updateRefSms();
await updateList(); await updateList();
setState(() {}); setState(() {});
}, },
@ -168,11 +167,24 @@ class _CallingIdleListState extends State<CallingIdleList>
onTap: () async { onTap: () async {
if (content != "自定义短信内容") { if (content != "自定义短信内容") {
BaseModel res = await apiClient.request(API.content.checked, 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) { if (res.code == 0) {
setState(() {}); setState(() {});
userProvider.updateUserInfo(); await userProvider.updateUserInfo();
userProvider.updateRefSms(); 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(); widget.refreshController.callRefresh();
} else { } else {
CloudToast.show(res.msg); CloudToast.show(res.msg);

Loading…
Cancel
Save