offlineTreatment.ts 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. onRecord(e: any) {
  13. const id = e.currentTarget.dataset.id;
  14. if (id) {
  15. wx.navigateTo({
  16. url: `/module/care/pages/care/verifyRecord?id=${id}`,
  17. });
  18. }
  19. },
  20. onTabChange(e: any) {
  21. const progress = e.detail.value;
  22. this.setData({
  23. currentTab: progress,
  24. });
  25. // 不立即清空数据,避免空状态闪烁
  26. this.getOfflineTreatmentList(progress);
  27. },
  28. // 获取线下非药物治疗记录列表
  29. async getOfflineTreatmentList(progress: string) {
  30. // 启用加载态,保留当前列表,避免空态闪烁
  31. this.setData({ isLoading: true });
  32. try {
  33. const res = await getOfflineTreatmentListMethod(progress);
  34. const list = res && res.data ? res.data : [];
  35. // 只有在数据加载完成后才更新列表
  36. this.setData({ treatmentList: list, isLoading: false });
  37. } catch (error: any) {
  38. wx.showToast({
  39. title: error.errMsg || "获取数据失败",
  40. icon: "none",
  41. });
  42. this.setData({ treatmentList: [], isLoading: false });
  43. }
  44. },
  45. });