share_manager.dart 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import 'package:fis_i18n/i18n.dart';
  2. import 'package:fis_jsonrpc/rpc.dart';
  3. import 'package:get/get.dart';
  4. import 'package:vitalapp/architecture/utils/prompt_box.dart';
  5. import 'package:vitalapp/managers/interfaces/share.dart';
  6. import 'package:vitalapp/rpc.dart';
  7. import 'interfaces/base_manager.dart';
  8. class ShareManager extends BaseManager implements IShareManager {
  9. /// 邮箱分享报告
  10. ///
  11. /// 若实时诊断的报告code为null就拿远程诊断的报告code
  12. Future<void> submitShareEmail(
  13. String reportCode, List<String> selectedEmails) async {
  14. final result = await rpc.report.shareReportByEmailAsync(
  15. ShareReportByEmailRequest(
  16. emailList: selectedEmails,
  17. token: token,
  18. reportCode: reportCode,
  19. languageCode: i18nBook.locale.toCodeString('-'),
  20. ),
  21. );
  22. if (result) {
  23. PromptBox.toast(i18nBook.user.operationSuccess.t);
  24. Get.back();
  25. } else {
  26. PromptBox.toast(i18nBook.user.operationFailed.t);
  27. }
  28. }
  29. /// 短信分享报告
  30. ///
  31. /// 若实时诊断的报告code为null就拿远程诊断的报告code
  32. Future<void> submitShareSMS(
  33. String reportCode, List<String> selectedPhoneNumbers) async {
  34. final result = await rpc.report.shareReportBySmsAsync(
  35. ShareReportBySmsRequest(
  36. mobileList: selectedPhoneNumbers,
  37. token: token,
  38. reportCode: reportCode,
  39. languageCode: i18nBook.locale.toCodeString('-'),
  40. ),
  41. );
  42. if (result) {
  43. PromptBox.toast(i18nBook.user.operationSuccess.t);
  44. Get.back();
  45. } else {
  46. PromptBox.toast(i18nBook.user.operationFailed.t);
  47. }
  48. }
  49. }