| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- 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,
- schemeId: '',
- healthIndex: { data: [], loading: false, message: '' },
- tongueAnalysis: [] as AnyArray,
- },
- onLoad(query: any) {
- this.getHealthReport(query).then(() => this.getHealthIndex(this.data.id));
- },
- async getHealthReport(query: Record<'id' | 'scene', string>) {
- console.log('[log] getHealthReport: load -->', query);
- wx.showLoading({ title: '加载中' });
- try {
- const dataset = await healthReportMethod(query);
- this.setData({ dataset, id: dataset.healthAnalysisReportId });
- this._update(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,
- });
- }
- },
- toHomePage() { toHomePage(); },
- toSchemePage() { toSchemePage(this.data.schemeId); },
- toTongueAnalysisResult() {
- wx.navigateTo({ url: `/module/health/pages/tongue-analysis/tongue-analysis` })
- .then(res => {
- res.eventChannel.emit('load', { dataset: this.data.tongueAnalysis });
- });
- },
- _update(data: any) {
- const has = data?.isHaveConditioningProgram === 'Y' && data?.isConfirmConditioningProgram === 'Y';
- const keys = [
- 'tongueColor', 'tongueCoatingColor',
- 'tongueShape', 'tongueCoating',
- 'bodyFluid', 'sublingualVein'
- ]
- const tongueAnalysis = [] as AnyObject[];
- for (const key of keys) {
- const actualList = data?.[key]?.['actualList'] ?? []
- tongueAnalysis.push(...actualList.filter((item: AnyObject) => item.contrast !== 's'))
- }
- this.setData({
- schemeId: has ? this.data.id : '',
- tongueAnalysis
- })
- },
- });
|