175 lines
6.5 KiB
JavaScript
175 lines
6.5 KiB
JavaScript
"use strict";
|
|
const common_vendor = require("../../common/vendor.js");
|
|
const utils_api = require("../../utils/api.js");
|
|
if (!Array) {
|
|
const _easycom_t_tab_panel2 = common_vendor.resolveComponent("t-tab-panel");
|
|
const _easycom_t_tabs2 = common_vendor.resolveComponent("t-tabs");
|
|
const _easycom_t_loading2 = common_vendor.resolveComponent("t-loading");
|
|
const _easycom_t_empty2 = common_vendor.resolveComponent("t-empty");
|
|
const _easycom_t_tag2 = common_vendor.resolveComponent("t-tag");
|
|
const _easycom_t_button2 = common_vendor.resolveComponent("t-button");
|
|
(_easycom_t_tab_panel2 + _easycom_t_tabs2 + _easycom_t_loading2 + _easycom_t_empty2 + _easycom_t_tag2 + _easycom_t_button2)();
|
|
}
|
|
const _easycom_t_tab_panel = () => "../../uni_modules/tdesign-uniapp/components/tab-panel/tab-panel.js";
|
|
const _easycom_t_tabs = () => "../../uni_modules/tdesign-uniapp/components/tabs/tabs.js";
|
|
const _easycom_t_loading = () => "../../uni_modules/tdesign-uniapp/components/loading/loading.js";
|
|
const _easycom_t_empty = () => "../../uni_modules/tdesign-uniapp/components/empty/empty.js";
|
|
const _easycom_t_tag = () => "../../uni_modules/tdesign-uniapp/components/tag/tag.js";
|
|
const _easycom_t_button = () => "../../uni_modules/tdesign-uniapp/components/button/button.js";
|
|
if (!Math) {
|
|
(_easycom_t_tab_panel + _easycom_t_tabs + _easycom_t_loading + _easycom_t_empty + _easycom_t_tag + _easycom_t_button)();
|
|
}
|
|
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
|
|
__name: "appointments",
|
|
setup(__props) {
|
|
const activeTab = common_vendor.ref("all");
|
|
const appointments = common_vendor.ref([]);
|
|
const loading = common_vendor.ref(false);
|
|
common_vendor.onMounted(() => {
|
|
loadAppointments();
|
|
});
|
|
const loadAppointments = async () => {
|
|
loading.value = true;
|
|
try {
|
|
const params = {};
|
|
if (activeTab.value !== "all") {
|
|
params.status = activeTab.value;
|
|
}
|
|
appointments.value = await utils_api.api.appointments.getList(params);
|
|
} catch (error) {
|
|
common_vendor.index.__f__("error", "at pages/appointments/appointments.vue:84", "加载预约失败", error);
|
|
} finally {
|
|
loading.value = false;
|
|
}
|
|
};
|
|
const onTabChange = (value) => {
|
|
const tabValue = typeof value === "string" ? value : (value == null ? void 0 : value.value) || "all";
|
|
activeTab.value = tabValue;
|
|
loadAppointments();
|
|
};
|
|
const getStatusTheme = (status) => {
|
|
const themes = {
|
|
pending: "warning",
|
|
confirmed: "success",
|
|
completed: "primary",
|
|
cancelled: "default"
|
|
};
|
|
return themes[status] || "default";
|
|
};
|
|
const getStatusText = (status) => {
|
|
const texts = {
|
|
pending: "待确认",
|
|
confirmed: "已确认",
|
|
completed: "已完成",
|
|
cancelled: "已取消"
|
|
};
|
|
return texts[status] || status;
|
|
};
|
|
const formatDate = (dateStr) => {
|
|
if (!dateStr)
|
|
return "";
|
|
try {
|
|
return dateStr.replace("T", " ").split("+")[0];
|
|
} catch (error) {
|
|
common_vendor.index.__f__("error", "at pages/appointments/appointments.vue:127", "Date format error:", error, dateStr);
|
|
return dateStr;
|
|
}
|
|
};
|
|
const formatTime = (timeStr) => {
|
|
const timePart = timeStr.split("T")[1] || timeStr;
|
|
const timeWithoutZone = timePart.split("+")[0].split("Z")[0];
|
|
const [hours, minutes] = timeWithoutZone.split(":");
|
|
return `${hours}:${minutes}`;
|
|
};
|
|
const cancelAppointment = (appointment) => {
|
|
common_vendor.index.showModal({
|
|
title: "确认取消",
|
|
content: "确定要取消这个预约吗?",
|
|
success: async (res) => {
|
|
if (res.confirm) {
|
|
try {
|
|
await utils_api.api.appointments.cancel(appointment.id);
|
|
common_vendor.index.showToast({
|
|
title: "取消成功",
|
|
icon: "success"
|
|
});
|
|
loadAppointments();
|
|
} catch (error) {
|
|
common_vendor.index.__f__("error", "at pages/appointments/appointments.vue:157", "取消预约失败", error);
|
|
}
|
|
}
|
|
}
|
|
});
|
|
};
|
|
return (_ctx, _cache) => {
|
|
return common_vendor.e({
|
|
a: common_vendor.p({
|
|
value: "all",
|
|
label: "全部"
|
|
}),
|
|
b: common_vendor.p({
|
|
value: "pending",
|
|
label: "待确认"
|
|
}),
|
|
c: common_vendor.p({
|
|
value: "confirmed",
|
|
label: "已确认"
|
|
}),
|
|
d: common_vendor.p({
|
|
value: "completed",
|
|
label: "已完成"
|
|
}),
|
|
e: common_vendor.p({
|
|
value: "cancelled",
|
|
label: "已取消"
|
|
}),
|
|
f: common_vendor.o(onTabChange),
|
|
g: common_vendor.p({
|
|
value: activeTab.value
|
|
}),
|
|
h: loading.value
|
|
}, loading.value ? {
|
|
i: common_vendor.p({
|
|
loading: true
|
|
})
|
|
} : appointments.value.length === 0 ? {
|
|
k: common_vendor.p({
|
|
description: "暂无预约记录"
|
|
})
|
|
} : {
|
|
l: common_vendor.f(appointments.value, (appointment, k0, i0) => {
|
|
return common_vendor.e({
|
|
a: common_vendor.t(getStatusText(appointment.status)),
|
|
b: "7c6f8f1a-8-" + i0,
|
|
c: common_vendor.p({
|
|
theme: getStatusTheme(appointment.status),
|
|
size: "small"
|
|
}),
|
|
d: common_vendor.t(formatDate(appointment.created_at)),
|
|
e: common_vendor.t(appointment.time_slot ? appointment.time_slot.date.split("T")[0] : ""),
|
|
f: common_vendor.t(appointment.time_slot ? formatTime(appointment.time_slot.start_time) : ""),
|
|
g: common_vendor.t(appointment.time_slot ? formatTime(appointment.time_slot.end_time) : ""),
|
|
h: common_vendor.t(appointment.people_count),
|
|
i: appointment.status === "pending"
|
|
}, appointment.status === "pending" ? {
|
|
j: common_vendor.o(($event) => cancelAppointment(appointment), appointment.id),
|
|
k: "7c6f8f1a-9-" + i0,
|
|
l: common_vendor.p({
|
|
size: "small",
|
|
theme: "danger",
|
|
variant: "outline"
|
|
})
|
|
} : {}, {
|
|
m: appointment.id
|
|
});
|
|
})
|
|
}, {
|
|
j: appointments.value.length === 0
|
|
});
|
|
};
|
|
}
|
|
});
|
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-7c6f8f1a"]]);
|
|
wx.createPage(MiniProgramPage);
|
|
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/appointments/appointments.js.map
|