| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- import PageContainerBehavior from "../../../../core/behavior/page-container.behavior";
- import { DraggableSheetBehavior, getDraggableSheetContext } from "../../../../core/behavior/draggableSheet.behavior";
- // module/health/pages/home/home.ts
- import { toPatientPage, toReportPage, toSchemePage } from "../../router";
- import { healthIndexMethod, healthPatientMethod, healthReportListMethod, healthReportMethod } from "../../request";
- import { healthIndex2Progress } from "../../tools/health-index";
- import { getTickleContext } from "../../../../core/behavior/tickle.behavior";
- Component({
- behaviors: [
- PageContainerBehavior,
- DraggableSheetBehavior('.health-report-list'),
- ],
- lifetimes: {
- attached() {
- this.getHealthPatient();
- this.getHealthReport();
- this.getHealthIndex();
- }
- },
- pageLifetimes: {
- hide() { this.hideDraggableSheet({}); }
- },
- properties: {},
- observers: {
- 'healthReport.data'(data) {
- this.setData({ healthId: data?.healthAnalysisReportId })
- }
- },
- data: {
- healthId: '',
- healthPatient: { data: null, loading: false, message: '' },
- healthIndex: { data: [], loading: false, message: '' },
- healthReport: { data: null, loading: false, message: '' },
- healthReportList: { data: [], loaded: false },
- },
- methods: {
- async getHealthPatient() {
- this.setData({ 'healthPatient.loading': true, })
- try {
- const data = await healthPatientMethod();
- this.setData({
- 'healthPatient.data': data,
- 'healthPatient.loading': false,
- });
- } catch (error) {
- this.setData({
- 'healthPatient.data': [],
- 'healthPatient.loading': false,
- 'healthPatient.message': error.errMsg,
- });
- }
- },
- async getHealthReport(id?: string) {
- this.setData({ 'healthReport.loading': true, })
- try {
- const data = await healthReportMethod(id);
- this.setData({
- 'healthReport.data': data,
- 'healthReport.loading': false,
- });
- } catch (error) {
- this.setData({
- 'healthReport.data': null,
- 'healthReport.loading': false,
- 'healthReport.message': error.errMsg,
- });
- }
- },
- 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,
- });
- }
- },
- onDraggableSizeUpdate(e) {
- 'worklet'
- if (e.pixels < 1) {
- wx.worklet.runOnJS(this.hideDraggableSheet.bind(this))()
- }
- },
- async showReportList() {
- if (!this.data.healthReportList.loaded) {
- wx.showLoading({ title: '加载中' })
- try {
- const data = await healthReportListMethod();
- this.setData({
- 'healthReportList.data': data,
- 'healthReportList.loaded': true,
- })
- } catch (error) {
- getTickleContext.call(this).showErrorMessage(error.errMsg);
- }
- wx.hideLoading();
- }
- if (this.data.healthReportList.data.length) {
- getDraggableSheetContext.call(this).scrollTo({
- size: 0.5,
- pixels: 600,
- animated: true,
- duration: 300,
- easingFunction: 'ease'
- });
- this.setData({ shade: 'shade' });
- } else {
- wx.showToast({ title: '暂无更新记录' })
- }
- },
- hideDraggableSheet(e?: any) {
- if (e) {
- getDraggableSheetContext.call(this).scrollTo({
- size: 0,
- animated: true,
- duration: 300,
- easingFunction: 'ease'
- });
- }
- this.setData({ shade: '' });
- },
- toSchemePage(event: WechatMiniprogram.TouchEvent) { toSchemePage(event.mark?.id); },
- toReportPage(event: WechatMiniprogram.TouchEvent) { toReportPage(event.mark?.id); },
- toPatientPage: toPatientPage,
- toHealthIndexListPage() {
- wx.navigateTo({ url: `/module/charts/record-index/record-index` })
- },
- toHealthStatusListPage() {
- wx.navigateTo({ url: `/module/health/pages/status-record/status-record` })
- },
- }
- })
|