offlineTreatment.ts 1.4 KB

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