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>
</view>
<ns-login ref="login"></ns-login>
</view>
</template>

View File

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

View File

@@ -262,9 +262,9 @@ export default {
return this.whetherCollection;
} else {
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 {
this.$refs.login.open(this.shareUrl);
this.$refs.login.open(this.shareUrl, 'redirectTo');
}
}
},

View File

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

View File

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

View File

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

View File

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

View File

@@ -296,7 +296,7 @@ export default {
this.checkFenxiaoIsStart();
} else {
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) {
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();
} else {
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();
} else {
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 {
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) {
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) {
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() {
this.$refs.login.open('/pages_goods/category')
this.$refs.login.open('/pages_goods/category', 'redirectTo');
}
},
// onPullDownRefresh() {

View File

@@ -442,7 +442,7 @@ export default {
// 立即购买
exchange() {
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;
}
this.$refs.goodsSku.show('point');

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -251,7 +251,7 @@
this.getList();
} else {
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();
if (!this.storeToken) {
this.$nextTick(() => {
this.$refs.login.open('/pages_tool/member/level');
this.$refs.login.open('/pages_tool/member/level', 'redirectTo');
});
} else {
this.getLevelList();

View File

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

View File

@@ -4,7 +4,7 @@ export default {
toLogin(url) {
const currentRoute = this.$util.getCurrentRoute();
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() {
if (!this.storeToken) {
this.$nextTick(() => {
this.$refs.login.open('/pages_tool/member/info');
});
} else {
this.getInfo();
// 使用redirectTo模式:当前页被登录页替换,返回时直接回到上一页,不会产生循环
setTimeout(() => {
this.$refs.login.open('/pages_tool/member/info', 'redirectTo');
}, 100);
return;
}
this.getInfo();
},
onHide() {
this.seconds = 120;

View File

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

View File

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