bitcooo
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

135 lines
3.1 KiB

<template>
<view class="">
<navigation :showBack="true" :bgnum="true">
{{ i18n.Language }}
</navigation>
<view class="main">
<view class="main_con">
<u-radio-group v-model="value" @change="radioGroupChange">
<view class="item flex" v-for="(item, index) in list" :key="index" @click="nowLanguage(item,index)">
<view class="text1">
{{item.lang}}
</view>
<u-radio @change="radioChange" :name="item.name" :disabled="item.disabled"
active-color="#5B53FF">
</u-radio>
</view>
</u-radio-group>
<view class="select_btn" @click="confirmLanguage">
{{ i18n.langSelect }}
</view>
</view>
</view>
</view>
</template>
<script>
import cont from "@/components/navigation/navigation.vue"
export default {
data() {
return {
language: this.$store.state.language == 'en' ? 'English' : '简体中文',
checked: false,
langInfo: {},
lang: '',
list: [{
lang: this.$t('index').langfan,
disabled: false,
name: "b",
},
{
lang: this.$t('index').langjian,
disabled: false,
name: "a",
},
{
lang: this.$t('index').eng,
disabled: false,
name: "c",
},
{
lang: this.$t('index').by,
disabled: false,
name: "D",
},
],
// u-radio-group的v-model绑定的值如果设置为某个radio的name,就会被默认选中
value: 'c',
};
},
methods: {
// 中英化
// 判断当前是什么语言
nowLanguage(e, i) {
console.log(e, 22222)
this.value = e.name
this.lang = e.lang
this.langInfo = e;
console.log(this.langInfo, 22222)
},
confirmLanguage() {
uni.setStorageSync('lang', this.value)
console.log(this.langInfo, 1212212)
if (this.langInfo.name == 'c') {
this._i18n.locale = 'en'
this.$store.commit('setLanguage', 'en')
uni.setStorageSync('langTrue', 'English')
uni.setStorageSync("language", 'en')
} else if (this.langInfo.name == 'a') {
this._i18n.locale = 'zh-CN'
this.$store.commit('setLanguage', 'zh-CN')
uni.setStorageSync("language", 'zh-CN')
uni.setStorageSync('langTrue', '简体中文')
} else if (this.langInfo.name == 'b'){
this._i18n.locale = 'zh-CNF'
this.$store.commit('setLanguage', 'zh-CNF')
uni.setStorageSync("language", 'zh-CNF')
uni.setStorageSync('langTrue', '繁體中文')
}else if (this.langInfo.name == 'd'){
this._i18n.locale = 'by'
this.$store.commit('setLanguage', 'by')
uni.setStorageSync("language", 'by')
uni.setStorageSync('langTrue', 'Русский')
}
uni.navigateBack(2)
},
radioChange(e) {
},
// 选中任一radio时,由radio-group触发
radioGroupChange(e) {
},
change(status) {
},
},
computed: {
i18n() {
return this.$t('index')
},
},
onLoad() {
if (uni.getStorageSync('lang')) {
this.value = uni.getStorageSync('lang')
} else {
uni.setStorageSync('lang', this.value)
}
}
};
</script>
<style scoped>
page {
background: #FAFAFA;
}
</style>
<style>
@import './index.css';
</style>