chore: 使用常量来处理会员中心的路由页面路径判断

This commit is contained in:
2026-01-07 15:09:49 +08:00
parent 6956841c8b
commit b10fcf02d4
27 changed files with 93 additions and 74 deletions

View File

@@ -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;
},
/**

View File

@@ -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

View File

@@ -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 {

View File

@@ -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;
}

View File

@@ -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);

View File

@@ -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;
}
}

View File

@@ -64,7 +64,7 @@
@click.stop="modifyInfo()">{{ langIndex == 0 ? 'CN' : 'EN' }}</view>
</view>
<view class="info-wrap" v-else :style="infoStyle" @click="redirect('/pages/member/index')">
<view class="info-wrap" v-else :style="infoStyle" @click="redirect($util.MEMBER_PAGE_URL)">
<view class="headimg">
<image :src="$util.getDefaultImage().head" mode="widthFix"></image>
</view>
@@ -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) {

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -42,26 +42,22 @@
<!-- 协议勾选 -->
<view style="display: flex;">
<view
class="iconfont"
<view class="iconfont"
:class="isAgree ? 'icon-fuxuankuang1 color-base-text' : 'icon-fuxuankuang2'"
@click="isAgree = !isAgree"
></view>
@click="isAgree = !isAgree"></view>
<view style="text-align: left; margin-left: 10rpx; padding-top: 2rpx; font-size: 28rpx;">
我同意
<text style="color: #4395ff;" @click="tourl('/pages_tool/agreement/contenr?type=0')">隐私条款</text>
<text style="color: #4395ff;" @click="tourl('/pages_tool/agreement/contenr?type=1')">用户服务协议</text>
<text style="color: #4395ff;"
@click="tourl('/pages_tool/agreement/contenr?type=0')">隐私条款</text>
<text style="color: #4395ff;"
@click="tourl('/pages_tool/agreement/contenr?type=1')">用户服务协议</text>
</view>
</view>
<!-- 手机号授权按钮 -->
<block v-if="isAgree">
<button
class="auth-login save-btn border-0"
style="border: none;"
open-type="getPhoneNumber"
@getphonenumber="getPhoneNumber"
>
<button class="auth-login save-btn border-0" style="border: none;" open-type="getPhoneNumber"
@getphonenumber="getPhoneNumber">
<text style="color: #fff; font-size: 30rpx;">同意隐私协议并授权手机号</text>
</button>
</block>
@@ -71,7 +67,8 @@
</button>
</block>
<view @click="closeLogin" style="font-size: 30rpx; color: #888; text-align: center; padding-top: 10rpx;">
<view @click="closeLogin"
style="font-size: 30rpx; color: #888; text-align: center; padding-top: 10rpx;">
暂不登录
</view>
@@ -118,8 +115,8 @@
<text class="color-base-text" v-else>获取手机号</text>
</button>
</view>
<button type="default" class="save-btn" @click="saveMp" :disabled="isDisabled">保存</button>
</template>
<button type="default" class="save-btn" @click="saveMp" :disabled="isDisabled">保存</button>
</template>
<!-- #endif -->
</view>
</uni-popup>
@@ -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);
}
}
}
};
</script>

View File

@@ -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;
}
};

View File

@@ -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: {

View File

@@ -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);
}
}
})

View File

@@ -109,7 +109,7 @@
title: '未开启提现'
});
setTimeout(() => {
this.$util.redirectTo('/pages/member/index');
this.$util.redirectTo(this.$util.MEMBER_PAGE_URL);
}, 1500);
}
}

View File

@@ -6,7 +6,7 @@
'height': menuButtonBounding.height + 'px'
}">
<view class="navbar-wrap">
<text class="iconfont icon-back_light back" @click="$util.redirectTo('/pages/member/index')"></text>
<text class="iconfont icon-back_light back" @click="$util.redirectTo($util.MEMBER_PAGE_URL)"></text>
<view class="navbar-title">
账户余额
</view>
@@ -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: {

View File

@@ -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');

View File

@@ -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);
}
}
});

View File

@@ -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 {
}
</style>
<style scoped>
<style lang="scss" scoped>
/deep/ .sku-layer .uni-popup__wrapper.uni-custom .uni-popup__wrapper-box {
max-height: unset !important;
}

View File

@@ -418,7 +418,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;
}
};

View File

@@ -96,7 +96,7 @@ export default {
this.$store.commit('setMemberInfo', '');
this.$store.dispatch('emptyCart');
uni.removeStorageSync('authInfo');
this.$util.redirectTo('/pages/member/index');
this.$util.redirectTo(this.$util.MEMBER_PAGE_URL);
}
}
});
@@ -118,7 +118,7 @@ export default {
this.$store.commit('setMemberInfo', '');
this.$store.dispatch('emptyCart');
uni.removeStorageSync('authInfo');
this.$util.redirectTo('/pages/member/index');
this.$util.redirectTo(this.$util.MEMBER_PAGE_URL);
} else {
this.$util.showToast({
title: rres.message

View File

@@ -354,7 +354,7 @@
if (options.from === 'navigateBack') {
return false;
}
this.$util.redirectTo('/pages/member/index');
this.$util.redirectTo(this.$util.MEMBER_PAGE_URL);
return true;
},
watch: {

View File

@@ -54,7 +54,7 @@
}, 'redirectTo');
} else {
if (this.back) this.$util.redirectTo(this.back);
else this.$util.redirectTo('/pages/member/index');
else this.$util.redirectTo(this.$util.MEMBER_PAGE_URL);
}
}
});
@@ -133,7 +133,7 @@
setTimeout(() => {
if (this.back) this.$util.redirectTo(this.back, {},
'redirectTo');
else this.$util.redirectTo('/pages/member/index');
else this.$util.redirectTo(this.$util.MEMBER_PAGE_URL);
}, 2000);
} else {
this.initInfo();

View File

@@ -7,7 +7,7 @@
}"
>
<view class="navbar-wrap">
<text class="iconfont icon-back_light back" @click="$util.redirectTo('/pages/member/index')"></text>
<text class="iconfont icon-back_light back" @click="$util.redirectTo($util.MEMBER_PAGE_URL)"></text>
<view class="navbar-title">
我的积分
</view>
@@ -143,7 +143,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: {

View File

@@ -256,7 +256,7 @@ export default {
this.$store.dispatch('emptyCart');
this.$store.dispatch('emptyCart');
uni.removeStorageSync('authInfo');
this.$util.redirectTo('/pages/member/index');
this.$util.redirectTo(this.$util.MEMBER_PAGE_URL);
} else {
this.$util.showToast({
title: rres.message
@@ -329,7 +329,7 @@ export default {
this.$store.dispatch('emptyCart');
this.$store.dispatch('emptyCart');
uni.removeStorageSync('authInfo');
this.$util.redirectTo('/pages/member/index');
this.$util.redirectTo(this.$util.MEMBER_PAGE_URL);
}
}
});

View File

@@ -106,7 +106,7 @@ export default {
if (this.back != '') {
this.$util.redirectTo(this.back, {}, this.redirect);
} else {
this.$util.redirectTo('/pages/member/index');
this.$util.redirectTo(this.$util.MEMBER_PAGE_URL);
}
},
//获取rule

View File

@@ -91,7 +91,7 @@
this.$util.redirectTo('/pages_tool/member/coupon', {});
break;
default:
this.$util.redirectTo('/pages/member/index', {}, 'reLaunch');
this.$util.redirectTo(this.$util.MEMBER_PAGE_URL, {}, 'reLaunch');
break;
}
},