fix: 统一登录跳转逻辑,添加redirectTo参数避免页面栈溢出

1. 为所有登录跳转调用添加redirectTo跳转类型参数
2. 调整部分页面的onShow生命周期执行顺序和定时器包装
3. 补充缺失的ns-login组件引用到两个diy组件中
4. 修复部分页面登录后返回出现循环跳转的问题
This commit is contained in:
2026-06-27 15:08:01 +08:00
parent 95194585d2
commit aee630b546
36 changed files with 81 additions and 75 deletions

View File

@@ -15,6 +15,7 @@
<view class="fui-cell-remark" style="font-size: 24rpx;">{{ lang == 'en-us' ? 'view' : '查看' }}</view> <view class="fui-cell-remark" style="font-size: 24rpx;">{{ lang == 'en-us' ? 'view' : '查看' }}</view>
</view> </view>
</view> </view>
<ns-login ref="login"></ns-login>
</view> </view>
</template> </template>

View File

@@ -11,6 +11,7 @@
<image mode="widthFix" src="{{childitem.imgurl}}" style="{{bannerheight?'height:'+bannerheight+'px':'height:auto'}}"></image> <image mode="widthFix" src="{{childitem.imgurl}}" style="{{bannerheight?'height:'+bannerheight+'px':'height:auto'}}"></image>
</view> --> </view> -->
</view> </view>
<ns-login ref="login"></ns-login>
</view> </view>
</template> </template>

View File

@@ -262,9 +262,9 @@ export default {
return this.whetherCollection; return this.whetherCollection;
} else { } else {
if (this.source_member) { if (this.source_member) {
this.$refs.login.open(this.shareUrl + '&source_member=' + this.source_member); this.$refs.login.open(this.shareUrl + '&source_member=' + this.source_member, 'redirectTo');
} else { } else {
this.$refs.login.open(this.shareUrl); this.$refs.login.open(this.shareUrl, 'redirectTo');
} }
} }
}, },

View File

@@ -83,7 +83,7 @@ export default {
}); });
}, },
toLogin() { toLogin() {
this.$refs.login.open('/pages_goods/category') this.$refs.login.open('/pages_goods/category', 'redirectTo');
} }
}, },
onPullDownRefresh() { onPullDownRefresh() {

View File

@@ -260,7 +260,7 @@ export default {
// 加入购物车 // 加入购物车
joinCart() { joinCart() {
if (!this.storeToken && this.preview == 0) { if (!this.storeToken && this.preview == 0) {
this.$refs.login.open(this.shareUrl); this.$refs.login.open(this.shareUrl, 'redirectTo');
return; return;
} }
if (this.goodsSkuDetail.is_virtual == 1) { if (this.goodsSkuDetail.is_virtual == 1) {
@@ -276,7 +276,7 @@ export default {
// 立即购买 // 立即购买
buyNow() { buyNow() {
if (!this.storeToken && this.preview == 0) { if (!this.storeToken && this.preview == 0) {
this.$refs.login.open(this.shareUrl); this.$refs.login.open(this.shareUrl, 'redirectTo');
return; return;
} }
this.$refs.goodsSku.show("buy_now", () => { this.$refs.goodsSku.show("buy_now", () => {
@@ -352,7 +352,7 @@ export default {
}, },
}); });
} else { } else {
this.$refs.login.open(this.shareUrl); this.$refs.login.open(this.shareUrl, 'redirectTo');
this.couponBtnSwitch = false; this.couponBtnSwitch = false;
} }
}, },

View File

@@ -76,7 +76,7 @@ export default {
} else { } else {
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.loadingCover.hide(); this.$refs.loadingCover.hide();
this.$refs.login.open(this.$util.getCurrentRoute().path) this.$refs.login.open(this.$util.getCurrentRoute().path, 'redirectTo');
}) })
} }
this.getTransactionAgreement(); this.getTransactionAgreement();

View File

@@ -66,7 +66,7 @@ export default {
if (!this.storeToken) { if (!this.storeToken) {
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.login.open('/pages_promotion/fenxiao/childfenxiao'); this.$refs.login.open('/pages_promotion/fenxiao/childfenxiao', 'redirectTo');
}); });
} }
}, },

View File

