Daisy 4c9dd152ca 1,修复密码详情分享报错问题
2,完成密码模块系统邮件通知、短信通知发送的对接及兼容
2024-06-12 16:49:39 +08:00

54 lines
2.1 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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';
class SendEmailNotificationLogic extends BaseGetXController {
final SendEmailNotificationState state = SendEmailNotificationState();
//获取电子钥匙通知模板 渠道1短信 2邮箱
Future<void> getKeyNoticeTemplate() async {
final SendEmailNotificationEntity entity =
await ApiRepository.to.getKeyNoticeTemplate(
lockId: CommonDataManage().currentKeyInfo.lockId ?? 0,
keyId: state.getKeyId.value,
channelType: state.channelType.value,
);
if (entity.errorCode!.codeIsSuccessful) {
state.emailTemplateList.value =
entity.data?.list ?? <EmailNotificationItem>[];
state.currentNotifyItem.value = state.emailTemplateList.first;
state.templateContentController.text =
state.currentNotifyItem.value.template ?? '';
state.emailTemplateList.refresh();
state.currentNotifyItem.refresh();
}
}
//发送短信、邮件通知 channelType--1短信 2邮件 opisAPKFileName
Future<void> keyNoticeSubmitRequest() async {
if (state.receiverController.text.isEmpty &&
state.getReceiver.value.isEmpty) {
showToast('请输入接收者');
return;
}
final SendEmailNotificationEntity entity =
await ApiRepository.to.keyNoticeSubmit(
receiverName: state.getReceiver.value.isEmpty
? state.receiverController.text
: state.getReceiver.value,
lockId: CommonDataManage().currentKeyInfo.lockId ?? 0,
keyId: state.getKeyId.value,
channelType: state.channelType.value,
openDoorType: 1,
templateType: state.currentNotifyItem.value.type ?? '',
);
if (entity.errorCode!.codeIsSuccessful) {
showToast('发送成功');
Get.back();
}
}
}