import { getPatients, getPatientPhone } from "../home/request"; import { toCertificationPage } from "../home/router"; import { getOrderList, getRecordCountMethod } from "../home/request"; 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: "", mineOrderList: [ { url: "../../assets/icon/obligation@3x.png", name: "待付款", count: 0, type: 1, tab: "pending", }, { url: "../../assets/icon/delivery@3x.png", name: "待收货", count: 0, type: 2, tab: "received", }, { url: "../../assets/icon/deal@3x.png", name: "交易成功", count: 0, type: 3, tab: "completed", }, { url: "../../assets/icon/all@3x.png", name: "全部", count: 0, type: 4, tab: "all", }, ], }, // 获取各状态调理记录数量 async getRecordCount() { console.log("获取各状态调理记录数量"); try { const res = await getRecordCountMethod(); console.log(res.data, "获取各状态调理记录数量"); if (res && res.data) { this.setData({ "mineOrderList[0].count": res.data.pendingPayment, "mineOrderList[1].count": res.data.pendingReceiptGoods, // "mineOrderList[2].count": res.data.successTrade, // "mineOrderList[3].count": res.data.total, }); } console.log(this.data.mineOrderList, "mineOrderList"); } catch (error: any) { console.error("获取各状态调理记录数量失败:", error); wx.showToast({ title: error.message, icon: "none", duration: 2000, }); } }, async load(retry = false) { if (retry) { await wx .showModal({ title: "提示", content: "数据加载失败,是否重试?", showCancel: true, }) .then((res) => { if (res.confirm) { this.load(); } }); return; } this.getRecordCount(); 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`, }); }, // 订单列表 toOrderListPage(e: any) { console.log("tab", e); const tab = e.currentTarget.dataset.tab; wx.navigateTo({ url: `/module/article/pages/order-list/order-list?tab=${tab}`, }); }, // 获取全部订单列表 async getOrderList() { const patientId = wx.getStorageSync("patientId"); console.log(patientId, "patientId"); const res = await getOrderList(patientId, ""); console.log(res, "获取订单列表"); }, onShow() { // 如果需要每次显示页面时刷新数据,可以在这里调用 load this.load(); }, // 足迹 toFootPrintPage() { wx.navigateTo({ url: "/module/article/pages/foot-print/foot-print", }); }, // 健康宣教 toHealthEducationPage() { wx.showToast({ title: "敬请期待", icon: "none", }); // wx.navigateTo({ // url: '/module/article/pages/evangelism-notice/evangelism-notice' // }); }, onAddressTap() { console.log("onAddressTap"); // 跳转到收货地址页面 wx.navigateTo({ url: "/module/article/pages/manage-address/manage-address", }); }, onConsultationTap() { // 跳转到咨询记录页面 wx.showToast({ title: "敬请期待", icon: "none", }); // wx.navigateTo({ // url: '/module/article/pages/consultation-record/consultation-record' // }); }, onTreatmentTap() { // 跳转到线下非药物治疗页面 wx.navigateTo({ url: "/module/care/pages/offlineTreatment/offlineTreatment", }); }, });