@@ -18,8 +18,8 @@
:src="$util.img('public/uniapp/fenxiao/index/commissionFission-level.png')" :src="$util.img('public/uniapp/fenxiao/index/commissionFission-level.png')"
alt="" class="level-icon">{{ info.level_name }}</p> alt="" class="level-icon">{{ info.level_name }}</p>
</view> </view>
<view class="recommend">{{ $lang('superiorAgent') }}:{{ info.parent_name ? info.parent_name : $lang('headquarters') }}</view> <view class="recommend">{{ $lang('superiorAgent') }}:{{ info.parent_name ? info.parent_name : $lang('headquarters') }}</view>
<view class="recommend">{{ $lang('invitedSuccess', { count: teamNum.num }) }}<text class="iconfont icon-right" <view class="recommend">{{ $lang('invitedSuccess', { count: teamNum.num }) }}<text class="iconfont icon-right"
style="font-size: 24rpx;"></text></view> style="font-size: 24rpx;"></text></view>
</view> </view>
<!-- <view class="promote-rules font-size-tag" @click="$util.redirectTo('/pages_promotion/fenxiao/promote')"> <!-- <view class="promote-rules font-size-tag" @click="$util.redirectTo('/pages_promotion/fenxiao/promote')">
@@ -296,7 +296,7 @@ export default {
this.checkFenxiaoIsStart(); this.checkFenxiaoIsStart();
} else { } else {
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.login.open('/pages_promotion/fenxiao/index'); this.$refs.login.open('/pages_promotion/fenxiao/index', 'redirectTo');
}); });
} }

View File

@@ -156,7 +156,7 @@ export default {
if (!this.storeToken) { if (!this.storeToken) {
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.login.open('/pages_promotion/fenxiao/order'); this.$refs.login.open('/pages_promotion/fenxiao/order', 'redirectTo');
}); });
} }
}, },

View File

@@ -116,7 +116,7 @@ export default {
this.getOrderData(); this.getOrderData();
} else { } else {
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.login.open('/pages_promotion/fenxiao/order_detail?id=' + this.orderId); this.$refs.login.open('/pages_promotion/fenxiao/order_detail?id=' + this.orderId, 'redirectTo');
}); });
} }
}, },

View File

@@ -95,7 +95,7 @@ export default {
this.getFenxiaoDetail(); this.getFenxiaoDetail();
} else { } else {
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.login.open('/pages_promotion/fenxiao/promote_code'); this.$refs.login.open('/pages_promotion/fenxiao/promote_code', 'redirectTo');
}); });
} }
}, },

View File

@@ -175,7 +175,7 @@ export default {
} else { } else {
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.login.open('/pages_promotion/fenxiao/promote_code'); this.$refs.login.open('/pages_promotion/fenxiao/promote_code', 'redirectTo');
}); });
} }
}, },

View File

@@ -123,7 +123,7 @@ export default {
if (!this.storeToken) { if (!this.storeToken) {
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.login.open('/pages_promotion/fenxiao/team'); this.$refs.login.open('/pages_promotion/fenxiao/team', 'redirectTo');
}); });
} }
}, },

View File

@@ -79,7 +79,7 @@ export default {
if (!this.storeToken) { if (!this.storeToken) {
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.login.open('/pages_promotion/fenxiao/withdraw_list'); this.$refs.login.open('/pages_promotion/fenxiao/withdraw_list', 'redirectTo');
}); });
} }
}, },

View File

@@ -218,7 +218,7 @@
}, },
toLogin() { toLogin() {
this.$refs.login.open('/pages_goods/category') this.$refs.login.open('/pages_goods/category', 'redirectTo');
} }
}, },
// onPullDownRefresh() { // onPullDownRefresh() {

View File

@@ -442,7 +442,7 @@ export default {
// 立即购买 // 立即购买
exchange() { exchange() {
if (!this.storeToken) { if (!this.storeToken) {
this.$refs.login.open('/pages_promotion/point/detail?id=' + this.id); this.$refs.login.open('/pages_promotion/point/detail?id=' + this.id, 'redirectTo');
return; return;
} }
this.$refs.goodsSku.show('point'); this.$refs.goodsSku.show('point');

View File

@@ -490,7 +490,7 @@ export default {
}, },
//跳转至登录页面 //跳转至登录页面
login() { login() {
this.$refs.login.open('/pages_promotion/point/list'); this.$refs.login.open('/pages_promotion/point/list', 'redirectTo');
}, },
imgError(index) { imgError(index) {
this.goodsList[index].image = this.$util.getDefaultImage().goods; this.goodsList[index].image = this.$util.getDefaultImage().goods;
@@ -521,7 +521,7 @@ export default {
*/ */
redirect(url) { redirect(url) {
if (!this.storeToken) { if (!this.storeToken) {
this.$refs.login.open(url); this.$refs.login.open(url, 'redirectTo');
} else { } else {
this.$util.redirectTo(url); this.$util.redirectTo(url);
} }

View File

@@ -127,7 +127,7 @@ export default {
if (!this.storeToken) { if (!this.storeToken) {
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.login.open('/pages_promotion/point/order_list'); this.$refs.login.open('/pages_promotion/point/order_list', 'redirectTo');
}); });
} }
}, },

View File

@@ -48,7 +48,7 @@
this.getData(); this.getData();
} else { } else {
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.login.open('/pages_tool/form/form?id=' + this.id) this.$refs.login.open('/pages_tool/form/form?id=' + this.id, 'redirectTo');
}) })
} }
}, },

