loadingModel.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import React from "react";
  2. import { TopviewGetInstance, Icon, Tip } from "beeshell";
  3. import { View, Text, ActivityIndicator, StyleSheet } from "react-native";
  4. //加载页
  5. export default {
  6. state: {
  7. status: "loading",
  8. title: "成功",
  9. show: false,
  10. time: -1,
  11. },
  12. actions: ({ model, setState }) => ({
  13. loading() {
  14. setState({
  15. status: "loading",
  16. show: true,
  17. time: -1,
  18. });
  19. },
  20. success(title) {
  21. setState({
  22. status: "success",
  23. title: title,
  24. show: true,
  25. time: 3000,
  26. });
  27. const { setTime } = model();
  28. setTime();
  29. },
  30. warnning(title) {
  31. setState({
  32. status: "warn",
  33. title: title,
  34. show: true,
  35. time: 3000,
  36. });
  37. const { setTime } = model();
  38. setTime();
  39. },
  40. setTime() {
  41. const { time, show, clear } = model();
  42. if (time > 0 && show) {
  43. setTimeout(() => {
  44. if (show) {
  45. clear();
  46. }
  47. }, time);
  48. }
  49. },
  50. clear() {
  51. setState({
  52. show: false,
  53. });
  54. },
  55. }),
  56. };