| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- import { getPatients, getPatientPhone } from "../home/request";
- import { toCertificationPage } from "../home/router";
- Page({
- data: {
- patients: [] as (App.Patient.Model & { isDefault: "Y" | "N" })[],
- patient: null as App.Patient.Model | null,
- patientDescription: "",
- userInfo: null,
- tabbarValue: "/pages/mine/mine",
- phone: "",
- },
- async load(retry = false) {
- if (retry) {
- await wx.showModal({
- title: '提示',
- content: '数据加载失败,是否重试?',
- showCancel: true,
- }).then(res => {
- if (res.confirm) {
- this.load();
- }
- });
- return;
- }
- try {
- wx.showLoading({ title: "加载中" });
- const { patient } = await getPatients();
- const { phone } = await getPatientPhone();
- wx.setStorageSync("patientName", patient?.name);
- this.setData({
- patient: patient || null,
- phone
- });
- } catch (error) {
- console.error('加载失败:', error);
- wx.showToast({
- title: '加载失败',
- icon: 'none',
- duration: 2000
- });
- } finally {
- wx.hideLoading();
- }
- },
- // 健康档案
- toHealthPage() {
- if (!this.data.patient?.patientId) {
- wx.showToast({
- title: '请先登录',
- icon: 'none'
- });
- toCertificationPage();
- }else {
- wx.navigateTo({ url: `/module/health/pages/home/home` });
- }
- },
- // 药膳
- toDietTonicPage() {
- wx.navigateTo({
- url: `/module/article/pages/diet-list/diet-list?classify=tonic`,
- });
- },
- // 茶饮
- toDietTeaPage() {
- wx.navigateTo({
- url: `/module/article/pages/diet-list/diet-list?classify=tea`,
- });
- },
- onLoad() {
- this.load();
- },
- onShow() {
- // 如果需要每次显示页面时刷新数据,可以在这里调用 load
- // this.load();
- },
- });
|