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,7 +1,7 @@
<template>
<view class="registration-records-page tn-safe-area-inset-bottom">
<tn-nav-bar :isBack="true" :bottomShadow="false" backgroundColor="transparent">
<view class="tn-text-bold tn-text-xl tn-color-black">{{ t('navTitle') }}</view>
<view class="tn-text-bold tn-text-xl tn-color-black">{{ $tr('注册记录') }}</view>
</tn-nav-bar>
<view class="page-main tn-padding" :style="{ paddingTop: vuex_custom_bar_height + 'px', paddingBottom: '48rpx' }">
@@ -20,8 +20,8 @@
</scroll-view>
<view v-if="providerUnavailable" class="empty-panel tn-padding-lg">
<view class="empty-title">{{ t('providerUnavailableTitle') }}</view>
<view class="empty-desc tn-margin-top-sm">{{ t('providerUnavailableDesc') }}</view>
<view class="empty-title">{{ $tr('当前无法获取微信身份') }}</view>
<view class="empty-desc tn-margin-top-sm">{{ $tr('请在微信小程序中打开后,再查看当前微信账号提交的注册记录。') }}</view>
</view>
<view v-else-if="list.length">
@@ -33,7 +33,7 @@
>
<view class="card-head tn-flex tn-flex-row-between tn-flex-col-center">
<view class="card-title-wrap">
<view class="card-title">{{ item.name || item.account || t('registrationFallbackTitle') }}</view>
<view class="card-title">{{ item.name || item.account || $tr('人员注册申请') }}</view>
<view class="card-code tn-margin-top-xs">{{ item.code || '--' }}</view>
</view>
<view :class="['status-badge', 'status-' + resolveStatusType(item.approvalStatus)]">
@@ -43,50 +43,50 @@
<view class="card-body tn-margin-top">
<view class="info-row tn-flex tn-flex-row-between">
<text class="info-label">{{ t('accountLabel') }}</text>
<text class="info-label">{{ $tr('注册账号') }}</text>
<text class="info-value">{{ item.account || '--' }}</text>
</view>
<view class="info-row tn-flex tn-flex-row-between">
<text class="info-label">{{ t('phoneLabel') }}</text>
<text class="info-label">{{ $tr('手机号') }}</text>
<text class="info-value">{{ item.phone || '--' }}</text>
</view>
<view class="info-row tn-flex tn-flex-row-between">
<text class="info-label">{{ t('idNumberLabel') }}</text>
<text class="info-label">{{ $tr('证件号') }}</text>
<text class="info-value">{{ item.idCard || item.passportNumber || '--' }}</text>
</view>
<view class="info-row tn-flex tn-flex-row-between">
<text class="info-label">{{ t('submittedAtLabel') }}</text>
<text class="info-label">{{ $tr('提交时间') }}</text>
<text class="info-value">{{ formatDateTime(item.createTime) }}</text>
</view>
<view v-if="item.approveTime" class="info-row tn-flex tn-flex-row-between">
<text class="info-label">{{ t('approvedAtLabel') }}</text>
<text class="info-label">{{ $tr('审批时间') }}</text>
<text class="info-value">{{ formatDateTime(item.approveTime) }}</text>
</view>
<view v-if="item.approveReason" class="remark-panel tn-margin-top">
<view class="remark-label">{{ item.approvalStatus === -1 ? t('rejectReasonLabel') : t('approvalRemarkLabel') }}</view>
<view class="remark-label">{{ item.approvalStatus === -1 ? $tr('驳回原因') : $tr('审批意见') }}</view>
<view class="remark-text tn-margin-top-xs">{{ item.approveReason }}</view>
</view>
</view>
</view>
<view class="load-state">
<text v-if="loadingMore">{{ t('loadingMore') }}</text>
<text v-else-if="!hasMore">{{ t('noMore') }}</text>
<text v-else>{{ t('pullUpMore') }}</text>
<text v-if="loadingMore">{{ $tr('加载中...') }}</text>
<text v-else-if="!hasMore">{{ $tr('没有更多记录了') }}</text>
<text v-else>{{ $tr('上拉加载更多') }}</text>
</view>
</view>
<view v-else-if="!loading" class="empty-panel tn-padding-lg">
<view class="empty-title">{{ t('emptyTitle') }}</view>
<view class="empty-desc tn-margin-top-sm">{{ t('emptyDesc') }}</view>
<view class="empty-title">{{ $tr('暂无注册记录') }}</view>
<view class="empty-desc tn-margin-top-sm">{{ $tr('当前微信账号还没有提交过人员注册申请。') }}</view>
<view class="action-btn tn-margin-top-lg" @click="goToRegister">
<text class="tn-text-bold">{{ t('goRegister') }}</text>
<text class="tn-text-bold">{{ $tr('去提交注册申请') }}</text>
</view>
</view>
<view v-if="loading && !list.length && !providerUnavailable" class="empty-panel tn-padding-lg">
<view class="empty-title">{{ t('loadingTitle') }}</view>
<view class="empty-desc tn-margin-top-sm">{{ t('loadingDesc') }}</view>
<view class="empty-title">{{ $tr('注册记录加载中') }}</view>
<view class="empty-desc tn-margin-top-sm">{{ $tr('正在同步当前微信账号提交的注册申请记录,请稍候。') }}</view>
</view>
</view>
</view>
@@ -152,15 +152,12 @@ export default {
}
},
methods: {
t(key, params) {
return this.$tm('pkgAccount.registration_records', key, params)
},
syncStatusOptions() {
this.statusOptions = [
{ label: this.t('statusAll'), value: '' },
{ label: this.t('statusPending'), value: 0 },
{ label: this.t('statusApproved'), value: 1 },
{ label: this.t('statusRejected'), value: -1 }
{ label: this.$tr('全部'), value: '' },
{ label: this.$tr('审核中'), value: 0 },
{ label: this.$tr('已通过'), value: 1 },
{ label: this.$tr('已驳回'), value: -1 }
]
},
syncNavigationTitle() {
@@ -187,11 +184,11 @@ export default {
},
getStatusText(status) {
const map = {
0: this.t('statusPending'),
1: this.t('statusApproved'),
'-1': this.t('statusRejected')
0: this.$tr('审核中'),
1: this.$tr('已通过'),
'-1': this.$tr('已驳回')
}
return map[status] || this.t('statusProcessing')
return map[status] || this.$tr('处理中')
},
getDisplayStatusText(item = {}) {
if (this.language !== 'en' && item.approvalStatusDesc) {
@@ -301,7 +298,7 @@ export default {
this.pageIndex = Math.max(1, this.pageIndex - 1)
}
uni.showToast({
title: (error && (error.message || error.msg)) || this.t('loadError'),
title: (error && (error.message || error.msg)) || this.$tr('注册记录加载失败'),
icon: 'none'
})
})