home.ts 2.1 KB

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