TotastUtils.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /* eslint-disable no-use-before-define */
  2. /* eslint-disable no-console */
  3. import React from 'react';
  4. import { Modal } from '@ant-design/react-native';
  5. import { Text } from 'react-native-magnus';
  6. import * as Linking from 'expo-linking';
  7. import i18n from '../i18n';
  8. import { navigate } from '../navigation/RootNavigation';
  9. export function alert(title, content, submitEvent) {
  10. Modal.alert(
  11. <Text textAlign="center" fontWeight="bold">
  12. {title || i18n.t('ti-shi')}
  13. </Text>,
  14. <Text fontSize="sm" color="red500" textAlign="center">
  15. {content}
  16. </Text>,
  17. [
  18. {
  19. text: i18n.t('qu-xiao'),
  20. onPress: () => console.log('cancel'),
  21. style: { color: '#000', fontSize: 12, lineHeight: 30 },
  22. },
  23. {
  24. text: i18n.t('que-ding'),
  25. onPress: () => {
  26. if (submitEvent) {
  27. submitEvent();
  28. }
  29. },
  30. style: { color: '#FFC21C', fontSize: 12, lineHeight: 30 },
  31. },
  32. ]
  33. );
  34. }
  35. export function alertWithoutCancel(title, content, isError, submitEvent) {
  36. Modal.alert(
  37. !!title && (
  38. <Text textAlign="center" fontWeight="bold">
  39. {title || ''}
  40. </Text>
  41. ),
  42. <Text
  43. fontSize="sm"
  44. color={isError ? 'red500' : 'gray600'}
  45. textAlign="center"
  46. >
  47. {content}
  48. </Text>,
  49. [
  50. {
  51. text: i18n.t('que-ding'),
  52. onPress: () => {
  53. if (submitEvent) {
  54. submitEvent();
  55. }
  56. },
  57. style: { color: '#FFC21C', fontSize: 12, lineHeight: 30 },
  58. },
  59. ]
  60. );
  61. }
  62. export function operation() {
  63. Modal.operation([
  64. { text: '标为未读', onPress: () => console.log('标为未读被点击了') },
  65. { text: '置顶聊天', onPress: () => console.log('置顶聊天被点击了') },
  66. ]);
  67. }
  68. export function connectKefu(orderId) {
  69. Modal.alert(
  70. '',
  71. <Text style={{ marginHorizontal: 15 }} more>
  72. {i18n.t('tips9')}
  73. </Text>,
  74. [
  75. {
  76. text: i18n.t('ke-fu-dian-hua'),
  77. onPress: connectKefuOn,
  78. style: { color: '#000', fontSize: 12, lineHeight: 30 },
  79. },
  80. {
  81. text: i18n.t('wo-yao-tou-su'),
  82. onPress: () => {
  83. navigate('Complaint', { orderId });
  84. },
  85. style: { color: '#FFC21C', fontSize: 12, lineHeight: 30 },
  86. },
  87. ]
  88. );
  89. }
  90. export function connectKefuOn() {
  91. Linking.openURL('tel:+123456789');
  92. }
  93. export function prompt(title, plac, defaultValue, callBack) {
  94. Modal.prompt(
  95. title || '',
  96. '',
  97. (val) => {
  98. if (callBack) callBack(val);
  99. },
  100. 'default',
  101. defaultValue || '',
  102. [plac || '']
  103. );
  104. }