SystemUtils.ts 1.6 KB

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