| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- import PageContainerBehavior from "../../../../core/behavior/page-container.behavior";
- import TickleBehavior, { getTickleContext } from "../../../../core/behavior/tickle.behavior";
- // module/health/pages/analysis/analysis.ts
- import { toHomePage } from "../../router";
- import { healthAnalysisMethod } from "../../request";
- import { AnalysisModel } from "../../model/health.model";
- Page({
- behaviors: [
- PageContainerBehavior,
- TickleBehavior
- ],
- data: {
- id: '',
- tongue: null as unknown as AnalysisModel,
- face: null as unknown as AnalysisModel,
- dataset: null as unknown as AnyObject,
- switchType: "",
- },
- onLoad(query: any) {
- if (query.scene) {
- this.setData({ switchType: query.scene });
- wx.showLoading({ title: "加载中" });
- } else this._load(query);
- },
- load(event: AnyObject) { this._load(event.detail, false); },
- async _load(query: Record<'id' | 'scene', string>, loading = true) {
- if (loading) wx.showLoading({ title: '加载中' });
- try {
- const { tongue, face, ...dataset } = await healthAnalysisMethod(query);
- this.setData({ tongue, face, dataset });
- } catch (error) {
- getTickleContext.call(this).showErrorMessage(error.errMsg, 0);
- }
- wx.hideLoading();
- },
- toHomePage() { toHomePage(this.data.switchType as string); },
- openMessage(event: any) {
- const message = event?.detail?.content;
- if (message) getTickleContext.call(this).showMessage(event.detail.type || 'info', message);
- }
- });
|