爱简收旧衣按件回收前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.1 KiB

  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const pullRefreshMixin = {
  4. data() {
  5. return {
  6. isRefreshing: false
  7. };
  8. },
  9. methods: {
  10. async refreshData() {
  11. if (this.isRefreshing)
  12. return;
  13. this.isRefreshing = true;
  14. try {
  15. if (typeof this.onRefresh === "function") {
  16. await this.onRefresh();
  17. } else {
  18. await new Promise((resolve) => setTimeout(resolve, 1e3));
  19. }
  20. common_vendor.index.showToast({
  21. title: "刷新成功",
  22. icon: "success"
  23. });
  24. } catch (error) {
  25. common_vendor.index.__f__("error", "at pages/mixins/pullRefreshMixin.js:26", "刷新失败:", error);
  26. common_vendor.index.showToast({
  27. title: "刷新失败",
  28. icon: "none"
  29. });
  30. } finally {
  31. this.isRefreshing = false;
  32. common_vendor.index.stopPullDownRefresh();
  33. }
  34. }
  35. },
  36. onPullDownRefresh() {
  37. this.refreshData();
  38. }
  39. };
  40. exports.pullRefreshMixin = pullRefreshMixin;
  41. //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/mixins/pullRefreshMixin.js.map