Merge branch 'release' of https://gitee.com/starlock-cn/app-starlock into release
This commit is contained in:
commit
003b213ba8
@ -1,9 +1,12 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/sendEmailNotification/sendEmailNotification_entity.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/sendEmailNotification/sendEmailNotification_state.dart';
|
||||
import 'package:star_lock/network/api_repository.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import 'package:star_lock/tools/commonDataManage.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
class SendEmailNotificationLogic extends BaseGetXController {
|
||||
final SendEmailNotificationState state = SendEmailNotificationState();
|
||||
@ -50,4 +53,40 @@ class SendEmailNotificationLogic extends BaseGetXController {
|
||||
Get.back();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> sendPersonalSMSOrEmail() async {
|
||||
if (state.channelType.value == 1) {
|
||||
//短信
|
||||
final String phoneNumber = state.getReceiver.value.isEmpty
|
||||
? state.receiverController.text
|
||||
: state.getReceiver.value;
|
||||
final String message = state.templateContentController.text;
|
||||
final Uri smsUri =
|
||||
Uri.parse('sms:$phoneNumber&body=${Uri.encodeComponent(message)}');
|
||||
|
||||
if (await canLaunchUrl(smsUri)) {
|
||||
await launchUrl(smsUri);
|
||||
} else {
|
||||
throw 'Could not launch $smsUri';
|
||||
}
|
||||
} else if (state.channelType.value == 2) {
|
||||
//邮箱
|
||||
final Uri emailUri = Uri(
|
||||
scheme: 'mailto',
|
||||
path: state.getReceiver.value.isEmpty
|
||||
? state.receiverController.text
|
||||
: state.getReceiver.value,
|
||||
queryParameters: <String, String>{
|
||||
'subject': state.currentNotifyItem.value.name ?? '',
|
||||
'body': state.templateContentController.text,
|
||||
},
|
||||
);
|
||||
|
||||
if (await canLaunchUrl(emailUri)) {
|
||||
await launchUrl(emailUri);
|
||||
} else {
|
||||
throw 'Could not launch $emailUri';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -137,7 +137,9 @@ class _SendEmailNotificationPageState extends State<SendEmailNotificationPage> {
|
||||
onClick: () {
|
||||
if (state.notifyTypeSelect.value == 1) {
|
||||
logic.keyNoticeSubmitRequest();
|
||||
} else {}
|
||||
} else {
|
||||
logic.sendPersonalSMSOrEmail();
|
||||
}
|
||||
}),
|
||||
],
|
||||
),
|
||||
|
||||
@ -15,19 +15,6 @@ class SendEmailNotificationState {
|
||||
if (Get.arguments['channelType'] != null) {
|
||||
channelType.value = Get.arguments['channelType'];
|
||||
updateNotifyTypeText();
|
||||
// if (channelType.value == 1) {
|
||||
// if (notifyTypeSelect.value == 1) {
|
||||
// getNotifyTypeText.value = '系统短信';
|
||||
// } else {
|
||||
// getNotifyTypeText.value = '个人短信';
|
||||
// }
|
||||
// } else {
|
||||
// if (notifyTypeSelect.value == 1) {
|
||||
// getNotifyTypeText.value = '系统邮件';
|
||||
// } else {
|
||||
// getNotifyTypeText.value = '个人邮件';
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user