View File

@@ -200,7 +200,7 @@ export default {
}); });
} else { } else {
this.couponBtnSwitch = false; this.couponBtnSwitch = false;
this.$refs.login.open('/pages_tool/goods/coupon'); this.$refs.login.open('/pages_tool/goods/coupon', 'redirectTo');
} }
}, },
//获取优惠券列表 //获取优惠券列表

View File

@@ -83,14 +83,14 @@ export default {
if (option.redirect) this.redirect = option.redirect; if (option.redirect) this.redirect = option.redirect;
}, },
onShow() { onShow() {
if (this.storeToken) { if (!this.storeToken) {
this.getTransferType(); setTimeout(() => {
if (this.$refs.mescroll) this.$refs.mescroll.refresh(); this.$refs.login.open('/pages_tool/member/account', 'redirectTo');
} else { }, 100);
this.$nextTick(() => { return;
this.$refs.login.open('/pages_tool/member/account');
});
} }
this.getTransferType();
if (this.$refs.mescroll) this.$refs.mescroll.refresh();
}, },
methods: { methods: {
// 编辑提现账户信息 // 编辑提现账户信息

View File

@@ -133,9 +133,10 @@ export default {
if (this.storeToken) { if (this.storeToken) {
if (this.$refs.mescroll) this.$refs.mescroll.refresh(); if (this.$refs.mescroll) this.$refs.mescroll.refresh();
} else { } else {
this.$nextTick(() => { // 使用redirectTo模式:当前页被登录页替换,返回时直接回到上一页,不会产生循环
this.$refs.login.open('/pages_tool/member/address'); setTimeout(() => {
}); this.$refs.login.open('/pages_tool/member/address', 'redirectTo');
}, 100);
} }
}, },
methods: { methods: {

View File

@@ -86,15 +86,15 @@ export default {
}; };
}, },
async onShow() { async onShow() {
if (!this.storeToken) {
setTimeout(() => {
this.$refs.login.open('/pages_tool/member/balance', 'redirectTo');
}, 100);
return;
}
this.getWithdrawConfig(); this.getWithdrawConfig();
this.getMemberrechargeConfig(); this.getMemberrechargeConfig();
if (!this.storeToken) { this.getUserInfo();
this.$nextTick(() => {
this.$refs.login.open('/pages_tool/member/balance');
});
} else {
this.getUserInfo();
}
}, },
onLoad() { onLoad() {
// #ifdef MP // #ifdef MP

View File

@@ -95,9 +95,10 @@ export default {
}, },
onShow() { onShow() {
if (!this.storeToken) { if (!this.storeToken) {
this.$nextTick(() => { setTimeout(() => {
this.$refs.login.open('/pages_tool/member/balance'); this.$refs.login.open('/pages_tool/member/balance_detail', 'redirectTo');
}); }, 100);
return;
} }
}, },
methods: { methods: {

View File

@@ -80,9 +80,10 @@
}, },
onShow() { onShow() {
if (!this.storeToken) { if (!this.storeToken) {
this.$nextTick(() => { setTimeout(() => {
this.$refs.login.open('/pages_tool/member/index'); this.$refs.login.open('/pages_tool/member/bind_mobile', 'redirectTo');
}); }, 100);
return;
} }
}, },
onHide() { onHide() {

View File

@@ -142,7 +142,7 @@ export default {
//会员卡 //会员卡
if (!this.storeToken) { if (!this.storeToken) {
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.login.open('/pages_tool/member/card'); this.$refs.login.open('/pages_tool/member/card', 'redirectTo');
}); });
return; return;
} }

View File

