diff --git a/common/js/lang.js b/common/js/lang.js index 5fec1bf..c8ca741 100644 --- a/common/js/lang.js +++ b/common/js/lang.js @@ -66,15 +66,16 @@ export default { const locale = uni.getStorageSync('lang') || "zh-cn"; //设置语言 - var value = ''; + let value = ''; // 存放解析后的语言值 + let langPath = ''; // 存放当前页面语言包路径 + try { //公共语言包(同步加载) var lang = loadLangPackSync(locale, 'common'); //当前页面语言包(同步加载) let route = _this.route; - let langPath = processRoutePath(route); - console.log(`当前语言: ${locale}, 当前页面语言包路径: ${langPath}`); + langPath = processRoutePath(route); // 加载当前页面语言包 let currentPageLang = loadLangPackSync(locale, langPath); @@ -102,7 +103,7 @@ export default { } } catch (e) { - console.error('解析语言包失败:', e); + console.error('解析语言包失败:', e, { langPath, field, locale }); value = field; } @@ -115,7 +116,10 @@ export default { if (value == undefined || (value == 'title' && field == 'title')) value = ''; // field // 多语言调试,注释后可以关闭控制台输出 - console.log(`字段: ${field}, 值: ${value}`) + if (field == value) { + console.warn(`警告: 字段 ${field} 在语言包 ${langPath} 中未找到对应值,使用默认值 ${field} 当前语言: ${locale}`); + } + return value; }, /** diff --git a/common/js/util.js b/common/js/util.js index 27d3725..7b21f81 100644 --- a/common/js/util.js +++ b/common/js/util.js @@ -7,15 +7,18 @@ import { -// 首页路径 +// 关于页面路径,使用常量导出 export const INDEX_PAGE_URL = '/pages/index/index'; +export const CATEGORY_PAGE_URL = '/pages_goods/category'; +export const CONTACT_PAGE_URL = '/pages_tool/contact/contact'; +export const MEMBER_PAGE_URL = '/pages_tool/member/index'; // 当前最新的tabBar.list (参见pages.json 中的tabBar.list 配置) export const systemTabBarList = [ INDEX_PAGE_URL, - '/pages_goods/category', - '/pages_tool/contact/contact', - '/pages_tool/member/index' + CATEGORY_PAGE_URL, + CONTACT_PAGE_URL, + MEMBER_PAGE_URL ]; /** @@ -109,6 +112,12 @@ export const checkTabBarActive = (linkUrl, currentPageRoute) => { } export default { + /** 导出页面URL常量 */ + MEMBER_PAGE_URL, + CATEGORY_PAGE_URL, + CONTACT_PAGE_URL, + INDEX_PAGE_URL, + /** * 页面跳转 * @param {string} to 跳转链接 /pages/idnex/index @@ -592,6 +601,9 @@ export default { } return cloneObj }, + + + /** * 自定义模板的跳转链接 * @param {Object} link diff --git a/components-diy/diy-digit.vue b/components-diy/diy-digit.vue index 83cdf74..de1f43d 100644 --- a/components-diy/diy-digit.vue +++ b/components-diy/diy-digit.vue @@ -90,7 +90,7 @@ export default { // 页面跳转 redirectTo(item) { - if (!item.wap_url || this.$util.getCurrRoute() != 'pages/member/index' || this.storeToken) { + if (!item.wap_url || this.$util.getCurrRoute() != this.$util.MEMBER_PAGE_URL || this.storeToken) { console.log(item); this.$util.diyRedirectTo(item); } else { diff --git a/components-diy/diy-graphic-nav.vue b/components-diy/diy-graphic-nav.vue index d645bb3..644b1d1 100644 --- a/components-diy/diy-graphic-nav.vue +++ b/components-diy/diy-graphic-nav.vue @@ -159,7 +159,7 @@ export default { redirectTo(link) { if (link.wap_url) { - if (this.$util.getCurrRoute() == 'pages/member/index' && !this.storeToken) { + if (this.$util.getCurrRoute() == this.$util.MEMBER_PAGE_URL && !this.storeToken) { this.$refs.login.open(link.wap_url); return; } diff --git a/components-diy/diy-image-nav.vue b/components-diy/diy-image-nav.vue index 8615a21..17b4fb9 100644 --- a/components-diy/diy-image-nav.vue +++ b/components-diy/diy-image-nav.vue @@ -116,7 +116,7 @@ export default { // 页面跳转 redirectTo(link) { - if (!link.wap_url || this.$util.getCurrRoute() != 'pages/member/index' || this.storeToken) { + if (!link.wap_url || this.$util.getCurrRoute() != this.$util.MEMBER_PAGE_URL || this.storeToken) { this.$util.diyRedirectTo(link); } else { this.$refs.login.open(link.wap_url); diff --git a/components-diy/diy-listmenu.vue b/components-diy/diy-listmenu.vue index f07440a..eb2d6a0 100644 --- a/components-diy/diy-listmenu.vue +++ b/components-diy/diy-listmenu.vue @@ -62,8 +62,8 @@ export default { methods: { redirectTo(link) { if (link.wap_url) { - if (this.$util.getCurrRoute() == 'pages/member/index' && !this.storeToken) { - this.$refs.login.open(link.wap_url); + if (this.$util.getCurrRoute() == this.$util.MEMBER_PAGE_URL && !this.storeToken) { + this.$refs?.login?.open(link.wap_url); return; } } diff --git a/components-diy/diy-member-info.vue b/components-diy/diy-member-info.vue index 37afec7..fea7e80 100644 --- a/components-diy/diy-member-info.vue +++ b/components-diy/diy-member-info.vue @@ -64,7 +64,7 @@ @click.stop="modifyInfo()">{{ langIndex == 0 ? 'CN' : 'EN' }} - + @@ -545,7 +545,7 @@ export default { */ redirectBeforeAuth(url) { if (!this.storeToken) { - this.$refs.login.open('/pages/member/index'); + this.$refs.login.open(this.$util.MEMBER_PAGE_URL); return; } @@ -583,7 +583,7 @@ export default { url: '/wechat/api/wechat/authcode', data: { scopes: 'snsapi_userinfo', - redirect_url: this.$config.h5Domain + '/pages/member/index' + redirect_url: this.$config.h5Domain + this.$util.MEMBER_PAGE_URL }, success: res => { if (res.code >= 0) { diff --git a/components-diy/diy-picture.vue b/components-diy/diy-picture.vue index 1f86e63..c17b371 100644 --- a/components-diy/diy-picture.vue +++ b/components-diy/diy-picture.vue @@ -65,7 +65,7 @@ export default { }, redirectTo(link) { if (link.wap_url) { - if (this.$util.getCurrRoute() == 'pages/member/index' && !this.storeToken) { + if (this.$util.getCurrRoute() == this.$util.MEMBER_PAGE_URL && !this.storeToken) { this.$refs.login.open(link.wap_url); return; } diff --git a/components-diy/diy-quick-nav.vue b/components-diy/diy-quick-nav.vue index 401efb7..d32b698 100644 --- a/components-diy/diy-quick-nav.vue +++ b/components-diy/diy-quick-nav.vue @@ -61,7 +61,7 @@ export default { methods: { redirectTo(link) { if (link.wap_url) { - if (this.$util.getCurrRoute() == 'pages/member/index' && !this.storeToken) { + if (this.$util.getCurrRoute() == this.$util.MEMBER_PAGE_URL && !this.storeToken) { this.$refs.login.open(link.wap_url); return; } diff --git a/components-diy/diy-search.vue b/components-diy/diy-search.vue index a74830b..1505d85 100644 --- a/components-diy/diy-search.vue +++ b/components-diy/diy-search.vue @@ -198,7 +198,7 @@ export default { }, redirectTo(link) { if (link.wap_url) { - if (this.$util.getCurrRoute() == 'pages/member/index' && !this.storeToken) { + if (this.$util.getCurrRoute() == this.$util.MEMBER_PAGE_URL && !this.storeToken) { this.$refs.login.open(link.wap_url); return; } diff --git a/components/ns-login/ns-login.vue b/components/ns-login/ns-login.vue index f246c57..0716ab8 100644 --- a/components/ns-login/ns-login.vue +++ b/components/ns-login/ns-login.vue @@ -42,26 +42,22 @@ - + @click="isAgree = !isAgree"> 我同意 - 《隐私条款》 - 《用户服务协议》 + 《隐私条款》 + 《用户服务协议》 - @@ -71,7 +67,8 @@ - + 暂不登录 @@ -118,8 +115,8 @@ 获取手机号 - - + + @@ -226,7 +223,7 @@ export default { if (siteInfo) { this.site_name = siteInfo.site_name; } - }, + }, methods: { // 同意协议 authno() { @@ -254,7 +251,7 @@ export default { }, // 打开弹窗 - open(url, mode) { + open(url = '', mode = 'navigateTo') { if (url) this.url = url; // #ifdef MP this.getCode(authData => { @@ -266,8 +263,13 @@ export default { if (this.$util.isWeChatMiniProgram()) { // 微信小程序环境,使用微信授权登录 let authData = uni.getStorageSync('authInfo'); - if (authData) this.authLogin(authData); - else this.getCode(); + if (authData) { + this.authLogin(authData); + } else { + this.getCode(authData => { + this.authLogin(authData, 'authOnlyLogin'); + }); + } } else if (this.$util.isWeiXin()) { // 微信浏览器环境,显示登录页面 this.toLogin(mode); @@ -283,7 +285,7 @@ export default { }, // 跳转去登录页 - toLogin(mode) { + toLogin(mode = 'navigateTo') { if (this.url) this.$util.redirectTo('/pages_tool/login/login', { back: encodeURIComponent(this.url) }, mode); @@ -535,7 +537,8 @@ export default { getPhoneNumber(e) { if (e.detail.errMsg === 'getPhoneNumber:ok') { const authInfo = uni.getStorageSync('authInfo'); - if (authInfo) { Object.assign(this.authMobileData, authInfo, e.detail); + if (authInfo) { + Object.assign(this.authMobileData, authInfo, e.detail); } if (uni.getStorageSync('source_member')) { this.authMobileData.source_member = uni.getStorageSync('source_member'); @@ -596,7 +599,7 @@ export default { } }); }, - + // 授权登录 authLogin(data, type = 'authLogin') { uni.showLoading({ @@ -686,8 +689,8 @@ export default { if (this.forceBindingMobileControl) { this.bindMobile(); - } else { - this.authLogin(authInfo); + } else { + this.authLogin(authInfo); } }, @@ -749,7 +752,7 @@ export default { // 跳转页面 tourl(url) { this.$util.redirectTo(url); - } + } } }; diff --git a/pages_promotion/fenxiao/apply.vue b/pages_promotion/fenxiao/apply.vue index ef3e730..33b8ebd 100644 --- a/pages_promotion/fenxiao/apply.vue +++ b/pages_promotion/fenxiao/apply.vue @@ -261,7 +261,7 @@ this.status = res.data.status; this.isSub = false; if (this.status == 2) { - this.$util.redirectTo('/pages/member/index'); + this.$util.redirectTo(this.$util.MEMBER_PAGE_URL); } } this.$refs.loadingCover.hide(); @@ -410,7 +410,7 @@ if (options.from === 'navigateBack') { return false; } - this.$util.redirectTo('/pages/member/index'); + this.$util.redirectTo(this.$util.MEMBER_PAGE_URL); return true; } }; diff --git a/pages_promotion/fenxiao/index.vue b/pages_promotion/fenxiao/index.vue index 178e244..628158e 100644 --- a/pages_promotion/fenxiao/index.vue +++ b/pages_promotion/fenxiao/index.vue @@ -348,7 +348,7 @@ export default { duration: 2000 }); setTimeout(() => { - this.$util.redirectTo('/pages/member/index'); + this.$util.redirectTo(this.$util.MEMBER_PAGE_URL); }, 2000); } } @@ -367,7 +367,7 @@ export default { title: '当前分销商已冻结' }); setTimeout(() => { - this.$util.redirectTo('/pages/member/index'); + this.$util.redirectTo(this.$util.MEMBER_PAGE_URL); }, 2000); return; } @@ -457,7 +457,7 @@ export default { if (options.from === 'navigateBack') { return false; } - this.$util.redirectTo('/pages/member/index', {}, 'reLaunch'); + this.$util.redirectTo(this.$util.MEMBER_PAGE_URL, {}, 'reLaunch'); return true; }, watch: { diff --git a/pages_tool/login/login.vue b/pages_tool/login/login.vue index 72e0bbe..a064dbe 100644 --- a/pages_tool/login/login.vue +++ b/pages_tool/login/login.vue @@ -234,13 +234,13 @@ export default { this.$util.showToast({ title: this.$lang('loginSuccessTip') }); - let back = this.back ? this.back : '/pages/member/index'; + let back = this.back ? this.back : this.$util.MEMBER_PAGE_URL; if (this.$refs.registerReward) this.$refs.registerReward.open(back); } else { if (this.back != '') { this.$util.redirectTo(decodeURIComponent(this.back), {}, 'reLaunch'); } else { - this.$util.redirectTo('/pages/member/index', {}, 'reLaunch'); + this.$util.redirectTo(this.$util.MEMBER_PAGE_URL, {}, 'reLaunch'); } } }); @@ -348,13 +348,13 @@ export default { this.$store.dispatch('getCartNumber'); this.getMemberInfo(() => { if (can_receive_registergift == 1) { - let back = this.back ? this.back : '/pages/member/index'; + let back = this.back ? this.back : this.$util.MEMBER_PAGE_URL; if (this.$refs.registerReward) this.$refs.registerReward.open(back); } else { if (this.back != '') { this.$util.redirectTo(decodeURIComponent(this.back), {}, this.redirect); } else { - this.$util.redirectTo('/pages/member/index', {}, this.redirect); + this.$util.redirectTo(this.$util.MEMBER_PAGE_URL, {}, this.redirect); } } }) diff --git a/pages_tool/member/apply_withdrawal.vue b/pages_tool/member/apply_withdrawal.vue index d258e4f..be31103 100644 --- a/pages_tool/member/apply_withdrawal.vue +++ b/pages_tool/member/apply_withdrawal.vue @@ -109,7 +109,7 @@ title: '未开启提现' }); setTimeout(() => { - this.$util.redirectTo('/pages/member/index'); + this.$util.redirectTo(this.$util.MEMBER_PAGE_URL); }, 1500); } } diff --git a/pages_tool/member/balance.vue b/pages_tool/member/balance.vue index 356e063..fa528b7 100644 --- a/pages_tool/member/balance.vue +++ b/pages_tool/member/balance.vue @@ -6,7 +6,7 @@ 'height': menuButtonBounding.height + 'px' }"> - + 账户余额 @@ -171,7 +171,7 @@ export default { if (options.from === 'navigateBack') { return false; } - this.$util.redirectTo('/pages/member/index', {}, 'reLaunch'); + this.$util.redirectTo(this.$util.MEMBER_PAGE_URL, {}, 'reLaunch'); return true; }, watch: { diff --git a/pages_tool/member/cancelrefuse.vue b/pages_tool/member/cancelrefuse.vue index eabb02a..51cc945 100644 --- a/pages_tool/member/cancelrefuse.vue +++ b/pages_tool/member/cancelrefuse.vue @@ -43,7 +43,7 @@ export default { }); }, toIndex() { - this.$util.redirectTo('/pages/member/index'); + this.$util.redirectTo(this.$util.MEMBER_PAGE_URL); }, apply() { this.$util.redirectTo('/pages_tool/member/cancellation'); diff --git a/pages_tool/member/cancelstatus.vue b/pages_tool/member/cancelstatus.vue index a33ecf0..c0675b8 100644 --- a/pages_tool/member/cancelstatus.vue +++ b/pages_tool/member/cancelstatus.vue @@ -77,7 +77,7 @@ }); }, back() { - this.$util.redirectTo('/pages/member/index'); + this.$util.redirectTo(this.$util.MEMBER_PAGE_URL); }, revoke() { uni.showModal({ @@ -90,7 +90,7 @@ url: '/membercancel/api/membercancel/cancelApply', success: res => { if (res.code >= 0) { - this.$util.redirectTo('/pages/member/index'); + this.$util.redirectTo(this.$util.MEMBER_PAGE_URL); } } }); diff --git a/pages_tool/member/card.vue b/pages_tool/member/card.vue index 0096af2..6f8a1de 100644 --- a/pages_tool/member/card.vue +++ b/pages_tool/member/card.vue @@ -183,7 +183,7 @@ export default { if (options.from === 'navigateBack') { return false; } - this.$util.redirectTo('/pages/member/index'); + this.$util.redirectTo(this.$util.MEMBER_PAGE_URL); return true; } }; @@ -220,7 +220,7 @@ export default { } -