From a6a31dd621b0724a06507a06e2d58c500c5422c4 Mon Sep 17 00:00:00 2001 From: gongfuxiang Date: Thu, 17 Apr 2025 11:43:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=9A=E8=AF=AD=E8=A8=80=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.vue | 11 +++++++- components/lang-switch/lang-switch.vue | 38 ++++++++++++-------------- 2 files changed, 28 insertions(+), 21 deletions(-) diff --git a/App.vue b/App.vue index f430ff1d..15c4edfd 100644 --- a/App.vue +++ b/App.vue @@ -2865,7 +2865,16 @@ // 获取当前语言 get_language_value() { - return uni.getLocale() || this.data.default_language; + // 当前系统语言、默认中文 + let value = uni.getLocale() || this.data.default_language; + // 语言标识转换和后端一致 + let arr = { + 'zh-Hans': 'zh', + 'zh-Hant': 'cht', + 'es': 'spa', + 'fra': 'fr', + }; + return ((arr[value] || null) == null) ? value : arr[value]; }, // 选择用户地理位置 diff --git a/components/lang-switch/lang-switch.vue b/components/lang-switch/lang-switch.vue index 416ddec8..d76ffe64 100644 --- a/components/lang-switch/lang-switch.vue +++ b/components/lang-switch/lang-switch.vue @@ -2,20 +2,24 @@ - + - + - - +
{{ $t('common.multilingual') }}
+ - + {{ value }} - {{ $t('common.confirm') }} + + + + + @@ -49,6 +53,7 @@ isEmpty, lang_open_event() { var language_key = app.globalData.get_language_value(); + console.log(language_key) var language_list = this.$t('language'); this.setData({ language_list: language_list, @@ -86,18 +91,18 @@ /** * 弹窗 */ - .nav-popup-container { + .lang-popup-container { padding: 20rpx 10rpx 0 10rpx; background: #fff; } - .nav-popup-container .close { + .lang-popup-container .close { position: absolute; top: 24rpx; right: 20rpx; z-index: 2; } - .nav-popup-title { + .lang-popup-title { position: absolute; top: 20rpx; left: 50%; @@ -106,21 +111,14 @@ font-size: 32rpx; } - .nav-popup-content { + .lang-popup-content { max-height: 80vh; overflow-y: scroll; overflow-x: hidden; - padding: 50rpx 60rpx; - padding-bottom: 30rpx; + padding: 50rpx 20rpx; + padding-bottom: 40rpx; } - .confirm-button { - color: #fff; - height: 60rpx; - border-radius: 100rpx; - padding: 6rpx 22rpx; - margin-top: 40rpx; - } - .nav-popup-list { + .lang-popup-list { padding: 20rpx 0; border-bottom: 1px solid #f5f5f5; font-size: 32rpx;