diff --git a/uni_modules/uni-id-pages-x/common/common.uts b/uni_modules/uni-id-pages-x/common/common.uts index 2e061174fc6ec92ad3674b79a5b4a6fd936558d5..8f9a536c829ecb6dc7835caa9b34efb791d6bc5d 100644 --- a/uni_modules/uni-id-pages-x/common/common.uts +++ b/uni_modules/uni-id-pages-x/common/common.uts @@ -1,6 +1,6 @@ import { state, mutations } from '@/uni_modules/uni-id-pages-x/store.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("新用户uid", e["uid"]); // state.currentUserInfo = uniCloud.getCurrentUserInfo() @@ -11,7 +11,7 @@ export const loginSuccess = (_ : UTSJSONObject) => { // 登录后重定向设置 function loginAfterToPage() { - const pages = getCurrentPages() + const pages = getCurrentPages() const currentPage = pages[pages.length - 1] let uniIdRedirectUrl = currentPage.options["uniIdRedirectUrl"]; if (uniIdRedirectUrl != null) { @@ -20,11 +20,11 @@ export const loginSuccess = (_ : UTSJSONObject) => { // #endif // console.log('uniIdRedirectUrl', uniIdRedirectUrl); uni.redirectTo({ - url: uniIdRedirectUrl, + url: uniIdRedirectUrl as string, fail() { console.error("uniIdRouter redirectTo fail"); uni.switchTab({ - "url": uniIdRedirectUrl + "url": uniIdRedirectUrl as string }) }, success() { @@ -33,6 +33,18 @@ export const loginSuccess = (_ : UTSJSONObject) => { }) } else if (currentPage.route.includes("uni_modules/uni-id-pages-x/pages/login/login") ){ 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