95 lines
2.3 KiB
JavaScript
95 lines
2.3 KiB
JavaScript
var redirecting=false;
|
||
// 🔥 统一的页面跳转方法 - 避免跳转冲突和超时
|
||
function navigateToPage(url) {
|
||
// 防止重复跳转
|
||
if (redirecting) {
|
||
|
||
return;
|
||
}
|
||
|
||
redirecting = true;
|
||
|
||
// 延迟执行,确保页面状态稳定
|
||
setTimeout(() => {
|
||
wx.navigateTo({
|
||
url: url,
|
||
success: () => {
|
||
|
||
redirecting = false;
|
||
},
|
||
fail: (error) => {
|
||
console.error('❌ 跳转到'+url+'失败:', error);
|
||
redirecting = false;
|
||
// 备用方案
|
||
wx.redirectTo({
|
||
url: url,
|
||
fail: (error2) => {
|
||
console.error('❌ redirectTo '+url+'失败:', error2);
|
||
wx.showToast({
|
||
title: '跳转失败,请重试',
|
||
icon: 'none'
|
||
});
|
||
}
|
||
});
|
||
}
|
||
});
|
||
}, 200); // 200ms延迟,确保页面状态稳定
|
||
} // 🔥 统一的页面跳转方法 - 避免跳转冲突和超时
|
||
function reLaunchToPage(url) {
|
||
// 防止重复跳转
|
||
if (redirecting) {
|
||
|
||
return;
|
||
}
|
||
|
||
redirecting = true;
|
||
|
||
// 延迟执行,确保页面状态稳定
|
||
setTimeout(() => {
|
||
wx.reLaunch({
|
||
url: url,
|
||
success: () => {
|
||
|
||
redirecting = false;
|
||
},
|
||
fail: (error) => {
|
||
console.error('❌ 跳转到'+url+'失败:', error);
|
||
redirecting = false;
|
||
// 备用方案
|
||
wx.redirectTo({
|
||
url: url,
|
||
fail: (error2) => {
|
||
console.error('❌ redirectTo '+url+'失败:', error2);
|
||
wx.showToast({
|
||
title: '跳转失败,请重试',
|
||
icon: 'none'
|
||
});
|
||
}
|
||
});
|
||
}
|
||
});
|
||
}, 200); // 200ms延迟,确保页面状态稳定
|
||
}
|
||
|
||
|
||
// 🔥 统一的手机号登陆页面跳转方法 - 避免跳转冲突和超时
|
||
function goMobileLogin() {
|
||
navigateToPage('/pages/login/mobile-login-page')
|
||
}
|
||
// 🔥 统一的主页跳转方法 - 避免跳转冲突和超时
|
||
function goMain() {
|
||
reLaunchToPage('/pages/map/map')
|
||
}
|
||
function goProfile() {
|
||
navigateToPage('/pages/login/profile-page')
|
||
}
|
||
|
||
|
||
|
||
module.exports = {
|
||
navigateToPage: navigateToPage,
|
||
goMobileLogin: goMobileLogin,
|
||
reLaunchToPage:reLaunchToPage,
|
||
goMain: goMain,
|
||
goProfile: goProfile
|
||
}
|