first commit

This commit is contained in:
lingxiao865
2026-02-10 08:05:03 +08:00
commit c5af079d8c
1094 changed files with 97530 additions and 0 deletions

View File

@@ -0,0 +1,280 @@
"use strict";
const common_vendor = require("../../common/vendor.js");
const utils_api = require("../../utils/api.js");
if (!Array) {
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");
const _easycom_t_stepper2 = common_vendor.resolveComponent("t-stepper");
const _easycom_t_dialog2 = common_vendor.resolveComponent("t-dialog");
(_easycom_t_loading2 + _easycom_t_empty2 + _easycom_t_tag2 + _easycom_t_button2 + _easycom_t_stepper2 + _easycom_t_dialog2)();
}
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";
const _easycom_t_stepper = () => "../../uni_modules/tdesign-uniapp/components/stepper/stepper.js";
const _easycom_t_dialog = () => "../../uni_modules/tdesign-uniapp/components/dialog/dialog.js";
if (!Math) {
(_easycom_t_loading + _easycom_t_empty + _easycom_t_tag + _easycom_t_button + _easycom_t_stepper + _easycom_t_dialog)();
}
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
__name: "booking",
setup(__props) {
const getLocalDateStr = () => {
const now = /* @__PURE__ */ new Date();
const year = now.getFullYear();
const month = String(now.getMonth() + 1).padStart(2, "0");
const day = String(now.getDate()).padStart(2, "0");
return `${year}-${month}-${day}`;
};
const selectedDate = common_vendor.ref(getLocalDateStr());
const timeslots = common_vendor.ref([]);
const loading = common_vendor.ref(false);
const showDialog = common_vendor.ref(false);
const selectedSlot = common_vendor.ref(null);
const peopleCount = common_vendor.ref(1);
const notes = common_vendor.ref("");
const isBooking = common_vendor.ref(false);
const currentDate = common_vendor.ref(/* @__PURE__ */ new Date());
const weekdays = ["日", "一", "二", "三", "四", "五", "六"];
const dateBookings = common_vendor.ref({});
const dateHasSlots = common_vendor.ref({});
const currentDateStr = common_vendor.computed(() => {
const year = currentDate.value.getFullYear();
const month = currentDate.value.getMonth() + 1;
return `${year}${month}`;
});
const totalBookingCount = common_vendor.computed(() => {
return timeslots.value.reduce((sum, slot) => sum + slot.current_people, 0);
});
const calendarDays = common_vendor.computed(() => {
const year = currentDate.value.getFullYear();
const month = currentDate.value.getMonth();
const firstDay = new Date(year, month, 1);
const lastDay = new Date(year, month + 1, 0);
const today = /* @__PURE__ */ new Date();
const startWeekday = firstDay.getDay();
const days = [];
for (let i = startWeekday - 1; i >= 0; i--) {
days.push({
day: "",
dateStr: "",
isPlaceholder: true,
isOtherMonth: false,
isToday: false,
bookingCount: 0,
hasBookings: false
});
}
for (let i = 1; i <= lastDay.getDate(); i++) {
const date = new Date(year, month, i);
const yearNum = date.getFullYear();
const monthNum = date.getMonth() + 1;
const dayNum = date.getDate();
const dateStr = `${yearNum}-${String(monthNum).padStart(2, "0")}-${String(dayNum).padStart(2, "0")}`;
const todayYear = today.getFullYear();
const todayMonth = today.getMonth();
const todayDay = today.getDate();
const isToday = yearNum === todayYear && monthNum - 1 === todayMonth && dayNum === todayDay;
days.push({
day: i,
dateStr,
isPlaceholder: false,
isOtherMonth: false,
isToday,
bookingCount: dateBookings.value[dateStr] || 0,
hasBookings: dateHasSlots.value[dateStr] || false
});
}
return days;
});
common_vendor.onMounted(() => {
const token = common_vendor.index.getStorageSync("token");
if (!token) {
common_vendor.index.redirectTo({ url: "/pages/login/login" });
} else {
loadTimeSlots();
loadDateBookings();
}
});
const loadDateBookings = async () => {
try {
const slots = await utils_api.api.timeslots.getList({ is_active: true });
const bookings = {};
const slotsMap = {};
slots.forEach((slot) => {
const dateStr = slot.date.split("T")[0];
bookings[dateStr] = (bookings[dateStr] || 0) + slot.current_people;
slotsMap[dateStr] = true;
});
dateBookings.value = bookings;
dateHasSlots.value = slotsMap;
} catch (error) {
common_vendor.index.__f__("error", "at pages/booking/booking.vue:230", "加载日期预约统计失败", error);
}
};
const loadTimeSlots = async () => {
loading.value = true;
try {
const slots = await utils_api.api.timeslots.getList({
date: selectedDate.value,
is_active: true
});
timeslots.value = slots;
} catch (error) {
common_vendor.index.__f__("error", "at pages/booking/booking.vue:244", "加载时间槽失败", error);
} finally {
loading.value = false;
}
};
const selectDate = (day) => {
selectedDate.value = day.dateStr;
loadTimeSlots();
};
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 showBookingModal = (slot) => {
if (isBooking.value) {
common_vendor.index.showToast({
title: "正在处理,请稍候",
icon: "none"
});
return;
}
if (!slot.is_active || slot.current_people >= slot.max_people) {
common_vendor.index.__f__("log", "at pages/booking/booking.vue:278", "时间槽不可用", slot);
common_vendor.index.showToast({
title: "该时间段已不可用",
icon: "none"
});
return;
}
selectedSlot.value = slot;
peopleCount.value = 1;
notes.value = "";
showDialog.value = true;
common_vendor.index.__f__("log", "at pages/booking/booking.vue:289", "打开弹窗", showDialog.value);
};
const confirmBooking = async () => {
if (!selectedSlot.value)
return;
isBooking.value = true;
try {
await utils_api.api.appointments.create(selectedSlot.value.id, peopleCount.value, notes.value);
common_vendor.index.showToast({
title: "预约成功",
icon: "success"
});
showDialog.value = false;
loadTimeSlots();
loadDateBookings();
} catch (error) {
showDialog.value = false;
} finally {
isBooking.value = false;
}
};
return (_ctx, _cache) => {
var _a, _b, _c, _d;
return common_vendor.e({
a: common_vendor.t(currentDateStr.value),
b: common_vendor.f(weekdays, (day, k0, i0) => {
return {
a: common_vendor.t(day),
b: day
};
}),
c: common_vendor.f(calendarDays.value, (day, index, i0) => {
return common_vendor.e({
a: !day.isPlaceholder
}, !day.isPlaceholder ? {
b: common_vendor.t(day.day)
} : {}, {
c: !day.isPlaceholder && day.bookingCount > 0
}, !day.isPlaceholder && day.bookingCount > 0 ? {
d: common_vendor.t(day.bookingCount)
} : {}, {
e: day.dateStr || `placeholder-${index}`,
f: day.isPlaceholder ? 1 : "",
g: day.dateStr === selectedDate.value ? 1 : "",
h: day.isToday ? 1 : "",
i: !day.hasBookings && !day.isPlaceholder ? 1 : "",
j: day.hasBookings ? 1 : "",
k: common_vendor.o(($event) => !day.isPlaceholder && selectDate(day), day.dateStr || `placeholder-${index}`)
});
}),
d: common_vendor.t(selectedDate.value),
e: totalBookingCount.value > 0
}, totalBookingCount.value > 0 ? {
f: common_vendor.t(totalBookingCount.value)
} : {}, {
g: loading.value
}, loading.value ? {
h: common_vendor.p({
loading: true
})
} : timeslots.value.length === 0 ? {
j: common_vendor.p({
description: "暂无可预约时间段"
})
} : {
k: common_vendor.f(timeslots.value, (slot, k0, i0) => {
return {
a: common_vendor.t(formatTime(slot.start_time)),
b: common_vendor.t(formatTime(slot.end_time)),
c: common_vendor.t(slot.current_people),
d: common_vendor.t(slot.max_people),
e: "d331dabb-2-" + i0,
f: common_vendor.p({
theme: slot.current_people >= slot.max_people ? "danger" : "success",
size: "small"
}),
g: common_vendor.t(slot.current_people >= slot.max_people ? "已满" : "预约"),
h: common_vendor.o(($event) => showBookingModal(slot), slot.id),
i: "d331dabb-3-" + i0,
j: common_vendor.p({
["t-class"]: "btn-primary",
size: "small",
theme: "primary",
disabled: !slot.is_active || slot.current_people >= slot.max_people
}),
k: slot.id,
l: !slot.is_active || slot.current_people >= slot.max_people ? 1 : ""
};
})
}, {
i: timeslots.value.length === 0,
l: common_vendor.t(selectedDate.value),
m: common_vendor.t(((_a = selectedSlot.value) == null ? void 0 : _a.start_time) ? formatTime(selectedSlot.value.start_time) : ""),
n: common_vendor.t(((_b = selectedSlot.value) == null ? void 0 : _b.end_time) ? formatTime(selectedSlot.value.end_time) : ""),
o: common_vendor.o(($event) => peopleCount.value = $event),
p: common_vendor.p({
min: 1,
max: ((_c = selectedSlot.value) == null ? void 0 : _c.max_people) - ((_d = selectedSlot.value) == null ? void 0 : _d.current_people) || 1,
disabled: true,
size: "small",
modelValue: peopleCount.value
}),
q: common_vendor.o(confirmBooking),
r: common_vendor.o(($event) => showDialog.value = false),
s: common_vendor.o(($event) => showDialog.value = $event),
t: common_vendor.p({
title: "预约确认",
cancelBtn: "取消",
confirmBtn: "确认预约",
["t-class-confirm"]: "btn-primary",
visible: showDialog.value
})
});
};
}
});
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-d331dabb"]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/booking/booking.js.map

