home.ts 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. console.log(data, "获取患者信息");
  28. this.setData({
  29. 'healthPatient.data': data,
  30. 'healthPatient.loading': false,
  31. });
  32. } catch (error) {
  33. this.setData({
  34. 'healthPatient.data': [],
  35. 'healthPatient.loading': false,
  36. 'healthPatient.message': error.errMsg,
  37. });
  38. }
  39. },
  40. async getHealthIndex(id?: string) {
  41. console.log(id, "获取健康指数");
  42. this.setData({ 'healthIndex.loading': true, })
  43. try {
  44. const data = await healthIndexMethod(id);
  45. console.log(data, "获取身体数据");
  46. this.setData({
  47. 'healthIndex.data': healthIndex2Progress(data),
  48. 'healthIndex.loading': false,
  49. });
  50. } catch (error) {
  51. this.setData({
  52. 'healthIndex.data': [],
  53. 'healthIndex.loading': false,
  54. 'healthIndex.message': error.errMsg,
  55. });
  56. }
  57. },
  58. toPatientPage: toPatientPage,
  59. toHealthIndexListPage() {
  60. wx.navigateTo({ url: `/module/charts/record-index/record-index` })
  61. },
  62. }
  63. })