TotastUtils.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 { Linking } from 'expo';
  6. import Text from '../components/Text';
  7. import { navigate } from '../navigation/RootNavigation';
  8. export function alert(title, content, submitEvent) {
  9. Modal.alert(
  10. <Text size="s1" bold center>
  11. {title || '提示'}
  12. </Text>,
  13. <Text type="error" 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 operation() {
  35. Modal.operation([
  36. { text: '标为未读', onPress: () => console.log('标为未读被点击了') },
  37. { text: '置顶聊天', onPress: () => console.log('置顶聊天被点击了') },
  38. ]);
  39. }
  40. export function connectKefu(orderId) {
  41. Modal.alert(
  42. '',
  43. <Text style={{ marginHorizontal: 15 }} more>
  44. 感谢您对我们的信任,我们将竭尽所能
  45. 的为您解决问题。您的每一个建议和反馈都对我们至关重要
  46. </Text>,
  47. [
  48. {
  49. text: '客服电话',
  50. onPress: connectKefuOn,
  51. style: { color: '#000', fontSize: 12, lineHeight: 30 },
  52. },
  53. {
  54. text: '我要投诉',
  55. onPress: () => {
  56. navigate('Complaint', { orderId });
  57. },
  58. style: { color: '#FFC21C', fontSize: 12, lineHeight: 30 },
  59. },
  60. ]
  61. );
  62. }
  63. export function connectKefuOn() {
  64. Linking.openURL('tel:+123456789');
  65. }
  66. export function prompt(title, plac, defaultValue, callBack) {
  67. Modal.prompt(
  68. title || '',
  69. '',
  70. (val) => {
  71. if (callBack) callBack(val);
  72. },
  73. 'default',
  74. defaultValue || '',
  75. [plac || '']
  76. );
  77. }