提交 e50dd806 编写于 作者: DCloud_JSON's avatar DCloud_JSON

修复 注册并登录后,没有返回到业务页面的问题

上级 528a1eba
import { state, mutations } from '@/uni_modules/uni-id-pages-x/store.uts'; import { state, mutations } from '@/uni_modules/uni-id-pages-x/store.uts';
import config from '@/uni_modules/uni-id-pages-x/config.uts'; import config from '@/uni_modules/uni-id-pages-x/config.uts';
export const loginSuccess = (_ : UTSJSONObject) => { export const loginSuccess = (_ : UTSJSONObject) => {
// console.log('loginSuccess', e); // console.log('loginSuccess', e);
// console.log("新用户uid", e["uid"]); // console.log("新用户uid", e["uid"]);
// state.currentUserInfo = uniCloud.getCurrentUserInfo() // state.currentUserInfo = uniCloud.getCurrentUserInfo()
...@@ -11,7 +11,7 @@ export const loginSuccess = (_ : UTSJSONObject) => { ...@@ -11,7 +11,7 @@ export const loginSuccess = (_ : UTSJSONObject) => {
// 登录后重定向设置 // 登录后重定向设置
function loginAfterToPage() { function loginAfterToPage() {
const pages = getCurrentPages() const pages = getCurrentPages()
const currentPage = pages[pages.length - 1] const currentPage = pages[pages.length - 1]
let uniIdRedirectUrl = currentPage.options["uniIdRedirectUrl"]; let uniIdRedirectUrl = currentPage.options["uniIdRedirectUrl"];
if (uniIdRedirectUrl != null) { if (uniIdRedirectUrl != null) {
...@@ -20,11 +20,11 @@ export const loginSuccess = (_ : UTSJSONObject) => { ...@@ -20,11 +20,11 @@ export const loginSuccess = (_ : UTSJSONObject) => {
// #endif // #endif
// console.log('uniIdRedirectUrl', uniIdRedirectUrl); // console.log('uniIdRedirectUrl', uniIdRedirectUrl);
uni.redirectTo({ uni.redirectTo({
url: uniIdRedirectUrl, url: uniIdRedirectUrl as string,
fail() { fail() {
console.error("uniIdRouter redirectTo fail"); console.error("uniIdRouter redirectTo fail");
uni.switchTab({ uni.switchTab({
"url": uniIdRedirectUrl "url": uniIdRedirectUrl as string
}) })
}, },
success() { success() {
...@@ -33,6 +33,18 @@ export const loginSuccess = (_ : UTSJSONObject) => { ...@@ -33,6 +33,18 @@ export const loginSuccess = (_ : UTSJSONObject) => {
}) })
} else if (currentPage.route.includes("uni_modules/uni-id-pages-x/pages/login/login") ){ } else if (currentPage.route.includes("uni_modules/uni-id-pages-x/pages/login/login") ){
uni.navigateBack() uni.navigateBack()
} else {
// 需要返回的页面数
const needBackCount = pages.reduce((count, page) => {
if (page.route.includes("uni_modules/uni-id-pages-x/pages")) {
return count + 1
}
return count
}, 0)
// console.log('needBackCount', needBackCount);
uni.navigateBack({
delta: needBackCount
})
} }
}; };
const toastDuration = 1500 const toastDuration = 1500
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册