From 7f44aeecd40af7c976ed51cb8323e199b77aec35 Mon Sep 17 00:00:00 2001 From: wangsongsole Date: Thu, 7 Mar 2024 10:55:48 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=A6=80=EF=B8=8F=20fix:=20=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E8=B7=AF=E5=BE=84=E5=8F=82=E6=95=B0=E6=88=AA=E5=8F=96?= =?UTF-8?q?=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index 3b1be6e..9aefddb 100644 --- a/index.html +++ b/index.html @@ -126,7 +126,7 @@ if (openid) { localStorage.setItem('openid', openid); /* 截取openid防止重定向 */ - this.entryLink = location.href.replace(/&[^&]*$/, ''); + this.entryLink = this.removeLastParamFromUrl(location.href); } else { this.entryLink = location.href; } @@ -224,6 +224,25 @@ }, }, methods: { + // 截取路径上的最后一个参数的函数 + removeLastParamFromUrl (url) { + // 找到问号后的路径部分 + var pathIndex = url.indexOf('?'); + var path = url.substring(pathIndex + 1); + + // 将路径部分拆分为参数数组 + var params = path.split('&'); + + // 如果存在参数,移除最后一个参数 + if (params.length > 0) { + params.pop(); // 移除最后一个参数 + } + + // 重构URL + var updatedUrl = url.substring(0, pathIndex + 1) + params.join('&'); + + return updatedUrl; + }, //获取白名单验证码 getcode () {