From e50dd80612778725370646f418132b584ec6ca0b Mon Sep 17 00:00:00 2001 From: linju Date: Mon, 9 Dec 2024 17:24:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20=E6=B3=A8=E5=86=8C?= =?UTF-8?q?=E5=B9=B6=E7=99=BB=E5=BD=95=E5=90=8E=EF=BC=8C=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E5=88=B0=E4=B8=9A=E5=8A=A1=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- uni_modules/uni-id-pages-x/common/common.uts | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/uni_modules/uni-id-pages-x/common/common.uts b/uni_modules/uni-id-pages-x/common/common.uts index 2e06117..8f9a536 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 -- GitLab