SystemUtils.ts 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. import i18n from '../i18n';
  2. import * as Linking from 'expo-linking';
  3. import { Toast, ModalIndicator, PopoverPicker } from 'teaset';
  4. import { Platform } from 'react-native';
  5. function connect(navigation) {
  6. toastHide();
  7. navigation.navigate('Modal', {
  8. screen: 'Alert',
  9. params: {
  10. msg: `${i18n.t('tips1')}:0512-109291882?`,
  11. hasCancel: true,
  12. submitText: i18n.t('li-ji-bo-da'),
  13. submitEvent: () => {
  14. Linking.openURL('tel:+123456789');
  15. },
  16. },
  17. });
  18. }
  19. function promot(
  20. navigation,
  21. params = {
  22. title: '',
  23. submitEvent: (val) => {},
  24. hasCancel: true,
  25. tips: '',
  26. secureTextEntry: false,
  27. }
  28. ) {
  29. toastHide();
  30. navigation.navigate('Modal', {
  31. screen: 'Promot',
  32. params,
  33. });
  34. }
  35. function alert(
  36. navigation,
  37. params = {
  38. msg: '',
  39. submitEvent: (val) => {},
  40. submitText: '',
  41. hasCancel: true,
  42. }
  43. ) {
  44. toastHide();
  45. navigation.navigate('Modal', {
  46. screen: 'Alert',
  47. params,
  48. });
  49. }
  50. function toastShow() {
  51. if (__DEV__) return;
  52. ModalIndicator.show(i18n.t('jia-zai-zhong'));
  53. }
  54. function toastHide() {
  55. if (__DEV__) return;
  56. ModalIndicator.hide();
  57. }
  58. function toastSuccess(title) {
  59. console.log(title);
  60. toastHide();
  61. if (__DEV__) return;
  62. Toast.success(title);
  63. }
  64. function toastInfo(title) {
  65. console.log(title);
  66. toastHide();
  67. if (__DEV__) return;
  68. Toast.message(title);
  69. }
  70. function getMoney(money = 0) {
  71. return money.toFixed(2);
  72. }
  73. export {
  74. connect,
  75. promot,
  76. toastShow,
  77. toastHide,
  78. toastInfo,
  79. toastSuccess,
  80. getMoney,
  81. alert,
  82. // PopoverPicker,
  83. };