From 42730a4429c69723abaa580fcc380cab5a598fba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E5=BF=A0=E6=9E=97?= <170083662@qq.com> Date: Fri, 6 Sep 2024 17:09:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=EF=BC=9Atoken=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/router/routes.ts | 5 +++++ src/utils/common.ts | 22 +++++++++++++++++++++- src/views/passport/loginToken/index.vue | 16 ++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 src/views/passport/loginToken/index.vue diff --git a/src/router/routes.ts b/src/router/routes.ts index 5154265..98cdaa8 100644 --- a/src/router/routes.ts +++ b/src/router/routes.ts @@ -15,6 +15,11 @@ export const routes = [ component: () => import('@/views/passport/login/index.vue'), meta: { title: '登录' } }, + { + path: '/token-login', + component: () => import('@/views/passport/loginToken/index.vue'), + meta: { title: 'token登录' } + }, // { // path: '/forget', // component: () => import('@/views/passport/forget/index.vue'), diff --git a/src/utils/common.ts b/src/utils/common.ts index 7756eaf..a49c7e9 100644 --- a/src/utils/common.ts +++ b/src/utils/common.ts @@ -97,7 +97,7 @@ export function openSpmUrl(path: string, d?: any, id = 0): void { // 跳转页面 url.value = `${domain}${path}${spm.value}${token.value}`; - console.log(url.value,'domain>>>>'); + console.log(url.value, 'domain>>>>'); window.open(`${url.value}`); } @@ -396,3 +396,23 @@ export const getPageTitle = () => { const { title } = meta; return title; }; + +/** + * 提取传参中的ID + * param 12334.html + * return 1234 + * @param index + */ +export const getIdBySpm = (index: number) => { + console.log('split', router.currentRoute.value.query.spm); + const split = String(router.currentRoute.value.query.spm).split('.'); + console.log(split); + return split[index]; +}; + +/** + * 提取传参中的token + */ +export const getTokenBySpm = () => { + return JSON.parse(router.currentRoute.value.query.token); +}; diff --git a/src/views/passport/loginToken/index.vue b/src/views/passport/loginToken/index.vue new file mode 100644 index 0000000..2ae6752 --- /dev/null +++ b/src/views/passport/loginToken/index.vue @@ -0,0 +1,16 @@ + + + +