home.ts 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import PageContainerBehavior from "../../../../core/behavior/page-container.behavior";
  2. // module/health/pages/home/home.ts
  3. import { toPatientPage } from "../../router";
  4. import { healthIndexMethod, healthPatientMethod } from "../../request";
  5. import { healthIndex2Progress } from "../../tools/health-index";
  6. Component({
  7. behaviors: [
  8. PageContainerBehavior,
  9. ],
  10. lifetimes: {
  11. attached() {
  12. this.getHealthPatient();
  13. this.getHealthIndex();
  14. }
  15. },
  16. properties: {},
  17. data: {
  18. // healthId: '',
  19. healthPatient: { data: null, loading: false, message: '' },
  20. healthIndex: { data: [], loading: false, message: '' },
  21. },
  22. methods: {
  23. async getHealthPatient() {
  24. this.setData({ 'healthPatient.loading': true, })
  25. try {
  26. const data = await healthPatientMethod();
  27. this.setData({
  28. 'healthPatient.data': data,
  29. 'healthPatient.loading': false,
  30. });
  31. } catch (error) {
  32. this.setData({
  33. 'healthPatient.data': [],
  34. 'healthPatient.loading': false,
  35. 'healthPatient.message': error.errMsg,
  36. });
  37. }
  38. },
  39. async getHealthIndex(id?: string) {
  40. this.setData({ 'healthIndex.loading': true, })
  41. try {
  42. const data = await healthIndexMethod(id);
  43. this.setData({
  44. 'healthIndex.data': healthIndex2Progress(data),
  45. 'healthIndex.loading': false,
  46. });
  47. } catch (error) {
  48. this.setData({
  49. 'healthIndex.data': [],
  50. 'healthIndex.loading': false,
  51. 'healthIndex.message': error.errMsg,
  52. });
  53. }
  54. },
  55. toPatientPage: toPatientPage,
  56. toHealthIndexListPage() {
  57. wx.navigateTo({ url: `/module/charts/record-index/record-index` })
  58. },
  59. }
  60. })