完成consumer端同步
This commit is contained in:
35
App.uvue
35
App.uvue
@@ -16,6 +16,26 @@
|
||||
console.log('App Hide')
|
||||
},
|
||||
methods: {
|
||||
safeReLaunch: function(targetUrl: string, fallbackUrl: string): void {
|
||||
try {
|
||||
uni.reLaunch({
|
||||
url: targetUrl,
|
||||
fail: function() {
|
||||
if (fallbackUrl !== '') {
|
||||
uni.reLaunch({ url: fallbackUrl })
|
||||
}
|
||||
}
|
||||
})
|
||||
} catch (e) {
|
||||
if (fallbackUrl !== '') {
|
||||
try {
|
||||
uni.reLaunch({ url: fallbackUrl })
|
||||
} catch (ee) {
|
||||
console.warn('safeReLaunch fallback failed', ee)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
checkExistingSession: function(): void {
|
||||
// 检查是否已有有效会话
|
||||
const session = supa.getSession()
|
||||
@@ -23,13 +43,13 @@
|
||||
console.log('已有有效会话,恢复登录状态')
|
||||
setIsLoggedIn(true)
|
||||
// #ifdef H5
|
||||
uni.reLaunch({ url: '/pages/mall/admin/homePage/index' })
|
||||
this.safeReLaunch('/pages/main/index', '/pages/user/login')
|
||||
// #endif
|
||||
// #ifdef MP-WEIXIN
|
||||
uni.reLaunch({ url: '/pages/mall/merchant/index' })
|
||||
this.safeReLaunch('/pages/main/index', '/pages/user/login')
|
||||
// #endif
|
||||
// #ifndef H5 || MP-WEIXIN
|
||||
uni.reLaunch({ url: '/pages/mall/admin/homePage/index' })
|
||||
this.safeReLaunch('/pages/main/index', '/pages/user/login')
|
||||
// #endif
|
||||
return
|
||||
}
|
||||
@@ -43,22 +63,25 @@
|
||||
console.log('会话恢复成功')
|
||||
setIsLoggedIn(true)
|
||||
// #ifdef H5
|
||||
uni.reLaunch({ url: '/pages/mall/admin/homePage/index' })
|
||||
this.safeReLaunch('/pages/main/index', '/pages/user/login')
|
||||
// #endif
|
||||
// #ifdef MP-WEIXIN
|
||||
uni.reLaunch({ url: '/pages/mall/merchant/index' })
|
||||
this.safeReLaunch('/pages/main/index', '/pages/user/login')
|
||||
// #endif
|
||||
// #ifndef H5 || MP-WEIXIN
|
||||
uni.reLaunch({ url: '/pages/mall/admin/homePage/index' })
|
||||
this.safeReLaunch('/pages/main/index', '/pages/user/login')
|
||||
// #endif
|
||||
}
|
||||
}).catch(() => {
|
||||
console.log('会话恢复失败,需要重新登录')
|
||||
this.safeReLaunch('/pages/user/login', '')
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 没有有效会话,显示登录页
|
||||
console.log('无有效会话,显示登录页')
|
||||
this.safeReLaunch('/pages/user/login', '')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user