@@ -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 @@
- 入住
+ {{ t("common.dateRange.checkIn") }}
{{ selectedDate.startDate }}
{{
- selectedDate.totalDays }}晚
- 离店
+ selectedDate.totalDays }}{{ t("common.dateRange.nights") }}
+ {{ t("common.dateRange.checkOut") }}
{{ selectedDate.endDate }}
- 房间详情
+ {{ t("common.dateRange.roomDetails") }}
@@ -21,6 +21,9 @@
diff --git a/src/components/Qrcode/index.vue b/src/components/Qrcode/index.vue
index 197731e..5662806 100644
--- a/src/components/Qrcode/index.vue
+++ b/src/components/Qrcode/index.vue
@@ -12,9 +12,11 @@
\ No newline at end of file
+
diff --git a/src/components/SumCard/index.vue b/src/components/SumCard/index.vue
index 737e076..c916fba 100644
--- a/src/components/SumCard/index.vue
+++ b/src/components/SumCard/index.vue
@@ -1,17 +1,21 @@
- 价格
+ {{ t("common.summary.price") }}
¥{{ referencePrice }}
- 折扣优惠
+ {{ t("common.summary.discount") }}
-¥{{ discount }}
diff --git a/src/pages/home/components/ChatInputArea/index.vue b/src/pages/home/components/ChatInputArea/index.vue
index 3c202bd..c0c6bde 100644
--- a/src/pages/home/components/ChatInputArea/index.vue
+++ b/src/pages/home/components/ChatInputArea/index.vue
@@ -27,13 +27,16 @@