refactor: 国际化文本迁移至全局 locales/messages.js

将组件级 i18n 对象重构为统一由全局 locales/messages.js 管理,确保中英文语言切换时正确显示对应文本。

- 新增 utils/i18n.js 国际化工具函数
- 更新 store/$t.mixin.js 翻译混入逻辑
- 迁移 pkgService、pkgBooking、pkgAccount、pkgExplore、pages 等共 58 个组件的中英文文本至全局消息表
This commit is contained in:
liangjian
2026-07-24 13:43:41 +08:00
parent 445bd850f4
commit 6e721ccc7e
58 changed files with 1810 additions and 4065 deletions

View File

@@ -1,14 +1,14 @@
<template>
<view class="pay-page tn-safe-area-inset-bottom">
<tn-nav-bar :isBack="true" :bottomShadow="false" backgroundColor="#F8F9FA">
<view class="tn-text-bold tn-text-xl tn-color-black">{{ t('title') }}</view>
<view class="tn-text-bold tn-text-xl tn-color-black">{{ $tr('支付定金') }}</view>
</tn-nav-bar>
<view class="pay-content tn-padding" :style="{paddingTop: vuex_custom_bar_height + 'px', paddingBottom: '200rpx'}">
<!-- 支付金额区 -->
<view class="amount-area tn-flex tn-flex-direction-column tn-flex-col-center tn-margin-top-xl tn-margin-bottom-xl">
<view class="tn-color-gray tn-text-md">{{ t('paymentAmount') }}</view>
<view class="tn-color-gray tn-text-md">{{ $tr('应付定金') }}</view>
<view class="tn-text-bold tn-color-black tn-margin-top-sm amount-text">
<text class="tn-text-xl tn-margin-right-xs">$</text>500.00
</view>
@@ -21,48 +21,48 @@
<view class="icon-bg-box tn-flex tn-flex-col-center tn-flex-row-center tn-margin-right-sm">
<text class="tn-icon-building bill-head-icon"></text>
</view>
<view class="tn-color-gray tn-text-md">{{ t('billTo') }}</view>
<view class="tn-color-gray tn-text-md">{{ $tr('收款方') }}</view>
</view>
<view class="tn-text-bold tn-text-md tn-color-black">{{ t('company') }}</view>
<view class="tn-text-bold tn-text-md tn-color-black">{{ $tr('绿居物业管理有限公司') }}</view>
</view>
<view class="tn-flex tn-flex-row-between tn-flex-col-center tn-margin-bottom">
<view class="tn-color-gray tn-text-md">{{ t('roomType') }}</view>
<view class="tn-color-gray tn-text-md">{{ $tr('房源风格') }}</view>
<view class="tn-text-bold tn-text-md tn-color-black clamp-text-1" style="max-width: 400rpx; text-align: right;">
{{ displayStyleName }}
</view>
</view>
<view class="tn-flex tn-flex-row-between tn-flex-col-center tn-margin-bottom" v-if="roomData && (roomData.roomTypeName || roomData.roomTypeNameEn)">
<view class="tn-color-gray tn-text-md">{{ t('roomTypeNameLabel') }}</view>
<view class="tn-color-gray tn-text-md">{{ $tr('房型') }}</view>
<view class="tn-text-bold tn-text-md tn-color-black clamp-text-1" style="max-width: 400rpx; text-align: right;">
{{ displayRoomTypeName }}
</view>
</view>
<view class="tn-flex tn-flex-row-between tn-flex-col-center tn-margin-bottom">
<view class="tn-color-gray tn-text-md">{{ t('location') }}</view>
<view class="tn-color-gray tn-text-md">{{ $tr('楼栋位置') }}</view>
<view class="tn-text-bold tn-text-md tn-color-black clamp-text-1" style="max-width: 400rpx; text-align: right;">{{ displayLocationText }}</view>
</view>
<view class="tn-flex tn-flex-row-between tn-flex-col-center tn-margin-bottom" v-if="roomData && roomData.startDate">
<view class="tn-color-gray tn-text-md">{{ t('bookingPeriod') }}</view>
<view class="tn-color-gray tn-text-md">{{ $tr('预订时间') }}</view>
<view class="tn-text-bold tn-text-md tn-color-black clamp-text-1" style="max-width: 400rpx; text-align: right;">
{{ roomData.startDate }} {{ t('toLabel') }} {{ roomData.endDate }}
{{ roomData.startDate }} {{ $tr('至') }} {{ roomData.endDate }}
</view>
</view>
<view class="tn-flex tn-flex-row-between tn-flex-col-center tn-margin-bottom" v-if="roomData && roomData.stayNights">
<view class="tn-color-gray tn-text-md">{{ t('stayNights') }}</view>
<view class="tn-text-bold tn-text-md tn-color-black">{{ roomData.stayNights }} {{ t('nightUnit') }}</view>
<view class="tn-color-gray tn-text-md">{{ $tr('入住晚数') }}</view>
<view class="tn-text-bold tn-text-md tn-color-black">{{ roomData.stayNights }} {{ $tr('晚') }}</view>
</view>
<view class="bill-divider tn-margin-top-md tn-margin-bottom"></view>
<view class="tn-flex tn-flex-row-between tn-flex-col-center tn-margin-top-md">
<view class="tn-color-black tn-text-bold tn-text-lg">{{ t('total') }}</view>
<view class="tn-color-black tn-text-bold tn-text-lg">{{ $tr('合计') }}</view>
<view class="tn-text-bold" style="color: $brand-primary; font-size: 40rpx;">$500.00</view>
</view>
</view>
<!-- 支付方式选择 -->
<view class="payment-methods">
<view class="tn-text-bold tn-text-xl tn-color-black tn-margin-bottom-lg">{{ t('paymentMethod') }}</view>
<view class="tn-text-bold tn-text-xl tn-color-black tn-margin-bottom-lg">{{ $tr('选择支付方式') }}</view>
<view class="method-item tn-flex tn-flex-row-between tn-flex-col-center tn-padding tn-margin-bottom"
:class="payMethod === 'Wechat' ? 'method-active' : ''" @click="payMethod = 'Wechat'">
@@ -105,10 +105,10 @@
</view>
<view class="tip-panel tn-padding-lg">
<view class="tn-text-bold tn-text-lg tn-color-black">{{ t('fallbackTitle') }}</view>
<view class="tn-color-gray tn-text-sm tn-margin-top-sm">{{ t('fallbackDesc') }}</view>
<view class="tn-text-bold tn-text-lg tn-color-black">{{ $tr('支付接口暂未接入') }}</view>
<view class="tn-color-gray tn-text-sm tn-margin-top-sm">{{ $tr('当前版本还未接通真实定金支付。你可以先改走已接好的入住申请提交流程,后续由工作人员跟进。') }}</view>
<view class="tip-action tn-margin-top-lg" @click="fallbackToApplication">
<text class="tn-text-bold">{{ t('fallbackAction') }}</text>
<text class="tn-text-bold">{{ $tr('改为提交入住申请') }}</text>
</view>
</view>
@@ -117,11 +117,11 @@
<!-- 底部固定支付按钮 -->
<view class="fixed-bottom-btn-area tn-flex tn-flex-row-between tn-flex-col-center">
<view class="tn-flex tn-flex-direction-column">
<view class="tn-text-sm tn-color-gray">{{ t('total') }}</view>
<view class="tn-text-sm tn-color-gray">{{ $tr('合计') }}</view>
<view class="tn-text-bold tn-text-xl tn-color-black">$500.00</view>
</view>
<view class="custom-btn btn-primary" style="width: 60%; height: 100rpx;" @click="handlePay" :class="{ 'btn-disabled': isSubmitting }">
<text class="tn-text-bold tn-text-lg">{{ isSubmitting ? (language === 'zh' ? '支付中...' : 'Processing...') : t('payNow') }}</text>
<text class="tn-text-bold tn-text-lg">{{ isSubmitting ? (language === 'zh' ? '支付中...' : 'Processing...') : $tr('确认支付并提交预订') }}</text>
</view>
</view>
@@ -136,77 +136,7 @@ export default {
return {
isSubmitting: false,
payMethod: 'Wechat',
roomData: null,
i18n: {
zh: {
title: '支付定金',
paymentAmount: '应付定金',
billTo: '收款方',
company: '绿居物业管理有限公司',
roomType: '房源风格',
roomTypeNameLabel: '房型',
location: '楼栋位置',
bookingPeriod: '预订时间',
toLabel: '至',
stayNights: '入住晚数',
nightUnit: '晚',
total: '合计',
paymentMethod: '选择支付方式',
payNow: '确认支付并提交预订',
fallbackTitle: '支付接口暂未接入',
fallbackDesc: '当前版本还未接通真实定金支付。你可以先改走已接好的入住申请提交流程,后续由工作人员跟进。',
fallbackAction: '改为提交入住申请',
fallbackNavigateTitle: '入住申请',
fallbackNavigateDesc: '支付接口暂未接入,先提交入住申请,由工作人员继续跟进。',
paying: '支付中...',
pendingTitle: '支付接口待接入',
paymentNoticeTitle: '用户须知',
paymentNoticeMethodLabel: '支付方式',
paymentNoticeAmountLabel: '支付金额',
paymentNoticeItemLabel: '支付项目',
paymentNoticeItemValue: '房源定金',
paymentNoticeLine1: '请确认支付方式和金额无误后再继续操作。',
paymentNoticeLine2: '当前页面为预支付引导页,真实支付接口暂未接入。',
paymentNoticeLine3: '确认后将进入后续提交流程,由工作人员继续跟进。',
paymentNoticeConfirm: '继续',
paymentNoticeCancel: '取消',
laterAction: '我知道了'
},
en: {
title: 'Deposit Payment',
paymentAmount: 'Deposit Amount',
billTo: 'Bill To',
company: 'Lüju Property Management',
roomType: 'Style',
roomTypeNameLabel: 'Room Type',
location: 'Location',
bookingPeriod: 'Booking Period',
toLabel: 'to',
stayNights: 'Stay Nights',
nightUnit: 'nights',
total: 'Total',
paymentMethod: 'Payment Method',
payNow: 'Pay and Submit',
fallbackTitle: 'Payment API Pending',
fallbackDesc: 'The real deposit payment flow is not ready yet. You can submit an application first and let staff follow up.',
fallbackAction: 'Submit Application Instead',
fallbackNavigateTitle: 'Stay Application',
fallbackNavigateDesc: 'The payment API is not ready yet. Submit a stay application first and let staff follow up.',
paying: 'Processing...',
pendingTitle: 'Payment API Pending',
paymentNoticeTitle: 'Payment Notice',
paymentNoticeMethodLabel: 'Payment Method',
paymentNoticeAmountLabel: 'Amount',
paymentNoticeItemLabel: 'Charge Item',
paymentNoticeItemValue: 'Deposit',
paymentNoticeLine1: 'Please confirm the payment method and amount before continuing.',
paymentNoticeLine2: 'This page is a pre-payment guide and the real payment API is not connected yet.',
paymentNoticeLine3: 'After confirmation, the process continues to the follow-up submission flow for staff handling.',
paymentNoticeConfirm: 'Continue',
paymentNoticeCancel: 'Cancel',
laterAction: 'Later'
}
}
roomData: null
}
},
computed: {
@@ -256,26 +186,23 @@ export default {
}
},
methods: {
t(key) {
return this.$tm('pkgBooking.pay.pay', key)
},
confirmPaymentNotice() {
const content = [
`${this.t('paymentNoticeItemLabel')}: ${this.t('paymentNoticeItemValue')}`,
`${this.t('paymentNoticeMethodLabel')}: ${this.payMethod}`,
`${this.t('paymentNoticeAmountLabel')}: $500.00`,
`${this.$tr('支付项目')}: ${this.$tr('房源定金')}`,
`${this.$tr('支付方式')}: ${this.payMethod}`,
`${this.$tr('支付金额')}: $500.00`,
'',
`1. ${this.t('paymentNoticeLine1')}`,
`2. ${this.t('paymentNoticeLine2')}`,
`3. ${this.t('paymentNoticeLine3')}`
`1. ${this.$tr('请确认支付方式和金额无误后再继续操作。')}`,
`2. ${this.$tr('当前页面为预支付引导页,真实支付接口暂未接入。')}`,
`3. ${this.$tr('确认后将进入后续提交流程,由工作人员继续跟进。')}`
].join('\n')
return new Promise((resolve) => {
uni.showModal({
title: this.t('paymentNoticeTitle'),
title: this.$tr('用户须知'),
content,
confirmText: this.t('paymentNoticeConfirm'),
cancelText: this.t('paymentNoticeCancel'),
confirmText: this.$tr('继续'),
cancelText: this.$tr('取消'),
success: (res) => resolve(!!(res && res.confirm)),
fail: () => resolve(false)
})
@@ -314,7 +241,7 @@ export default {
const descZh = '支付接口暂未接入,先提交入住申请,由工作人员继续跟进。'
const descEn = 'The payment API is not ready yet. Submit a stay application first and let staff follow up.'
uni.navigateTo({
url: `/pkgService/submit_request/submit_request?title=${encodeURIComponent(this.t('fallbackNavigateTitle'))}&titleZh=${encodeURIComponent(titleZh)}&titleEn=${encodeURIComponent(titleEn)}&desc=${encodeURIComponent(this.t('fallbackNavigateDesc'))}&descZh=${encodeURIComponent(descZh)}&descEn=${encodeURIComponent(descEn)}&payload=${encodeURIComponent(JSON.stringify(payload))}`
url: `/pkgService/submit_request/submit_request?title=${encodeURIComponent(this.$tr('入住申请'))}&titleZh=${encodeURIComponent(titleZh)}&titleEn=${encodeURIComponent(titleEn)}&desc=${encodeURIComponent(this.$tr('支付接口暂未接入,先提交入住申请,由工作人员继续跟进。'))}&descZh=${encodeURIComponent(descZh)}&descEn=${encodeURIComponent(descEn)}&payload=${encodeURIComponent(JSON.stringify(payload))}`
})
},
handlePay() {
@@ -322,16 +249,16 @@ export default {
this.confirmPaymentNotice().then((confirmed) => {
if (!confirmed) return
this.isSubmitting = true
uni.showLoading({ title: this.t('paying') })
uni.showLoading({ title: this.$tr('支付中...') })
setTimeout(() => {
uni.hideLoading()
this.isSubmitting = false
uni.showModal({
title: this.t('pendingTitle'),
content: this.t('fallbackDesc'),
confirmText: this.t('fallbackAction'),
cancelText: this.t('laterAction'),
title: this.$tr('支付接口待接入'),
content: this.$tr('当前版本还未接通真实定金支付。你可以先改走已接好的入住申请提交流程,后续由工作人员跟进。'),
confirmText: this.$tr('改为提交入住申请'),
cancelText: this.$tr('我知道了'),
success: (res) => {
if (res.confirm) {
this.fallbackToApplication()