diff --git a/components/hover-nav/hover-nav.vue b/components/hover-nav/hover-nav.vue index d93bb08..2a064fc 100644 --- a/components/hover-nav/hover-nav.vue +++ b/components/hover-nav/hover-nav.vue @@ -185,12 +185,29 @@ export default { uni.showToast({ title: '暂无联系电话', icon: 'none' }); } }, - toggleLanguage() { - this.currentLangIndex = this.currentLangIndex === 0 ? 1 : 0; - const targetLang = this.langIndexMap[this.currentLangIndex]; - let currentRoute = this.$util.getCurrentRoute().path; - this.$langConfig.change(targetLang, currentRoute); - }, + /** + * 切换中英文语言,并刷新当前页面(保留所有参数) + */ + toggleLanguage() { + this.currentLangIndex = this.currentLangIndex === 0 ? 1 : 0; + const targetLang = this.langIndexMap[this.currentLangIndex]; + + uni.setStorageSync('lang', targetLang); + + const pages = getCurrentPages(); + if (pages.length === 0) return; + + const currentPage = pages[pages.length - 1]; + const route = currentPage.route; + + console.log('【调试】切换语言:', targetLang, '路径:', route); + + if (uni.getSystemInfoSync().platform === 'browser') { + window.location.reload(); + } else { + uni.redirectTo({ url: `/${route}` }); + } + }, openKefuSelectPopup() { const kefuNames = this.kefuList.map(item => item.name); uni.showActionSheet({