mirror of
https://github.com/soybeanjs/soybean-admin.git
synced 2025-09-27 13:46:41 +08:00
fix(other): 新增企业微信登录方法,对接后端FastAPI接口
This commit is contained in:
parent
a03becdaed
commit
a5e8bef596
2
.env
2
.env
@ -29,7 +29,7 @@ VITE_HTTP_PROXY=Y
|
|||||||
VITE_ROUTER_HISTORY_MODE=history
|
VITE_ROUTER_HISTORY_MODE=history
|
||||||
|
|
||||||
# success code of backend service, when the code is received, the request is successful
|
# success code of backend service, when the code is received, the request is successful
|
||||||
VITE_SERVICE_SUCCESS_CODE=0000
|
VITE_SERVICE_SUCCESS_CODE=200
|
||||||
|
|
||||||
# logout codes of backend service, when the code is received, the user will be logged out and redirected to login page
|
# logout codes of backend service, when the code is received, the user will be logged out and redirected to login page
|
||||||
VITE_SERVICE_LOGOUT_CODES=8888,8889
|
VITE_SERVICE_LOGOUT_CODES=8888,8889
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
# backend service base url, test environment
|
# backend service base url, test environment
|
||||||
VITE_SERVICE_BASE_URL=https://mock.apifox.cn/m1/3109515-0-default
|
# VITE_SERVICE_BASE_URL=https://mock.apifox.cn/m1/3109515-0-default
|
||||||
|
VITE_SERVICE_BASE_URL=http://172.21.10.20:8000/api/v1
|
||||||
|
|
||||||
# other backend service base url, test environment
|
# other backend service base url, test environment
|
||||||
VITE_OTHER_SERVICE_BASE_URL= `{
|
VITE_OTHER_SERVICE_BASE_URL= `{
|
||||||
|
@ -55,6 +55,7 @@
|
|||||||
"@sa/materials": "workspace:*",
|
"@sa/materials": "workspace:*",
|
||||||
"@sa/utils": "workspace:*",
|
"@sa/utils": "workspace:*",
|
||||||
"@vueuse/core": "12.5.0",
|
"@vueuse/core": "12.5.0",
|
||||||
|
"@wecom/jssdk": "^2.2.5",
|
||||||
"clipboard": "2.0.11",
|
"clipboard": "2.0.11",
|
||||||
"dayjs": "1.11.13",
|
"dayjs": "1.11.13",
|
||||||
"defu": "6.1.4",
|
"defu": "6.1.4",
|
||||||
|
@ -32,6 +32,9 @@ importers:
|
|||||||
'@vueuse/core':
|
'@vueuse/core':
|
||||||
specifier: 12.5.0
|
specifier: 12.5.0
|
||||||
version: 12.5.0(typescript@5.7.3)
|
version: 12.5.0(typescript@5.7.3)
|
||||||
|
'@wecom/jssdk':
|
||||||
|
specifier: ^2.2.5
|
||||||
|
version: 2.2.5
|
||||||
clipboard:
|
clipboard:
|
||||||
specifier: 2.0.11
|
specifier: 2.0.11
|
||||||
version: 2.0.11
|
version: 2.0.11
|
||||||
@ -1466,6 +1469,9 @@ packages:
|
|||||||
'@vueuse/shared@12.5.0':
|
'@vueuse/shared@12.5.0':
|
||||||
resolution: {integrity: sha512-vMpcL1lStUU6O+kdj6YdHDixh0odjPAUM15uJ9f7MY781jcYkIwFA4iv2EfoIPO6vBmvutI1HxxAwmf0cx5ISQ==}
|
resolution: {integrity: sha512-vMpcL1lStUU6O+kdj6YdHDixh0odjPAUM15uJ9f7MY781jcYkIwFA4iv2EfoIPO6vBmvutI1HxxAwmf0cx5ISQ==}
|
||||||
|
|
||||||
|
'@wecom/jssdk@2.2.5':
|
||||||
|
resolution: {integrity: sha512-qOBAsfqaiYM8jZHWYs/atHSpJhsLdZVNaxHQdmEQ7ZWul/GZMt4P5VY8Nf7GII7GhG8z/k+r37Dto6qtAaRqow==}
|
||||||
|
|
||||||
acorn-jsx@5.3.2:
|
acorn-jsx@5.3.2:
|
||||||
resolution: {integrity: sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==}
|
resolution: {integrity: sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
@ -5618,6 +5624,8 @@ snapshots:
|
|||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- typescript
|
- typescript
|
||||||
|
|
||||||
|
'@wecom/jssdk@2.2.5': {}
|
||||||
|
|
||||||
acorn-jsx@5.3.2(acorn@8.14.0):
|
acorn-jsx@5.3.2(acorn@8.14.0):
|
||||||
dependencies:
|
dependencies:
|
||||||
acorn: 8.14.0
|
acorn: 8.14.0
|
||||||
|
1
src/assets/svg-icon/gitee.svg
Normal file
1
src/assets/svg-icon/gitee.svg
Normal file
@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24"><path fill="currentColor" d="M11.984 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12a12 12 0 0 0 12-12A12 12 0 0 0 12 0zm6.09 5.333c.328 0 .593.266.592.593v1.482a.594.594 0 0 1-.593.592H9.777c-.982 0-1.778.796-1.778 1.778v5.63c0 .327.266.592.593.592h5.63c.982 0 1.778-.796 1.778-1.778v-.296a.593.593 0 0 0-.592-.593h-4.15a.59.59 0 0 1-.592-.592v-1.482a.593.593 0 0 1 .593-.592h6.815c.327 0 .593.265.593.592v3.408a4 4 0 0 1-4 4H5.926a.593.593 0 0 1-.593-.593V9.778a4.444 4.444 0 0 1 4.445-4.444h8.296Z"/></svg>
|
After Width: | Height: | Size: 581 B |
1
src/assets/svg-icon/wechat.svg
Normal file
1
src/assets/svg-icon/wechat.svg
Normal file
@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 16 16"><g fill="currentColor"><path d="M11.176 14.429c-2.665 0-4.826-1.8-4.826-4.018c0-2.22 2.159-4.02 4.824-4.02S16 8.191 16 10.411c0 1.21-.65 2.301-1.666 3.036a.32.32 0 0 0-.12.366l.218.81a.6.6 0 0 1 .029.117a.166.166 0 0 1-.162.162a.2.2 0 0 1-.092-.03l-1.057-.61a.5.5 0 0 0-.256-.074a.5.5 0 0 0-.142.021a5.7 5.7 0 0 1-1.576.22M9.064 9.542a.647.647 0 1 0 .557-1a.645.645 0 0 0-.646.647a.6.6 0 0 0 .09.353Zm3.232.001a.646.646 0 1 0 .546-1a.645.645 0 0 0-.644.644a.63.63 0 0 0 .098.356"/><path d="M0 6.826c0 1.455.781 2.765 2.001 3.656a.385.385 0 0 1 .143.439l-.161.6l-.1.373a.5.5 0 0 0-.032.14a.19.19 0 0 0 .193.193q.06 0 .111-.029l1.268-.733a.6.6 0 0 1 .308-.088q.088 0 .171.025a6.8 6.8 0 0 0 1.625.26a4.5 4.5 0 0 1-.177-1.251c0-2.936 2.785-5.02 5.824-5.02l.15.002C10.587 3.429 8.392 2 5.796 2C2.596 2 0 4.16 0 6.826m4.632-1.555a.77.77 0 1 1-1.54 0a.77.77 0 0 1 1.54 0m3.875 0a.77.77 0 1 1-1.54 0a.77.77 0 0 1 1.54 0"/></g></svg>
|
After Width: | Height: | Size: 1007 B |
1
src/assets/svg-icon/wecom.svg
Normal file
1
src/assets/svg-icon/wecom.svg
Normal file
@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 1024 1024"><path fill="currentColor" fill-rule="evenodd" d="M909.784 729.585a135.9 135.9 0 0 0-47.042 19.049a114.24 114.24 0 0 1-51.41 31.075c2.613-17.554 11.313-33.577 24.455-45.418a169.3 169.3 0 0 0 23.409-55.017c-.061-27.838 22.44-50.459 50.265-50.534c27.827-.076 50.45 22.423 50.539 50.26c.089 27.839-22.39 50.482-50.215 50.585zM817.568 608.83a168.8 168.8 0 0 0-54.808-23.68c-27.836 0-50.402-22.575-50.402-50.423s22.566-50.423 50.402-50.423s50.402 22.575 50.402 50.423a137.5 137.5 0 0 0 18.817 47.211a114.8 114.8 0 0 1 30.764 51.656a76.08 76.08 0 0 1-45.026-24.763h-.186zm-83.033-177.713C719.34 303.789 587.548 204.026 428.09 204.026c-169.874 0-308.088 113.097-308.088 252.19c2.72 78.1 43.941 149.778 110.063 191.385a311 311 0 0 0 33.602 21.588l-13.664 54.569c4.928 2.316 9.706 4.78 14.746 6.91l68.996-34.512c10.08 2.615 20.683 4.295 31.21 6.088c6.721 1.195 13.442 2.428 20.35 3.25a354.8 354.8 0 0 0 128.805-7.396a249 249 0 0 0 10.154 55.055a425.6 425.6 0 0 1-96.175 11.242a418 418 0 0 1-86.392-9.524l-125.186 62.526a27.62 27.62 0 0 1-29.98-3.137a28.02 28.02 0 0 1-9.67-28.611l22.401-90.239C117.176 643.186 66.463 553.506 64 456.216C64 285.973 227.004 148 428.09 148c190.93 0 347.29 124.527 362.521 282.818a245 245 0 0 0-26.47-2.614c-9.893.374-19.787 1.307-29.607 2.876zM618.237 629.934c16.764-3.362 32.706-9.786 47.042-19.049a114.24 114.24 0 0 1 51.447-31.001a76.47 76.47 0 0 1-24.491 45.344c-11.014 16.807-18.929 35.483-23.409 55.054c.041 27.833-22.468 50.435-50.29 50.497s-50.43-22.44-50.514-50.273c-.082-27.833 22.393-50.469 50.215-50.572m90.798 121.314c16.652 11.168 35.17 19.236 54.659 23.904c20.386 0 38.764 12.286 46.565 31.127s3.49 40.53-10.926 54.95a50.38 50.38 0 0 1-54.927 10.931c-18.834-7.804-31.114-26.19-31.114-46.585a136.7 136.7 0 0 0-18.668-47.285a114.7 114.7 0 0 1-30.54-51.805a76 76 0 0 1 44.951 25.062z"/></svg>
|
After Width: | Height: | Size: 1.9 KiB |
@ -178,7 +178,8 @@ const local: App.I18n.Schema = {
|
|||||||
back: 'Back',
|
back: 'Back',
|
||||||
validateSuccess: 'Verification passed',
|
validateSuccess: 'Verification passed',
|
||||||
loginSuccess: 'Login successfully',
|
loginSuccess: 'Login successfully',
|
||||||
welcomeBack: 'Welcome back, {userName} !'
|
welcomeBack: 'Welcome back, {userName} !',
|
||||||
|
infoWarning: 'The current feature has not been implemented yet.'
|
||||||
},
|
},
|
||||||
pwdLogin: {
|
pwdLogin: {
|
||||||
title: 'Password Login',
|
title: 'Password Login',
|
||||||
@ -209,6 +210,10 @@ const local: App.I18n.Schema = {
|
|||||||
},
|
},
|
||||||
bindWeChat: {
|
bindWeChat: {
|
||||||
title: 'Bind WeChat'
|
title: 'Bind WeChat'
|
||||||
|
},
|
||||||
|
weComLogin: {
|
||||||
|
title: 'WeCom Login',
|
||||||
|
wecomOauth: 'WeCom OAuth Login'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
home: {
|
home: {
|
||||||
|
@ -178,7 +178,8 @@ const local: App.I18n.Schema = {
|
|||||||
back: '返回',
|
back: '返回',
|
||||||
validateSuccess: '验证成功',
|
validateSuccess: '验证成功',
|
||||||
loginSuccess: '登录成功',
|
loginSuccess: '登录成功',
|
||||||
welcomeBack: '欢迎回来,{userName} !'
|
welcomeBack: '欢迎回来,{userName} !',
|
||||||
|
infoWarning: '当前功能尚未实现!'
|
||||||
},
|
},
|
||||||
pwdLogin: {
|
pwdLogin: {
|
||||||
title: '密码登录',
|
title: '密码登录',
|
||||||
@ -209,6 +210,10 @@ const local: App.I18n.Schema = {
|
|||||||
},
|
},
|
||||||
bindWeChat: {
|
bindWeChat: {
|
||||||
title: '绑定微信'
|
title: '绑定微信'
|
||||||
|
},
|
||||||
|
weComLogin: {
|
||||||
|
title: '企业微信登录',
|
||||||
|
wecomOauth: '企业微信单点登录'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
home: {
|
home: {
|
||||||
|
@ -1,5 +1,13 @@
|
|||||||
import { request } from '../request';
|
import { request } from '../request';
|
||||||
|
|
||||||
|
/** 获取企业微信手机及Webview的URL链接 */
|
||||||
|
export function fetchGetWecomUrl(info: boolean) {
|
||||||
|
if (info) {
|
||||||
|
return request<string>({ url: '/getWecomUrl', params: { info } });
|
||||||
|
}
|
||||||
|
return request<string>({ url: '/getWecomUrl' });
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Login
|
* Login
|
||||||
*
|
*
|
||||||
|
8
src/typings/api.d.ts
vendored
8
src/typings/api.d.ts
vendored
@ -65,6 +65,14 @@ declare namespace Api {
|
|||||||
roles: string[];
|
roles: string[];
|
||||||
buttons: string[];
|
buttons: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface WecomInfo {
|
||||||
|
appid: string;
|
||||||
|
agent_id: string;
|
||||||
|
redirect_uri: string;
|
||||||
|
state: string;
|
||||||
|
session_id?: string;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
5
src/typings/app.d.ts
vendored
5
src/typings/app.d.ts
vendored
@ -422,6 +422,7 @@ declare namespace App {
|
|||||||
validateSuccess: string;
|
validateSuccess: string;
|
||||||
loginSuccess: string;
|
loginSuccess: string;
|
||||||
welcomeBack: string;
|
welcomeBack: string;
|
||||||
|
infoWarning: string;
|
||||||
};
|
};
|
||||||
pwdLogin: {
|
pwdLogin: {
|
||||||
title: string;
|
title: string;
|
||||||
@ -453,6 +454,10 @@ declare namespace App {
|
|||||||
bindWeChat: {
|
bindWeChat: {
|
||||||
title: string;
|
title: string;
|
||||||
};
|
};
|
||||||
|
weComLogin: {
|
||||||
|
title: string;
|
||||||
|
wecomOauth: string;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
home: {
|
home: {
|
||||||
branchDesc: string;
|
branchDesc: string;
|
||||||
|
3
src/typings/components.d.ts
vendored
3
src/typings/components.d.ts
vendored
@ -26,7 +26,10 @@ declare module 'vue' {
|
|||||||
IconIcRoundRemove: typeof import('~icons/ic/round-remove')['default']
|
IconIcRoundRemove: typeof import('~icons/ic/round-remove')['default']
|
||||||
IconIcRoundSearch: typeof import('~icons/ic/round-search')['default']
|
IconIcRoundSearch: typeof import('~icons/ic/round-search')['default']
|
||||||
IconLocalBanner: typeof import('~icons/local/banner')['default']
|
IconLocalBanner: typeof import('~icons/local/banner')['default']
|
||||||
|
IconLocalGitee: typeof import('~icons/local/gitee')['default']
|
||||||
IconLocalLogo: typeof import('~icons/local/logo')['default']
|
IconLocalLogo: typeof import('~icons/local/logo')['default']
|
||||||
|
IconLocalWechat: typeof import('~icons/local/wechat')['default']
|
||||||
|
IconLocalWecom: typeof import('~icons/local/wecom')['default']
|
||||||
IconMdiArrowDownThin: typeof import('~icons/mdi/arrow-down-thin')['default']
|
IconMdiArrowDownThin: typeof import('~icons/mdi/arrow-down-thin')['default']
|
||||||
IconMdiArrowUpThin: typeof import('~icons/mdi/arrow-up-thin')['default']
|
IconMdiArrowUpThin: typeof import('~icons/mdi/arrow-up-thin')['default']
|
||||||
IconMdiDrag: typeof import('~icons/mdi/drag')['default']
|
IconMdiDrag: typeof import('~icons/mdi/drag')['default']
|
||||||
|
@ -5,11 +5,14 @@ import { loginModuleRecord } from '@/constants/app';
|
|||||||
import { useRouterPush } from '@/hooks/common/router';
|
import { useRouterPush } from '@/hooks/common/router';
|
||||||
import { useFormRules, useNaiveForm } from '@/hooks/common/form';
|
import { useFormRules, useNaiveForm } from '@/hooks/common/form';
|
||||||
import { useAuthStore } from '@/store/modules/auth';
|
import { useAuthStore } from '@/store/modules/auth';
|
||||||
|
import { useAppStore } from '@/store/modules/app';
|
||||||
|
import { fetchGetWecomUrl } from '@/service/api';
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: 'PwdLogin'
|
name: 'PwdLogin'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const appStore = useAppStore();
|
||||||
const authStore = useAuthStore();
|
const authStore = useAuthStore();
|
||||||
const { toggleLoginModule } = useRouterPush();
|
const { toggleLoginModule } = useRouterPush();
|
||||||
const { formRef, validate } = useNaiveForm();
|
const { formRef, validate } = useNaiveForm();
|
||||||
@ -39,39 +42,26 @@ async function handleSubmit() {
|
|||||||
await authStore.login(model.userName, model.password);
|
await authStore.login(model.userName, model.password);
|
||||||
}
|
}
|
||||||
|
|
||||||
type AccountKey = 'super' | 'admin' | 'user';
|
async function getWecomInfo(info = false) {
|
||||||
|
// 调用后端接口获取企业微信相关信息
|
||||||
interface Account {
|
const { data: url, error } = await fetchGetWecomUrl(info);
|
||||||
key: AccountKey;
|
if (!error) {
|
||||||
label: string;
|
// 跳转到企业微信授权页面
|
||||||
userName: string;
|
window.location.href = url;
|
||||||
password: string;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const accounts = computed<Account[]>(() => [
|
// 判断是否是手机和企业微信Webview的方法
|
||||||
{
|
const isMobileAndWecom = computed(() => {
|
||||||
key: 'super',
|
const userAgent = navigator.userAgent;
|
||||||
label: $t('page.login.pwdLogin.superAdmin'),
|
const isWecom = /wxwork/i.test(userAgent);
|
||||||
userName: 'Super',
|
return !appStore.isMobile && !isWecom;
|
||||||
password: '123456'
|
});
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'admin',
|
|
||||||
label: $t('page.login.pwdLogin.admin'),
|
|
||||||
userName: 'Admin',
|
|
||||||
password: '123456'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'user',
|
|
||||||
label: $t('page.login.pwdLogin.user'),
|
|
||||||
userName: 'User',
|
|
||||||
password: '123456'
|
|
||||||
}
|
|
||||||
]);
|
|
||||||
|
|
||||||
async function handleAccountLogin(account: Account) {
|
// 未实现功能告警
|
||||||
await authStore.login(account.userName, account.password);
|
const handleFailed = () => {
|
||||||
}
|
window.$message?.warning($t('page.login.common.infoWarning'));
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@ -107,8 +97,21 @@ async function handleAccountLogin(account: Account) {
|
|||||||
</div>
|
</div>
|
||||||
<NDivider class="text-14px text-#666 !m-0">{{ $t('page.login.pwdLogin.otherAccountLogin') }}</NDivider>
|
<NDivider class="text-14px text-#666 !m-0">{{ $t('page.login.pwdLogin.otherAccountLogin') }}</NDivider>
|
||||||
<div class="flex-center gap-12px">
|
<div class="flex-center gap-12px">
|
||||||
<NButton v-for="item in accounts" :key="item.key" type="primary" @click="handleAccountLogin(item)">
|
<NButton v-if="isMobileAndWecom" quaternary class="text-20px lt-sm:text-18px" @click="getWecomInfo(true)">
|
||||||
{{ item.label }}
|
<template #icon>
|
||||||
|
<icon-local-wecom />
|
||||||
|
</template>
|
||||||
|
</NButton>
|
||||||
|
<NButton v-else text @click="getWecomInfo(false)">{{ $t('page.login.weComLogin.wecomOauth') }}</NButton>
|
||||||
|
<NButton v-show="isMobileAndWecom" quaternary class="text-20px lt-sm:text-18px" @click="handleFailed">
|
||||||
|
<template #icon>
|
||||||
|
<icon-local-wechat />
|
||||||
|
</template>
|
||||||
|
</NButton>
|
||||||
|
<NButton v-show="isMobileAndWecom" quaternary class="text-20px lt-sm:text-18px" @click="handleFailed">
|
||||||
|
<template #icon>
|
||||||
|
<icon-local-gitee />
|
||||||
|
</template>
|
||||||
</NButton>
|
</NButton>
|
||||||
</div>
|
</div>
|
||||||
</NSpace>
|
</NSpace>
|
||||||
|
93
src/views/_builtin/login/modules/wecom-login.vue
Normal file
93
src/views/_builtin/login/modules/wecom-login.vue
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import * as ww from '@wecom/jssdk';
|
||||||
|
import { onMounted, onUnmounted, reactive, ref } from 'vue';
|
||||||
|
import { useRouterPush } from '@/hooks/common/router';
|
||||||
|
|
||||||
|
defineOptions({
|
||||||
|
name: 'WecomLogin'
|
||||||
|
});
|
||||||
|
|
||||||
|
const weComCodeLogin = ref();
|
||||||
|
|
||||||
|
// 定义appid
|
||||||
|
const wecomInfo: Api.Auth.WecomInfo = reactive({
|
||||||
|
appid: '',
|
||||||
|
agent_id: '',
|
||||||
|
redirect_uri: '',
|
||||||
|
state: ''
|
||||||
|
});
|
||||||
|
|
||||||
|
const { toggleLoginModule } = useRouterPush();
|
||||||
|
|
||||||
|
// 初始化登录组件
|
||||||
|
const wwLogin = ww.createWWLoginPanel({
|
||||||
|
el: '#ww_login',
|
||||||
|
params: {
|
||||||
|
login_type: ww.WWLoginType.corpApp,
|
||||||
|
appid: wecomInfo.appid, // 企业微信的公司ID
|
||||||
|
agentid: wecomInfo.agent_id, // 企业微信自建应用ID
|
||||||
|
redirect_uri: wecomInfo.redirect_uri,
|
||||||
|
state: wecomInfo.state,
|
||||||
|
panel_size: ww.WWLoginPanelSizeType.small,
|
||||||
|
redirect_type: ww.WWLoginRedirectType.callback
|
||||||
|
},
|
||||||
|
// 获取企业微信桌面端登录状态的回调函数
|
||||||
|
// onCheckWeComLogin({ isWeComLogin }) {
|
||||||
|
// authStore.isWechatLogin = isWeComLogin;
|
||||||
|
// },
|
||||||
|
onLoginSuccess({ code }: any) {
|
||||||
|
// 把获取到的code传递给后端,并在后端获取用户的详细信息返回
|
||||||
|
// authStore.wecomLogin(code).then(() => {
|
||||||
|
// 登录成功后跳转到首页
|
||||||
|
// router.push("/");
|
||||||
|
// })
|
||||||
|
window.$message?.success(code);
|
||||||
|
},
|
||||||
|
onLoginFail(err: any) {
|
||||||
|
window.$message?.error(err.message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 确认按钮的回调函数
|
||||||
|
function handleSubmit() {
|
||||||
|
window.$message?.warning('扫码成功即可登录,无需点击该按钮');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始化登录组件参数
|
||||||
|
// async function initLoginParams() {
|
||||||
|
// // 向后端获取企业微信扫码组件需要的必要信息
|
||||||
|
// const { data: info, error } = await fetchGetWecomInfo();
|
||||||
|
// if (!error) {
|
||||||
|
// wecomInfo.appid = info.appid;
|
||||||
|
// wecomInfo.agent_id = info.agent_id;
|
||||||
|
// wecomInfo.redirect_uri = info.redirect_uri;
|
||||||
|
// wecomInfo.state = info.state;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
// await initLoginParams();
|
||||||
|
weComCodeLogin.value.appendChild(wwLogin.el);
|
||||||
|
});
|
||||||
|
onUnmounted(() => {
|
||||||
|
wwLogin.unmount();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<NForm size="large" :show-label="false">
|
||||||
|
<NFormItem path="code">
|
||||||
|
<div ref="weComCodeLogin" class="w-full flex-x-center" />
|
||||||
|
</NFormItem>
|
||||||
|
<NSpace vertical :size="18" class="mt-5 w-full">
|
||||||
|
<NButton type="primary" size="large" round block @click="handleSubmit">
|
||||||
|
{{ $t('common.confirm') }}
|
||||||
|
</NButton>
|
||||||
|
<NButton size="large" round block @click="toggleLoginModule('pwd-login')">
|
||||||
|
{{ $t('page.login.common.back') }}
|
||||||
|
</NButton>
|
||||||
|
</NSpace>
|
||||||
|
</NForm>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped></style>
|
Loading…
Reference in New Issue
Block a user