| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- import PageContainerBehavior from "../../../../core/behavior/page-container.behavior";
- import TickleBehavior, { getTickleContext } from "../../../../core/behavior/tickle.behavior";
- // module/health/pages/report/report.ts
- import { toSchemePage } from '../../router';
- import { healthIndexMethod, healthReportMethod } from "../../request";
- import { healthIndex2Progress } from "../../tools/health-index";
- Component({
- behaviors: [
- PageContainerBehavior,
- TickleBehavior
- ],
- lifetimes: {
- attached() {
- this.getHealthReport(this.data.id);
- this.getHealthIndex(this.data.id);
- }
- },
- properties: {
- id: { type: String, value: '' },
- },
- data: {
- dataset: null,
- schemeId: '',
- healthIndex: { data: [], loading: false, message: '' },
- },
- observers: {
- 'dataset'(data) {
- const has = data?.isHaveConditioningProgram === 'Y' && data?.isConfirmConditioningProgram === 'Y';
- this.setData({ schemeId: has ? this.data.id : '' })
- }
- },
- methods: {
- async getHealthReport(id?: string) {
- wx.showLoading({ title: '加载中' });
- try {
- const dataset = await healthReportMethod(id);
- this.setData({ dataset });
- } catch (error) {
- getTickleContext.call(this).showErrorMessage(error.errMsg, 0);
- }
- wx.hideLoading();
- },
- async getHealthIndex(id?: string) {
- this.setData({ 'healthIndex.loading': true, })
- try {
- const data = await healthIndexMethod(id);
- this.setData({
- 'healthIndex.data': healthIndex2Progress(data),
- 'healthIndex.loading': false,
- });
- } catch (error) {
- this.setData({
- 'healthIndex.data': [],
- 'healthIndex.loading': false,
- 'healthIndex.message': error.errMsg,
- });
- }
- },
- toSchemePage() { toSchemePage(this.data.schemeId); }
- }
- })
|