import PageContainerBehavior from "../../../../core/behavior/page-container.behavior"; import TickleBehavior, { getTickleContext } from "../../../../core/behavior/tickle.behavior"; // module/health/pages/report/report.ts import { toSchemePage, toHomePage } from '../../router'; import { healthIndexMethod, healthReportMethod } from "../../request"; import { healthIndex2Progress } from "../../tools/health-index"; Page({ behaviors: [ PageContainerBehavior, TickleBehavior ], data: { id: '', dataset: null as unknown as AnyObject, showScheme: false, schemeId: '', healthIndex: { data: [], loading: false, message: '' }, tongueAnalysis: [] as AnyArray, }, onLoad(query: any) { this._load(query).then((id: string) => { if (id) this.getHealthIndex(id); }); }, async _load(query: Record<'id' | 'scene', string>) { let id = ''; wx.showLoading({ title: '加载中' }); try { const { __origin__, ...dataset } = await healthReportMethod(query); id = dataset.id; const showScheme = __origin__?.isHaveConditioningProgram === 'Y'; const schemeId = __origin__?.isConfirmConditioningProgram === 'Y' ? id : ''; this.setData({ showScheme, schemeId, dataset: { ...dataset, factorItems: __origin__?.factorItems, diagnoseSyndromes: __origin__?.diagnoseSyndromes, } }); } catch (error) { getTickleContext.call(this).showErrorMessage(error.errMsg, 0); } wx.hideLoading(); return id; }, 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, }); } }, toHomePage() { toHomePage(); }, toSchemePage() { toSchemePage(this.data.schemeId); }, });