From b3f465601308d5037c0ba24817eecf879638f928 Mon Sep 17 00:00:00 2001 From: zhanghua <314079846@qq.com> Date: 星期一, 04 十一月 2024 23:40:13 +0800 Subject: [PATCH] 钉钉登录bug修改 --- src/views/dingdingLogin.vue | 31 +++++++++++++++++++++++++------ 1 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/views/dingdingLogin.vue b/src/views/dingdingLogin.vue index cf735b3..e2f1c3c 100644 --- a/src/views/dingdingLogin.vue +++ b/src/views/dingdingLogin.vue @@ -11,16 +11,32 @@ import { dingdingLogin } from '@/api/system/user'; import { setToken } from '@/utils/auth'; +import { ElMessage } from 'element-plus'; +import { any } from 'vue-types'; + const getUserDate = async (authCode: string, code: string) => { await dingdingLogin({ authCode: authCode, code: code - }).then((res: any) => { - var data = { value: 'admin', expirse: new Date().getTime() }; + }) + .then((res: any) => { + if (res) { + var data = { value: res, expirse: new Date().getTime() }; - setToken(JSON.stringify(data)); - window.location.href = '/index'; - }); + setToken(JSON.stringify(data)); + window.location.href = '/index'; + } else { + ElMessage({ message: '鐧诲綍澶辫触', type: 'error' }); + setTimeout(() => { + window.location.href = '/login'; + }, 3000); + } + }) + .catch((e: any) => { + setTimeout(() => { + window.location.href = '/login'; + }, 3000); + }); }; onMounted(() => { const router = useRoute(); @@ -29,8 +45,11 @@ if (code) { getUserDate(authCode, code); } else { + var mode = 'openid corpid'; window.location.href = - 'https://login.dingtalk.com/oauth2/auth?redirect_uri=http://127.0.0.1:81/login&response_type=code&client_id=dingl5dxahaj3uzfug66&scope=oD9LphDV7Ge4vGgnIiS3WIwiEiE&state=dddd&prompt=consent'; + 'https://login.dingtalk.com/oauth2/auth?redirect_uri=http://127.0.0.1:81/login&response_type=code&client_id=dingl5dxahaj3uzfug66&scope=' + + encodeURIComponent(mode) + + '&state=dddd&prompt=consent'; // // STEP3锛氬湪闇�瑕佺殑鏃跺�欙紝璋冪敤 window.DTFrameLogin 鏂规硶鏋勯�犵櫥褰曚簩缁寸爜锛屽苟澶勭悊鐧诲綍鎴愬姛鎴栧け璐ョ殑鍥炶皟銆� // window.DTFrameLogin( // { -- Gitblit v1.8.0