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 { navigate } from '../navigation/RootNavigation';
  8. export function alert(title, content, submitEvent) {
  9. Modal.alert(
  10. <Text textAlign="center" fontWeight="bold">
  11. {title || '提示'}
  12. </Text>,
  13. <Text fontSize="sm" color="red500" textAlign="center">
  14. {content}
  15. </Text>,
  16. [
  17. {
  18. text: '取消',
  19. onPress: () => console.log('cancel'),
  20. style: { color: '#000', fontSize: 12, lineHeight: 30 },
  21. },
  22. {
  23. text: '确定',
  24. onPress: () => {
  25. if (submitEvent) {
  26. submitEvent();
  27. }
  28. },
  29. style: { color: '#FFC21C', fontSize: 12, lineHeight: 30 },
  30. },
  31. ]
  32. );
  33. }
  34. export function alertWithoutCancel(title, content, isError, submitEvent) {
  35. Modal.alert(
  36. !!title && (
  37. <Text textAlign="center" fontWeight="bold">
  38. {title || ''}
  39. </Text>
  40. ),
  41. <Text
  42. fontSize="sm"
  43. color={isError ? 'red500' : 'gray600'}
  44. textAlign="center"
  45. >
  46. {content}
  47. </Text>,
  48. [
  49. {
  50. text: '确定',
  51. onPress: () => {
  52. if (submitEvent) {
  53. submitEvent();
  54. }
  55. },
  56. style: { color: '#FFC21C', fontSize: 12, lineHeight: 30 },
  57. },
  58. ]
  59. );
  60. }
  61. export function operation() {
  62. Modal.operation([
  63. { text: '标为未读', onPress: () => console.log('标为未读被点击了') },
  64. { text: '置顶聊天', onPress: () => console.log('置顶聊天被点击了') },
  65. ]);
  66. }
  67. export function connectKefu(orderId) {
  68. Modal.alert(
  69. '',
  70. <Text style={{ marginHorizontal: 15 }} more>
  71. 感谢您对我们的信任,我们将竭尽所能
  72. 的为您解决问题。您的每一个建议和反馈都对我们至关重要
  73. </Text>,
  74. [
  75. {
  76. text: '客服电话',
  77. onPress: connectKefuOn,
  78. style: { color: '#000', fontSize: 12, lineHeight: 30 },
  79. },
  80. {
  81. text: '我要投诉',
  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. }