View File

@@ -0,0 +1,11 @@
{
"navigationBarTitleText": "我要预约",
"usingComponents": {
"t-loading": "../../uni_modules/tdesign-uniapp/components/loading/loading",
"t-empty": "../../uni_modules/tdesign-uniapp/components/empty/empty",
"t-tag": "../../uni_modules/tdesign-uniapp/components/tag/tag",
"t-button": "../../uni_modules/tdesign-uniapp/components/button/button",
"t-stepper": "../../uni_modules/tdesign-uniapp/components/stepper/stepper",
"t-dialog": "../../uni_modules/tdesign-uniapp/components/dialog/dialog"
}
}

View File

@@ -0,0 +1 @@
<view class="container data-v-d331dabb"><view class="date-selector data-v-d331dabb"><view class="calendar-header data-v-d331dabb"><text class="month-title data-v-d331dabb">{{a}}</text></view><view class="calendar-weekdays data-v-d331dabb"><text wx:for="{{b}}" wx:for-item="day" wx:key="b" class="weekday data-v-d331dabb">{{day.a}}</text></view><view class="calendar-days data-v-d331dabb"><view wx:for="{{c}}" wx:for-item="day" wx:key="e" class="{{['calendar-day', 'data-v-d331dabb', day.f && 'placeholder', day.g && 'selected', day.h && 'today', day.i && 'disabled', day.j && 'has-bookings']}}" bindtap="{{day.k}}"><text wx:if="{{day.a}}" class="day-number data-v-d331dabb">{{day.b}}</text><text wx:if="{{day.c}}" class="booking-count data-v-d331dabb">{{day.d}}人 </text></view></view></view><scroll-view class="timeslots-scroll data-v-d331dabb" scroll-y="true"><view class="timeslots-section data-v-d331dabb"><view class="section-title data-v-d331dabb">{{d}} 可选时间段 <text wx:if="{{e}}" class="total-booking data-v-d331dabb"> (总预约: {{f}}人) </text></view><t-loading wx:if="{{g}}" class="data-v-d331dabb" u-i="d331dabb-0" bind:__l="__l" u-p="{{h}}"/><view wx:elif="{{i}}" class="empty-state data-v-d331dabb"><t-empty wx:if="{{j}}" class="data-v-d331dabb" u-i="d331dabb-1" bind:__l="__l" u-p="{{j}}"/></view><view wx:else class="timeslots-list data-v-d331dabb"><view wx:for="{{k}}" wx:for-item="slot" wx:key="k" class="{{['timeslot-card', 'data-v-d331dabb', slot.l && 'disabled']}}"><view class="timeslot-info data-v-d331dabb"><view class="time-range data-v-d331dabb">{{slot.a}} - {{slot.b}}</view><view class="slot-status data-v-d331dabb"><t-tag wx:if="{{slot.f}}" class="data-v-d331dabb" u-s="{{['d']}}" u-i="{{slot.e}}" bind:__l="__l" u-p="{{slot.f}}">{{slot.c}}/{{slot.d}}</t-tag></view></view><t-button wx:if="{{slot.j}}" class="data-v-d331dabb" u-s="{{['d']}}" catchclick="{{slot.h}}" u-i="{{slot.i}}" bind:__l="__l" u-p="{{slot.j}}">{{slot.g}}</t-button></view></view></view></scroll-view><t-dialog wx:if="{{t}}" class="data-v-d331dabb" u-s="{{['content']}}" bindconfirm="{{q}}" bindcancel="{{r}}" u-i="d331dabb-4" bind:__l="__l" bindupdateVisible="{{s}}" u-p="{{t}}"><scroll-view type="list" scroll-y class="long-content data-v-d331dabb" slot="content"><view class="booking-dialog data-v-d331dabb"><view class="dialog-item data-v-d331dabb"><text class="dialog-label data-v-d331dabb">日期:</text><text class="dialog-value data-v-d331dabb">{{l}}</text></view><view class="dialog-item data-v-d331dabb"><text class="dialog-label data-v-d331dabb">时间段:</text><text class="dialog-value data-v-d331dabb">{{m}} - {{n}}</text></view><view class="dialog-item data-v-d331dabb"><text class="dialog-label data-v-d331dabb">人数:</text><t-stepper wx:if="{{p}}" class="data-v-d331dabb" u-i="d331dabb-5,d331dabb-4" bind:__l="__l" bindupdateModelValue="{{o}}" u-p="{{p}}"/></view></view></scroll-view></t-dialog></view>

