diff --git a/common/js/golbalConfig.js b/common/js/golbalConfig.js index d412a07..c38a69f 100644 --- a/common/js/golbalConfig.js +++ b/common/js/golbalConfig.js @@ -7,7 +7,7 @@ export default { computed: { // 是否是英文环境 isEnEnv() { - return uni.getStorageSync('lang') === 'en-us'; + return this.$langConfig.getCurrentLocale() === 'en-us'; }, themeStyle() { return this.$store.state.themeStyle; diff --git a/common/js/lang.js b/common/js/lang.js index c8ca741..e62032a 100644 --- a/common/js/lang.js +++ b/common/js/lang.js @@ -56,15 +56,24 @@ function loadLangPackSync(lang, path) { export default { langList: langConfig.langList, + + /** + * 获得当前本地语言 + * @returns + */ + getCurrentLocale() { + return uni.getStorageSync('lang') || "zh-cn"; + }, + /** * * 解析多语言 * @param {Object} field */ lang(field) { - let _this = getCurrentPages()[getCurrentPages().length - 1]; - if (!_this) return; + let _page = getCurrentPages()[getCurrentPages().length - 1]; + if (!_page) return; - const locale = uni.getStorageSync('lang') || "zh-cn"; //设置语言 + const locale = this.getCurrentLocale(); // 获得当前本地语言 let value = ''; // 存放解析后的语言值 let langPath = ''; // 存放当前页面语言包路径 @@ -74,7 +83,7 @@ export default { var lang = loadLangPackSync(locale, 'common'); //当前页面语言包(同步加载) - let route = _this.route; + let route = _page.route; langPath = processRoutePath(route); // 加载当前页面语言包 @@ -128,11 +137,11 @@ export default { * @param {String} url 切换后跳转的页面url */ change(value, url = '/pages_tool/member/index') { - let _this = getCurrentPages()[getCurrentPages().length - 1]; - if (!_this) return; + let _page = getCurrentPages()[getCurrentPages().length - 1]; + if (!_page) return; uni.setStorageSync("lang", value); - const locale = uni.getStorageSync('lang') || "zh-cn"; //设置语言 + const locale = this.getCurrentLocale(); // 清空已加载的语言包缓存 for (let key in loadedLangPacks) { @@ -149,9 +158,10 @@ export default { }, //刷新标题、tabbar refresh() { - let _this = getCurrentPages()[getCurrentPages().length - 1]; - if (!_this) return; - const locale = uni.getStorageSync('lang') || "zh-cn"; //设置语言 + let _page = getCurrentPages()[getCurrentPages().length - 1]; + if (!_page) return; + + const locale = this.getCurrentLocale(); this.title(this.lang("title")); diff --git a/components-diy/diy-group.vue b/components-diy/diy-group.vue index 6de5241..8149d33 100644 --- a/components-diy/diy-group.vue +++ b/components-diy/diy-group.vue @@ -251,6 +251,11 @@ + +