upload project
This commit is contained in:
commit
06961cae04
422 changed files with 110626 additions and 0 deletions
95
utils/redirect.js
Normal file
95
utils/redirect.js
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue