| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- import PageContainerBehavior from "../../../../core/behavior/page-container.behavior";
- import TickleBehavior, { getTickleContext } from "../../../../core/behavior/tickle.behavior";
- import { getPatients } from "../../../../lib/request/common";
- // 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,
- showUserAuth: false,
- switchType: "",
- },
- onLoad(query: any) {
- this._load(query);
- if (query.scene) {
- this.setData({
- switchType: query.scene,
- });
- }
- },
- async _load(query: Record<'id' | 'scene', string>) {
- wx.showLoading({ title: '加载中' });
- try {
- if (query.scene) {
- // 查找患者是否需要授权
- const { auth } = await getPatients().catch(() => ({ auth: true }));
- if (auth) this.setData({ showUserAuth: true });
- }
- 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);
- }
- });
|