|
@@ -43,7 +43,8 @@ Page({
|
|
|
},
|
|
},
|
|
|
// 读取缓存,若存在则直接渲染并返回已读到的数据
|
|
// 读取缓存,若存在则直接渲染并返回已读到的数据
|
|
|
hydrateFromCache() {
|
|
hydrateFromCache() {
|
|
|
- const cachedPatient = (wx.getStorageSync("patient") || null) as App.Patient.Model | null;
|
|
|
|
|
|
|
+ const cachedPatient = (wx.getStorageSync("patient") ||
|
|
|
|
|
+ null) as App.Patient.Model | null;
|
|
|
const cachedPhone = (wx.getStorageSync("patientPhone") || "") as string;
|
|
const cachedPhone = (wx.getStorageSync("patientPhone") || "") as string;
|
|
|
if (cachedPatient || cachedPhone) {
|
|
if (cachedPatient || cachedPhone) {
|
|
|
this.setData({
|
|
this.setData({
|
|
@@ -66,19 +67,26 @@ Page({
|
|
|
} catch {}
|
|
} catch {}
|
|
|
},
|
|
},
|
|
|
// 轻量对比(避免 JSON 深比较):患者用 patientId 或 name,对比手机号字符串
|
|
// 轻量对比(避免 JSON 深比较):患者用 patientId 或 name,对比手机号字符串
|
|
|
- isDifferent(cachedPatient: App.Patient.Model | null, newPatient: App.Patient.Model | null, cachedPhone: string, newPhone: string) {
|
|
|
|
|
|
|
+ isDifferent(
|
|
|
|
|
+ cachedPatient: App.Patient.Model | null,
|
|
|
|
|
+ newPatient: App.Patient.Model | null,
|
|
|
|
|
+ cachedPhone: string,
|
|
|
|
|
+ newPhone: string
|
|
|
|
|
+ ) {
|
|
|
const cachedId = cachedPatient?.patientId || "";
|
|
const cachedId = cachedPatient?.patientId || "";
|
|
|
const newId = newPatient?.patientId || "";
|
|
const newId = newPatient?.patientId || "";
|
|
|
const cachedName = cachedPatient?.name || "";
|
|
const cachedName = cachedPatient?.name || "";
|
|
|
const newName = newPatient?.name || "";
|
|
const newName = newPatient?.name || "";
|
|
|
- return cachedId !== newId || cachedName !== newName || (cachedPhone || "") !== (newPhone || "");
|
|
|
|
|
|
|
+ return (
|
|
|
|
|
+ cachedId !== newId ||
|
|
|
|
|
+ cachedName !== newName ||
|
|
|
|
|
+ (cachedPhone || "") !== (newPhone || "")
|
|
|
|
|
+ );
|
|
|
},
|
|
},
|
|
|
// 获取各状态调理记录数量
|
|
// 获取各状态调理记录数量
|
|
|
async getRecordCount() {
|
|
async getRecordCount() {
|
|
|
- console.log("获取各状态调理记录数量");
|
|
|
|
|
try {
|
|
try {
|
|
|
const res = await getRecordCountMethod();
|
|
const res = await getRecordCountMethod();
|
|
|
- console.log(res.data, "获取各状态调理记录数量");
|
|
|
|
|
if (res && res.data) {
|
|
if (res && res.data) {
|
|
|
this.setData({
|
|
this.setData({
|
|
|
"mineOrderList[0].count": res.data.pendingPayment,
|
|
"mineOrderList[0].count": res.data.pendingPayment,
|
|
@@ -87,9 +95,7 @@ Page({
|
|
|
// "mineOrderList[3].count": res.data.total,
|
|
// "mineOrderList[3].count": res.data.total,
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
- console.log(this.data.mineOrderList, "mineOrderList");
|
|
|
|
|
} catch (error: any) {
|
|
} catch (error: any) {
|
|
|
- console.error("获取各状态调理记录数量失败:", error);
|
|
|
|
|
wx.showToast({
|
|
wx.showToast({
|
|
|
title: error.message,
|
|
title: error.message,
|
|
|
icon: "none",
|
|
icon: "none",
|
|
@@ -119,14 +125,28 @@ Page({
|
|
|
|
|
|
|
|
// 2) 并行请求接口,完成后轻量对比,有变更再更新与回写缓存
|
|
// 2) 并行请求接口,完成后轻量对比,有变更再更新与回写缓存
|
|
|
wx.showLoading({ title: "加载中" });
|
|
wx.showLoading({ title: "加载中" });
|
|
|
- const [{ patient }, phoneRes] = await Promise.all([getPatients(), getPatientPhone()]);
|
|
|
|
|
|
|
+ const [{ patient }, phoneRes] = await Promise.all([
|
|
|
|
|
+ getPatients(),
|
|
|
|
|
+ getPatientPhone(),
|
|
|
|
|
+ ]);
|
|
|
const latestPhone = phoneRes?.phone || "";
|
|
const latestPhone = phoneRes?.phone || "";
|
|
|
- if (this.isDifferent(cachedPatient, patient || null, cachedPhone || "", latestPhone) || !this.data.loaded) {
|
|
|
|
|
- this.setData({ patient: patient || null, phone: latestPhone, loaded: true });
|
|
|
|
|
|
|
+ if (
|
|
|
|
|
+ this.isDifferent(
|
|
|
|
|
+ cachedPatient,
|
|
|
|
|
+ patient || null,
|
|
|
|
|
+ cachedPhone || "",
|
|
|
|
|
+ latestPhone
|
|
|
|
|
+ ) ||
|
|
|
|
|
+ !this.data.loaded
|
|
|
|
|
+ ) {
|
|
|
|
|
+ this.setData({
|
|
|
|
|
+ patient: patient || null,
|
|
|
|
|
+ phone: latestPhone,
|
|
|
|
|
+ loaded: true,
|
|
|
|
|
+ });
|
|
|
this.syncCache(patient || null, latestPhone);
|
|
this.syncCache(patient || null, latestPhone);
|
|
|
}
|
|
}
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
- console.error("加载失败:", error);
|
|
|
|
|
wx.showToast({
|
|
wx.showToast({
|
|
|
title: "加载失败",
|
|
title: "加载失败",
|
|
|
icon: "none",
|
|
icon: "none",
|
|
@@ -169,7 +189,6 @@ Page({
|
|
|
|
|
|
|
|
// 订单列表
|
|
// 订单列表
|
|
|
toOrderListPage(e: any) {
|
|
toOrderListPage(e: any) {
|
|
|
- console.log("tab", e);
|
|
|
|
|
const tab = e.currentTarget.dataset.tab;
|
|
const tab = e.currentTarget.dataset.tab;
|
|
|
wx.navigateTo({
|
|
wx.navigateTo({
|
|
|
url: `/module/article/pages/order-list/order-list?tab=${tab}`,
|
|
url: `/module/article/pages/order-list/order-list?tab=${tab}`,
|
|
@@ -178,9 +197,7 @@ Page({
|
|
|
// 获取全部订单列表
|
|
// 获取全部订单列表
|
|
|
async getOrderList() {
|
|
async getOrderList() {
|
|
|
const patientId = wx.getStorageSync("patientId");
|
|
const patientId = wx.getStorageSync("patientId");
|
|
|
- console.log(patientId, "patientId");
|
|
|
|
|
- const res = await getOrderList(patientId, "");
|
|
|
|
|
- console.log(res, "获取订单列表");
|
|
|
|
|
|
|
+ await getOrderList(patientId, "");
|
|
|
},
|
|
},
|
|
|
onShow() {
|
|
onShow() {
|
|
|
// 如果需要每次显示页面时刷新数据,可以在这里调用 load
|
|
// 如果需要每次显示页面时刷新数据,可以在这里调用 load
|
|
@@ -203,7 +220,6 @@ Page({
|
|
|
// });
|
|
// });
|
|
|
},
|
|
},
|
|
|
onAddressTap() {
|
|
onAddressTap() {
|
|
|
- console.log("onAddressTap");
|
|
|
|
|
// 跳转到收货地址页面
|
|
// 跳转到收货地址页面
|
|
|
wx.navigateTo({
|
|
wx.navigateTo({
|
|
|
url: "/module/article/pages/manage-address/manage-address",
|
|
url: "/module/article/pages/manage-address/manage-address",
|