mirror of
https://gitee.com/zongzhige/shopxo-uniapp.git
synced 2026-06-05 18:25:48 +08:00
多语言,app权限处理
This commit is contained in:
30
App.vue
30
App.vue
@ -47,6 +47,14 @@
|
||||
// 1.新增一个对象,按照当前格式新增
|
||||
// 2.去lang里面各个文件去新增语言翻译
|
||||
default_language: 'zh',
|
||||
// 默认语言对照表
|
||||
default_language_list: {
|
||||
'zh-Hans': 'zh',
|
||||
'zh-Hant': 'cht',
|
||||
'en-US': 'en',
|
||||
'es': 'spa',
|
||||
'fra': 'fr',
|
||||
},
|
||||
|
||||
// 系统tabbar
|
||||
system_tabbar: [
|
||||
@ -3021,14 +3029,8 @@
|
||||
// 当前系统语言、默认中文
|
||||
let value = uni.getLocale() || this.data.default_language;
|
||||
// 语言标识转换和后端一致
|
||||
let arr = {
|
||||
'zh-Hans': 'zh',
|
||||
'zh-Hant': 'cht',
|
||||
'en-US': 'en',
|
||||
'es': 'spa',
|
||||
'fra': 'fr',
|
||||
};
|
||||
return ((arr[value] || null) == null) ? value : arr[value];
|
||||
let list = this.data.default_language_list;
|
||||
return ((list[value] || null) == null) ? value : list[value];
|
||||
},
|
||||
|
||||
// 选择用户地理位置
|
||||
@ -3331,8 +3333,16 @@
|
||||
|
||||
// 指定多语言设置
|
||||
if((temp_params.lang || null) != null) {
|
||||
uni.setLocale(temp_params.lang);
|
||||
i18n.locale = temp_params.lang;
|
||||
let lang = temp_params.lang;
|
||||
let list = this.globalData.data.default_language_list;
|
||||
if((list[lang] || null) == null) {
|
||||
list = Object.fromEntries(Object.entries(list).map(([key, value]) => [value, key]));
|
||||
if((list[lang] || null) != null) {
|
||||
lang = list[lang];
|
||||
}
|
||||
}
|
||||
uni.setLocale(lang);
|
||||
i18n.locale = lang;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
<view class="padding-top-xxxl padding-bottom-xxxl tc cr-red">{{ $t('goods-buy.goods-buy.ufdm25') }}</view>
|
||||
</block>
|
||||
<block v-else>
|
||||
<view class="goods-spec-choice-content">
|
||||
<scroll-view :scroll-y="true" class="goods-spec-choice-content">
|
||||
<!-- 商品规格 -->
|
||||
<view v-if="goods_spec_choose.length > 0" class="goods-spec-choose">
|
||||
<view v-for="(item, key) in goods_spec_choose" :key="key" class="item padding-top-xxl padding-bottom-xxl">
|
||||
@ -54,7 +54,7 @@
|
||||
<view @tap="goods_buy_number_event" class="number-submit tc cr-grey fl va-m" data-type="1">+</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
<view v-if="(opt_button || null) != null && opt_button.length > 0" class="padding-bottom-main">
|
||||
<view :class="'flex-row jc-sa gap-20 buy-nav-btn-number-' + (opt_button.length || 0)">
|
||||
<block v-for="(item, index) in opt_button" :key="index">
|
||||
@ -918,8 +918,6 @@
|
||||
}
|
||||
.goods-spec-choice-content {
|
||||
max-height: 50vh;
|
||||
overflow-y: scroll;
|
||||
overflow-x: hidden;
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
.goods-spec-choice-container .item .spec .spec-btn {
|
||||
|
||||
@ -90,9 +90,16 @@
|
||||
this.$emit('popup_sub_language_event', language_list[this.language_key]);
|
||||
},
|
||||
// 多语言切换
|
||||
language_change(key) {
|
||||
uni.setLocale(key);
|
||||
this.$i18n.locale = key;
|
||||
language_change(lang) {
|
||||
let list = app.globalData.data.default_language_list;
|
||||
if((list[lang] || null) == null) {
|
||||
list = Object.fromEntries(Object.entries(list).map(([key, value]) => [value, key]));
|
||||
if((list[lang] || null) != null) {
|
||||
lang = list[lang];
|
||||
}
|
||||
}
|
||||
uni.setLocale(lang);
|
||||
this.$i18n.locale = lang;
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
@ -57,6 +57,8 @@
|
||||
"<uses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\"/>",
|
||||
"<uses-permission android:name=\"android.permission.RECORD_AUDIO\"/>",
|
||||
"<uses-permission android:name=\"android.permission.RECEIVE_BOOT_COMPLETED\"/>",
|
||||
"<uses-permission android:name=\"android.permission.ACTION_BOOT_COMPLETED\"/>",
|
||||
"<uses-permission android:name=\"android.permission.BOOT_COMPLETED\"/>",
|
||||
"<uses-permission android:name=\"android.permission.RECEIVE_COMPLETED\"/>"
|
||||
],
|
||||
"permissionPhoneState" : {
|
||||
|
||||
Reference in New Issue
Block a user