SystemUtils.ts 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import i18n from '../i18n';
  2. import * as Linking from 'expo-linking';
  3. // import { Toast, ModalIndicator } 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. }
  25. ) {
  26. navigation.navigate('Modal', {
  27. screen: 'Promot',
  28. params,
  29. });
  30. }
  31. function toastShow() {
  32. if (Platform.OS === 'web') return;
  33. ModalIndicator.show(i18n.t('jia-zai-zhong'));
  34. }
  35. function toastHide() {
  36. if (Platform.OS === 'web') return;
  37. ModalIndicator.hide();
  38. }
  39. function toastSuccess(title) {
  40. toastHide();
  41. if (Platform.OS === 'web') return;
  42. Toast.success(title);
  43. }
  44. function toastInfo(title) {
  45. toastHide();
  46. if (Platform.OS === 'web') return;
  47. Toast.message(title);
  48. }
  49. function getMoney(money = 0) {
  50. return money.toFixed(2);
  51. }
  52. export {
  53. connect,
  54. promot,
  55. toastShow,
  56. toastHide,
  57. toastInfo,
  58. toastSuccess,
  59. getMoney,
  60. };