diff --git a/src/components/Calender/index.vue b/src/components/Calender/index.vue index b3a1922..9c4e8ae 100644 --- a/src/components/Calender/index.vue +++ b/src/components/Calender/index.vue @@ -6,8 +6,9 @@
- 日历选择 - 选择住宿日期,以下价格为单晚参考价 + {{ t("common.calendar.title") }} + {{ + t("common.calendar.stayDateHint") }}
@@ -61,12 +62,15 @@ import { watch, onBeforeUnmount, } from "vue"; +import { useI18n } from "vue-i18n"; // 定义组件名称 defineOptions({ name: "Calendar", }); +const { t } = useI18n(); + // van-popup组件引用 const popup = ref(null); const show = ref(false); @@ -140,7 +144,15 @@ const emit = defineEmits([ ]); // 响应式数据 -const weekDays = ref(["一", "二", "三", "四", "五", "六", "日"]); +const weekDays = computed(() => [ + t("common.calendar.weekdays.monday"), + t("common.calendar.weekdays.tuesday"), + t("common.calendar.weekdays.wednesday"), + t("common.calendar.weekdays.thursday"), + t("common.calendar.weekdays.friday"), + t("common.calendar.weekdays.saturday"), + t("common.calendar.weekdays.sunday"), +]); const selectedDates = ref([]); const currentYear = ref(new Date().getFullYear()); const isRangeSelecting = ref(false); @@ -163,7 +175,7 @@ const yearMonthsGrid = computed(() => { months.push({ key: `${year}-${month}`, - title: `${year}年${month}月`, + title: t("common.calendar.monthTitle", { year, month }), year: year, month: month, grid: generateCalendarGrid(year, month), @@ -298,13 +310,13 @@ const getDateLabel = (dateStr) => { if (props.mode === "range") { if (dateStr === rangeStart.value && dateStr === rangeEnd.value) { // 当入住和离店是同一天时,显示"住/离" - return "住/离"; + return t("common.calendar.labels.stayAndLeave"); } if (dateStr === rangeStart.value) { - return "入住"; + return t("common.calendar.labels.checkIn"); } if (dateStr === rangeEnd.value) { - return "离店"; + return t("common.calendar.labels.checkOut"); } } @@ -367,7 +379,7 @@ const getDateLabelClass = (dateInfo) => { const handleDateClick = (dateInfo) => { if (!dateInfo) return; if (dateInfo.disabled) { - showToast("该日期不可选"); + showToast(t("common.calendar.errors.disabledDate")); // 仍然触发点击事件,供上层参考 emit("date-click", { date: dateInfo.date, @@ -421,11 +433,11 @@ const handleRangeSelection = (dateInfo) => { dateInfo.price !== undefined && dateInfo.price !== "-"; if (!hasPrice) { - showToast('所选日期不可预订,请重新选择'); + showToast(t("common.calendar.errors.dateUnavailable")); return; } if (dateInfo.stock !== undefined && Number(dateInfo.stock) <= 0) { - showToast("所选日期库存不足,请选择其他日期"); + showToast(t("common.calendar.errors.stockUnavailable")); return; } } @@ -438,7 +450,7 @@ const handleRangeSelection = (dateInfo) => { // 否则为结束日期(完成选择) if (rangeStart.value === dateInfo.date) { - showToast("离店日期不能与入住日期相同"); + showToast(t("common.calendar.errors.sameDate")); return; } @@ -453,7 +465,7 @@ const handleRangeSelection = (dateInfo) => { // 检查日期跨度是否超过28天 const daysBetween = calculateDaysBetween(rangeStart.value, rangeEnd.value); if (daysBetween > 28) { - showToast("预定时间不能超过28天"); + showToast(t("common.calendar.errors.maxRange")); rangeStart.value = null; rangeEnd.value = null; isRangeSelecting.value = false; @@ -467,7 +479,7 @@ const handleRangeSelection = (dateInfo) => { (d) => d.price === null || d.price === undefined || d.price === "-", ); if (missing) { - showToast("所选区间包含无价格日期,请重新选择"); + showToast(t("common.calendar.errors.missingPrice")); rangeStart.value = null; rangeEnd.value = null; return; @@ -478,7 +490,7 @@ const handleRangeSelection = (dateInfo) => { return item && item.stock !== undefined && Number(item.stock) <= 0; }); if (badStock) { - showToast("所选区间包含库存不足的日期,请重新选择"); + showToast(t("common.calendar.errors.rangeStockUnavailable")); rangeStart.value = null; rangeEnd.value = null; return; diff --git a/src/components/DateRangeSection/index.vue b/src/components/DateRangeSection/index.vue index 2805de5..d51a509 100644 --- a/src/components/DateRangeSection/index.vue +++ b/src/components/DateRangeSection/index.vue @@ -1,19 +1,19 @@ diff --git a/src/pages/home/components/QuickBookingContentList/index.vue b/src/pages/home/components/QuickBookingContentList/index.vue index 516ab34..c814d54 100644 --- a/src/pages/home/components/QuickBookingContentList/index.vue +++ b/src/pages/home/components/QuickBookingContentList/index.vue @@ -29,7 +29,8 @@ /{{ item.stockUnitLabel }}
- 下单 + {{ + t("home.quickBooking.order") }}
@@ -40,10 +41,13 @@ diff --git a/src/pages/order/components/OrderQrcode/index.vue b/src/pages/order/components/OrderQrcode/index.vue index a598f22..6957372 100644 --- a/src/pages/order/components/OrderQrcode/index.vue +++ b/src/pages/order/components/OrderQrcode/index.vue @@ -4,10 +4,10 @@
- 核销凭证 + {{ t("order.qrcode.title") }}
- 请向工作人员出示此码 + {{ t("order.qrcode.instruction") }}
@@ -25,11 +25,11 @@
- 总计{{ selectedVoucher.count }}{{ selectedVoucher.unit }} + {{ t("order.qrcode.total") }}{{ selectedVoucher.count }}{{ selectedVoucher.unit }}
- 剩{{ selectedVoucher.count - selectedVoucher.writeOffCount - }}{{ selectedVoucher.unit }}可用 + {{ t("order.qrcode.remaining") }}{{ selectedVoucher.count - selectedVoucher.writeOffCount + }}{{ selectedVoucher.unit }}{{ t("order.qrcode.available") }}
@@ -38,14 +38,14 @@ class="flex flex-col w-full items-center justify-center rounded-[8px] border border-ink-200 pt-[16px] pb-[32px] mt-[12px]">
- 凭证{{ + {{ t("order.qrcode.voucher") }}{{ selectedVoucherList.length > 1 ? currentVoucherIndex + 1 : "" }}
- 此码仅可核销{{ + {{ t("order.qrcode.onlyVerify") }}{{ selectedVoucher.count - selectedVoucher.writeOffCount - }}份 + }}{{ t("order.qrcode.unit") }}
@@ -77,7 +77,7 @@ -
扫码后点击下一张
+
{{ t("order.qrcode.swipeHint") }}
@@ -92,8 +92,11 @@ diff --git a/src/pages/order/components/Tabs/index.vue b/src/pages/order/components/Tabs/index.vue index fd4bfe7..89a5065 100644 --- a/src/pages/order/components/Tabs/index.vue +++ b/src/pages/order/components/Tabs/index.vue @@ -28,23 +28,23 @@ import { ref, reactive, + computed, onMounted, nextTick, watch, getCurrentInstance, } from "vue"; +import { useI18n } from "vue-i18n"; // 获取组件实例 const instance = getCurrentInstance(); +const { t } = useI18n(); // Props const props = defineProps({ tabs: { type: Array, - default: () => [ - { label: "全部订单", value: "all" }, - { label: "服务工单", value: "service" }, - ], + default: () => [], }, defaultActive: { type: Number, @@ -61,7 +61,11 @@ const emit = defineEmits(["change", "update:modelValue"]); // 响应式数据 const activeIndex = ref(props.defaultActive); -const tabList = ref(props.tabs); +const defaultTabs = computed(() => [ + { label: t("order.tabs.all"), value: "all" }, + { label: t("order.tabs.service"), value: "service" }, +]); +const tabList = computed(() => props.tabs.length ? props.tabs : defaultTabs.value); const indicatorLeft = ref(0); const indicatorWidth = ref(0); const tabItemRects = reactive([]); @@ -164,8 +168,7 @@ watch( // 监听tabs变化 watch( () => props.tabs, - (newTabs) => { - tabList.value = newTabs; + () => { // 重置初始化状态 indicatorInitialized.value = false; // 重新初始化指示器 diff --git a/src/pages/order/components/UserInfo/index.vue b/src/pages/order/components/UserInfo/index.vue index e1ee993..46366c9 100644 --- a/src/pages/order/components/UserInfo/index.vue +++ b/src/pages/order/components/UserInfo/index.vue @@ -2,12 +2,12 @@
- 住客姓名 + {{ t("order.user.guestName") }} {{ item.visitorName }}
- 联系电话 + {{ t("order.user.phone") }} {{ contactPhone }}
@@ -15,6 +15,9 @@ diff --git a/src/pages/service/index.vue b/src/pages/service/index.vue index e4d9e4a..c3db8ec 100644 --- a/src/pages/service/index.vue +++ b/src/pages/service/index.vue @@ -1,14 +1,15 @@