329 lines
7.1 KiB
Vue
329 lines
7.1 KiB
Vue
|
|
<template>
|
||
|
|
<!-- 语言切换区域 -->
|
||
|
|
<view class="lang-select">
|
||
|
|
<!-- 返回按钮 -->
|
||
|
|
<view class="back-btn" @click="goBack">
|
||
|
|
<text class="back-icon">←</text>
|
||
|
|
<text class="back-text">{{ $i18n.t('back') }}</text>
|
||
|
|
</view>
|
||
|
|
|
||
|
|
<view class="lang-title">
|
||
|
|
<text>{{ $i18n.t('languageSettings') }}</text>
|
||
|
|
</view>
|
||
|
|
<view class="current-lang">
|
||
|
|
<text class="current-lang-text">{{ $i18n.t('currentLanguage') }}: {{ getCurrentLangName() }}</text>
|
||
|
|
</view>
|
||
|
|
<view class="lang-buttons">
|
||
|
|
<view
|
||
|
|
class="lang-item"
|
||
|
|
:class="{ 'active': currentLang === 'zh' }"
|
||
|
|
@click="changeLang('zh')"
|
||
|
|
>
|
||
|
|
<view class="flag-icon">🇨🇳</view>
|
||
|
|
<text class="lang-text">{{ $i18n.t('chinese') }}</text>
|
||
|
|
<view class="check-icon" v-if="currentLang === 'zh'">✓</view>
|
||
|
|
</view>
|
||
|
|
|
||
|
|
<view
|
||
|
|
class="lang-item"
|
||
|
|
:class="{ 'active': currentLang === 'en' }"
|
||
|
|
@click="changeLang('en')"
|
||
|
|
>
|
||
|
|
<view class="flag-icon">🇺🇸</view>
|
||
|
|
<text class="lang-text">{{ $i18n.t('english') }}</text>
|
||
|
|
<view class="check-icon" v-if="currentLang === 'en'">✓</view>
|
||
|
|
</view>
|
||
|
|
<view
|
||
|
|
class="lang-item"
|
||
|
|
:class="{ 'active': currentLang === 'ru' }"
|
||
|
|
@click="changeLang('ru')"
|
||
|
|
>
|
||
|
|
<view class="flag-icon">🇷🇺</view>
|
||
|
|
<text class="lang-text">{{ $i18n.t('russian') }}</text>
|
||
|
|
<view class="check-icon" v-if="currentLang === 'ru'">✓</view>
|
||
|
|
</view>
|
||
|
|
<!-- <view
|
||
|
|
class="lang-item"
|
||
|
|
:class="{ 'active': currentLang === 'ja' }"
|
||
|
|
@click="changeLang('ja')"
|
||
|
|
>
|
||
|
|
<view class="flag-icon">🇯🇵</view>
|
||
|
|
<text class="lang-text">{{ $i18n.t('japanese') }}</text>
|
||
|
|
<view class="check-icon" v-if="currentLang === 'ja'">✓</view>
|
||
|
|
</view> -->
|
||
|
|
</view>
|
||
|
|
</view>
|
||
|
|
</template>
|
||
|
|
|
||
|
|
<script>
|
||
|
|
export default {
|
||
|
|
name: 'YuyanPage',
|
||
|
|
data() {
|
||
|
|
return {
|
||
|
|
currentLang: 'zh',
|
||
|
|
type:''
|
||
|
|
}
|
||
|
|
},
|
||
|
|
onLoad(option) {
|
||
|
|
this.type = option.type
|
||
|
|
},
|
||
|
|
methods: {
|
||
|
|
// 点击进行语言切换
|
||
|
|
changeLang(lang) {
|
||
|
|
// 设置语言
|
||
|
|
this.$i18n.setLanguage(lang);
|
||
|
|
this.currentLang = lang;
|
||
|
|
// 显示切换成功提示
|
||
|
|
uni.showToast({
|
||
|
|
title: this.$i18n.t('languageSwitchSuccess'),
|
||
|
|
icon: 'success',
|
||
|
|
duration: 1500
|
||
|
|
});
|
||
|
|
},
|
||
|
|
getCurrentLangName() {
|
||
|
|
const langMap = {
|
||
|
|
'zh': this.$i18n.t('chinese'),
|
||
|
|
'en': this.$i18n.t('english'),
|
||
|
|
'ja': this.$i18n.t('japanese'),
|
||
|
|
'ru': this.$i18n.t('russian')
|
||
|
|
};
|
||
|
|
return langMap[this.currentLang] || this.$i18n.t('chinese');
|
||
|
|
},
|
||
|
|
// 判断返回上一级还是回到登录页
|
||
|
|
goBack() {
|
||
|
|
if(this.type == 1){
|
||
|
|
uni.reLaunch({
|
||
|
|
url:'/pages/login/index'
|
||
|
|
})
|
||
|
|
}else{
|
||
|
|
uni.reLaunch({
|
||
|
|
url:'/pages/index/index'
|
||
|
|
})
|
||
|
|
}
|
||
|
|
}
|
||
|
|
},
|
||
|
|
// 添加页面显示时的生命周期,确保语言更新
|
||
|
|
onShow() {
|
||
|
|
// 获取当前语言
|
||
|
|
this.currentLang = this.$i18n.getCurrentLanguage()
|
||
|
|
// 强制更新组件
|
||
|
|
this.$forceUpdate()
|
||
|
|
},
|
||
|
|
// 监听多语言变化事件
|
||
|
|
mounted() {
|
||
|
|
this.currentLang = this.$i18n.getCurrentLanguage()
|
||
|
|
uni.$on('languageChanged', () => {
|
||
|
|
this.currentLang = this.$i18n.getCurrentLanguage()
|
||
|
|
this.$forceUpdate()
|
||
|
|
})
|
||
|
|
},
|
||
|
|
// 移除监听事件
|
||
|
|
beforeDestroy() {
|
||
|
|
uni.$off('languageChanged')
|
||
|
|
}
|
||
|
|
}
|
||
|
|
</script>
|
||
|
|
|
||
|
|
<style lang="scss" scoped>
|
||
|
|
.lang-select {
|
||
|
|
padding: 40rpx;
|
||
|
|
display: flex;
|
||
|
|
flex-direction: column;
|
||
|
|
align-items: center;
|
||
|
|
justify-content: center;
|
||
|
|
min-height: 100vh;
|
||
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||
|
|
position: relative;
|
||
|
|
overflow: hidden;
|
||
|
|
&::before {
|
||
|
|
content: '';
|
||
|
|
position: absolute;
|
||
|
|
top: -50%;
|
||
|
|
left: -50%;
|
||
|
|
width: 200%;
|
||
|
|
height: 200%;
|
||
|
|
background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
|
||
|
|
animation: float 6s ease-in-out infinite;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
@keyframes float {
|
||
|
|
0%, 100% {
|
||
|
|
transform: translateY(0px) rotate(0deg);
|
||
|
|
}
|
||
|
|
50% {
|
||
|
|
transform: translateY(-20px) rotate(180deg);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
.back-btn {
|
||
|
|
position: absolute;
|
||
|
|
top: 100rpx;
|
||
|
|
left: 40rpx;
|
||
|
|
z-index: 10;
|
||
|
|
display: flex;
|
||
|
|
align-items: center;
|
||
|
|
background: rgba(255, 255, 255, 0.2);
|
||
|
|
backdrop-filter: blur(10rpx);
|
||
|
|
border-radius: 30rpx;
|
||
|
|
padding: 10rpx 20rpx;
|
||
|
|
cursor: pointer;
|
||
|
|
transition: background 0.3s ease;
|
||
|
|
|
||
|
|
&:hover {
|
||
|
|
background: rgba(255, 255, 255, 0.3);
|
||
|
|
}
|
||
|
|
|
||
|
|
.back-icon {
|
||
|
|
font-size: 40rpx;
|
||
|
|
margin-right: 10rpx;
|
||
|
|
color: white;
|
||
|
|
}
|
||
|
|
|
||
|
|
.back-text {
|
||
|
|
font-size: 32rpx;
|
||
|
|
color: white;
|
||
|
|
font-weight: 500;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
.lang-title {
|
||
|
|
margin-bottom: 80rpx;
|
||
|
|
text-align: center;
|
||
|
|
position: relative;
|
||
|
|
z-index: 2;
|
||
|
|
|
||
|
|
text {
|
||
|
|
font-size: 48rpx;
|
||
|
|
font-weight: 600;
|
||
|
|
color: white;
|
||
|
|
text-shadow: 0 2rpx 4rpx rgba(0, 0, 0, 0.3);
|
||
|
|
background: linear-gradient(45deg, #fff, #f0f0f0);
|
||
|
|
-webkit-background-clip: text;
|
||
|
|
-webkit-text-fill-color: transparent;
|
||
|
|
background-clip: text;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
.current-lang {
|
||
|
|
margin-bottom: 60rpx;
|
||
|
|
text-align: center;
|
||
|
|
position: relative;
|
||
|
|
z-index: 2;
|
||
|
|
|
||
|
|
.current-lang-text {
|
||
|
|
font-size: 32rpx;
|
||
|
|
color: rgba(255, 255, 255, 0.9);
|
||
|
|
text-shadow: 0 1rpx 2rpx rgba(0, 0, 0, 0.3);
|
||
|
|
background: rgba(255, 255, 255, 0.1);
|
||
|
|
padding: 20rpx 40rpx;
|
||
|
|
border-radius: 30rpx;
|
||
|
|
backdrop-filter: blur(10rpx);
|
||
|
|
border: 1rpx solid rgba(255, 255, 255, 0.2);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
.lang-buttons {
|
||
|
|
width: 100%;
|
||
|
|
display: flex;
|
||
|
|
flex-direction: column;
|
||
|
|
gap: 40rpx;
|
||
|
|
position: relative;
|
||
|
|
z-index: 2;
|
||
|
|
}
|
||
|
|
|
||
|
|
.lang-item {
|
||
|
|
display: flex;
|
||
|
|
align-items: center;
|
||
|
|
padding: 40rpx 60rpx;
|
||
|
|
background: rgba(255, 255, 255, 0.95);
|
||
|
|
backdrop-filter: blur(10rpx);
|
||
|
|
border-radius: 20rpx;
|
||
|
|
box-shadow: 0 8rpx 32rpx rgba(0, 0, 0, 0.1);
|
||
|
|
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||
|
|
cursor: pointer;
|
||
|
|
border: 1rpx solid rgba(255, 255, 255, 0.2);
|
||
|
|
position: relative;
|
||
|
|
overflow: hidden;
|
||
|
|
margin-top: 30rpx;
|
||
|
|
&::before {
|
||
|
|
content: '';
|
||
|
|
position: absolute;
|
||
|
|
top: 0;
|
||
|
|
left: -100%;
|
||
|
|
width: 100%;
|
||
|
|
height: 100%;
|
||
|
|
background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
|
||
|
|
transition: left 0.5s;
|
||
|
|
}
|
||
|
|
|
||
|
|
&:active {
|
||
|
|
transform: scale(0.98);
|
||
|
|
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.15);
|
||
|
|
|
||
|
|
&::before {
|
||
|
|
left: 100%;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
&:hover {
|
||
|
|
background: rgba(255, 255, 255, 1);
|
||
|
|
box-shadow: 0 12rpx 40rpx rgba(0, 0, 0, 0.15);
|
||
|
|
transform: translateY(-2rpx);
|
||
|
|
}
|
||
|
|
|
||
|
|
&.active {
|
||
|
|
background: rgba(255, 255, 255, 1);
|
||
|
|
box-shadow: 0 12rpx 40rpx rgba(0, 0, 0, 0.15);
|
||
|
|
transform: translateY(-2rpx);
|
||
|
|
border-color: #667eea;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
.flag-icon {
|
||
|
|
font-size: 60rpx;
|
||
|
|
margin-right: 40rpx;
|
||
|
|
width: 80rpx;
|
||
|
|
height: 60rpx;
|
||
|
|
display: flex;
|
||
|
|
align-items: center;
|
||
|
|
justify-content: center;
|
||
|
|
border-radius: 8rpx;
|
||
|
|
overflow: hidden;
|
||
|
|
position: relative;
|
||
|
|
|
||
|
|
&::after {
|
||
|
|
content: '';
|
||
|
|
position: absolute;
|
||
|
|
top: 0;
|
||
|
|
left: 0;
|
||
|
|
right: 0;
|
||
|
|
bottom: 0;
|
||
|
|
background: linear-gradient(45deg, transparent 30%, rgba(255, 255, 255, 0.3) 50%, transparent 70%);
|
||
|
|
transform: translateX(-100%);
|
||
|
|
transition: transform 0.6s;
|
||
|
|
}
|
||
|
|
|
||
|
|
&:hover::after {
|
||
|
|
transform: translateX(100%);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
.lang-text {
|
||
|
|
font-size: 36rpx;
|
||
|
|
font-weight: 500;
|
||
|
|
color: #333;
|
||
|
|
flex: 1;
|
||
|
|
transition: color 0.3s ease;
|
||
|
|
}
|
||
|
|
|
||
|
|
.lang-item:hover .lang-text {
|
||
|
|
color: #667eea;
|
||
|
|
}
|
||
|
|
|
||
|
|
.check-icon {
|
||
|
|
font-size: 40rpx;
|
||
|
|
color: #667eea;
|
||
|
|
margin-left: 20rpx;
|
||
|
|
}
|
||
|
|
</style>
|