@@ -298,7 +298,7 @@ export default {
this.getCardList(); this.getCardList();
} else { } else {
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.login.open('/pages_tool/member/card_buy'); this.$refs.login.open('/pages_tool/member/card_buy', 'redirectTo');
}); });
} }
this.getAgreement(); this.getAgreement();

View File

@@ -84,7 +84,7 @@ export default {
onLoad() { onLoad() {
if (!this.storeToken) { if (!this.storeToken) {
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.login.open('/pages_tool/member/card_log'); this.$refs.login.open('/pages_tool/member/card_log', 'redirectTo');
}); });
return; return;
} }

View File

@@ -101,13 +101,13 @@ export default {
this.isIphoneX = this.$util.uniappIsIPhoneX(); this.isIphoneX = this.$util.uniappIsIPhoneX();
}, },
onShow() { onShow() {
if (this.storeToken) { if (!this.storeToken) {
if (this.$refs.mescroll) this.$refs.mescroll.refresh(); setTimeout(() => {
} else { this.$refs.login.open('/pages_tool/member/coupon', 'redirectTo');
this.$nextTick(() => { }, 100);
this.$refs.login.open('/pages_tool/member/coupon'); return;
});
} }
if (this.$refs.mescroll) this.$refs.mescroll.refresh();
}, },
methods: { methods: {
//切换状态 //切换状态

View File

@@ -251,7 +251,7 @@
this.getList(); this.getList();
} else { } else {
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.login.open('/pages_tool/member/invite_friends'); this.$refs.login.open('/pages_tool/member/invite_friends', 'redirectTo');
}); });
} }
}, },

View File

@@ -221,7 +221,7 @@
this.getLevelRule(); this.getLevelRule();
if (!this.storeToken) { if (!this.storeToken) {
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.login.open('/pages_tool/member/level'); this.$refs.login.open('/pages_tool/member/level', 'redirectTo');
}); });
} else { } else {
this.getLevelList(); this.getLevelList();

View File

@@ -90,12 +90,12 @@ export default {
}, },
onShow() { onShow() {
if (!this.storeToken) { if (!this.storeToken) {
this.$nextTick(() => { setTimeout(() => {
this.$refs.login.open('/pages_tool/member/point'); this.$refs.login.open('/pages_tool/member/point', 'redirectTo');
}); }, 100);
} else { return;
this.getMemberPoint();
} }
this.getMemberPoint();
}, },
onLoad() { onLoad() {
// #ifdef MP // #ifdef MP

View File

@@ -4,7 +4,7 @@ export default {
toLogin(url) { toLogin(url) {
const currentRoute = this.$util.getCurrentRoute(); const currentRoute = this.$util.getCurrentRoute();
const backUrl = url ?? (currentRoute && currentRoute.path ? currentRoute.path : ''); const backUrl = url ?? (currentRoute && currentRoute.path ? currentRoute.path : '');
this.$refs.login.open(backUrl); this.$refs.login.open(backUrl, 'redirectTo');
} }
} }
} }

View File

@@ -88,12 +88,13 @@ export default {
}, },
onShow() { onShow() {
if (!this.storeToken) { if (!this.storeToken) {
this.$nextTick(() => { // 使用redirectTo模式:当前页被登录页替换,返回时直接回到上一页,不会产生循环
this.$refs.login.open('/pages_tool/member/info'); setTimeout(() => {
}); this.$refs.login.open('/pages_tool/member/info', 'redirectTo');
} else { }, 100);
this.getInfo(); return;
} }
this.getInfo();
}, },
onHide() { onHide() {
this.seconds = 120; this.seconds = 120;

View File

@@ -46,7 +46,7 @@ export default {
onShow() { onShow() {
if (!this.storeToken) { if (!this.storeToken) {
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.login.open('/pages_tool/member/signin'); this.$refs.login.open('/pages_tool/member/signin', 'redirectTo');
}); });
return; return;
} }

View File

@@ -48,13 +48,13 @@ export default {
}; };
}, },
onShow() { onShow() {
if (this.$refs.mescroll) this.$refs.mescroll.refresh();
if (!this.storeToken) { if (!this.storeToken) {
this.$nextTick(() => { setTimeout(() => {
this.$refs.login.open('/pages_tool/recharge/order_list'); this.$refs.login.open('/pages_tool/recharge/order_list', 'redirectTo');
}); }, 100);
return;
} }
if (this.$refs.mescroll) this.$refs.mescroll.refresh();
}, },
methods: { methods: {
getListData(mescroll) { getListData(mescroll) {