View File

@@ -0,0 +1,179 @@
.container.data-v-d331dabb {
height: calc(100vh - var(--window-top));
display: flex;
flex-direction: column;
background: #f5f5f5;
overflow: hidden;
}
.date-selector.data-v-d331dabb {
flex-shrink: 0;
background: #ffffff;
margin: 24rpx 32rpx;
border-radius: 16rpx;
padding: 32rpx;
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.06);
}
.calendar-header.data-v-d331dabb {
text-align: center;
margin-bottom: 24rpx;
}
.month-title.data-v-d331dabb {
font-size: 32rpx;
font-weight: bold;
color: #333;
}
.calendar-weekdays.data-v-d331dabb {
display: grid;
grid-template-columns: repeat(7, 1fr);
gap: 8rpx;
margin-bottom: 16rpx;
padding: 0 10rpx;
}
.weekday.data-v-d331dabb {
font-size: 24rpx;
color: #999;
text-align: center;
}
.calendar-days.data-v-d331dabb {
display: grid;
grid-template-columns: repeat(7, 1fr);
gap: 8rpx;
padding: 0 10rpx;
}
.calendar-day.data-v-d331dabb {
height: 100rpx;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
border-radius: 8rpx;
cursor: pointer;
transition: all 0.3s ease;
}
.calendar-day.placeholder.data-v-d331dabb {
visibility: hidden;
}
.calendar-day.disabled.data-v-d331dabb {
opacity: 0.4;
pointer-events: none;
}
.calendar-day.has-bookings.data-v-d331dabb {
background: rgba(255, 122, 0, 0.08);
border: 2rpx solid #FF7A00;
}
.calendar-day.today.data-v-d331dabb {
background: rgba(255, 122, 0, 0.12);
}
.calendar-day.selected.data-v-d331dabb {
background: linear-gradient(135deg, #FF7A00 0%, #FF9500 100%);
}
.calendar-day.selected .day-number.data-v-d331dabb {
color: #ffffff;
}
.calendar-day.selected .booking-count.data-v-d331dabb {
color: #ffffff;
}
.day-number.data-v-d331dabb {
font-size: 28rpx;
color: #333;
margin-bottom: 4rpx;
}
.booking-count.data-v-d331dabb {
font-size: 20rpx;
color: #FF7A00;
}
.timeslots-scroll.data-v-d331dabb {
flex: 1;
overflow: hidden;
}
.timeslots-section.data-v-d331dabb {
padding: 32rpx;
}
.section-title.data-v-d331dabb {
font-size: 32rpx;
font-weight: bold;
color: #333;
margin-bottom: 24rpx;
display: flex;
align-items: center;
}
.total-booking.data-v-d331dabb {
font-size: 24rpx;
color: #FF7A00;
margin-left: 16rpx;
font-weight: normal;
}
.empty-state.data-v-d331dabb {
padding: 80rpx 0;
}
.timeslots-list.data-v-d331dabb {
display: flex;
flex-direction: column;
gap: 20rpx;
}
.timeslot-card.data-v-d331dabb {
background: #ffffff;
border-radius: 16rpx;
padding: 32rpx;
display: flex;
justify-content: space-between;
align-items: center;
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.06);
}
.timeslot-card.disabled.data-v-d331dabb {
opacity: 0.6;
}
.timeslot-info.data-v-d331dabb {
flex: 1;
}
.time-range.data-v-d331dabb {
font-size: 32rpx;
font-weight: bold;
color: #333;
margin-bottom: 16rpx;
}
.slot-status.data-v-d331dabb {
margin-top: 8rpx;
}
.booking-dialog.data-v-d331dabb {
padding: 32rpx 0;
}
.dialog-item.data-v-d331dabb {
display: flex;
align-items: center;
padding: 20rpx 0;
border-bottom: 1rpx solid #f0f0f0;
}
.dialog-item.data-v-d331dabb:last-child {
border-bottom: none;
}
.dialog-label.data-v-d331dabb {
width: 120rpx;
font-size: 28rpx;
color: #666;
}
.dialog-value.data-v-d331dabb {
flex: 1;
font-size: 28rpx;
color: #333;
font-weight: 500;
}
/* 按钮自定义样式 - 使用全局样式 */
.btn-primary {
background: linear-gradient(135deg, #FF7A00 0%, #FF9500 100%) !important;
border: none !important;
border-radius: 8rpx !important;
color: #FFFFFF !important;
box-shadow: 0 4rpx 12rpx rgba(255, 122, 0, 0.3) !important;
outline: none !important;
}
.btn-primary::after {
border: none !important;
box-shadow: none !important;
}
.btn-primary:active {
background: linear-gradient(135deg, #FF6900 0%, #FF8500 100%) !important;
}