loadingModel.js 909 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import { Toast, Portal } from "@ant-design/react-native";
  2. // 加载页
  3. export default {
  4. state: {
  5. status: "loading",
  6. title: "成功",
  7. show: false,
  8. time: -1,
  9. tKey: "",
  10. },
  11. actions: ({ model, setState }) => ({
  12. loading() {
  13. console.log("aaaaa");
  14. const { tKey } = model();
  15. if (!tKey) {
  16. const newKey = Toast.loading("Loading...", 0);
  17. setState({
  18. tKey: newKey,
  19. });
  20. }
  21. },
  22. success(title) {
  23. const { clearLoading } = model();
  24. clearLoading();
  25. Toast.success(title, 2);
  26. },
  27. warnning(title) {
  28. const { clearLoading } = model();
  29. clearLoading();
  30. Toast.info(title, 2);
  31. },
  32. clearLoading() {
  33. const { tKey } = model();
  34. if (tKey) {
  35. Portal.remove(tKey);
  36. setState({
  37. tKey: "",
  38. });
  39. }
  40. },
  41. }),
  42. };