offlineTreatment.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import { getOfflineTreatmentListMethod } from "../../request";
  2. Page({
  3. data: {
  4. currentTab: "",
  5. treatmentList: [],
  6. isLoading: false,
  7. },
  8. onLoad() {
  9. this.getOfflineTreatmentList("");
  10. },
  11. // 跳转到核销记录
  12. switchVerifyRecode() {
  13. wx.navigateTo({
  14. url: "/pages/care/verifyRecode",
  15. });
  16. },
  17. onTabChange(e: any) {
  18. const progress = e.detail.value;
  19. this.setData({
  20. currentTab: progress,
  21. });
  22. // 不立即清空数据,避免空状态闪烁
  23. this.getOfflineTreatmentList(progress);
  24. },
  25. // 获取线下非药物治疗记录列表
  26. async getOfflineTreatmentList(progress: string) {
  27. // 启用加载态,保留当前列表,避免空态闪烁
  28. this.setData({ isLoading: true });
  29. try {
  30. const res = await getOfflineTreatmentListMethod(progress);
  31. const list = res && res.data ? res.data : [];
  32. // 只有在数据加载完成后才更新列表
  33. this.setData({ treatmentList: list, isLoading: false });
  34. } catch (error: any) {
  35. wx.showToast({
  36. title: error.errMsg || "获取数据失败",
  37. icon: "none",
  38. });
  39. this.setData({ treatmentList: [], isLoading: false });
  40. }
  41. },
  42. });