| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- 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 res = await getPatientPhone();
- console.log(res, "获取手机号");
- if (res && res.phone) {
- this.setData({
- phone: res.phone
- });
- }
- wx.setStorageSync("patientName", patient?.name);
- this.setData({
- patient: patient || null,
- });
- } 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();
- },
- });
|