zhanghua
2024-11-04 b3f465601308d5037c0ba24817eecf879638f928
钉钉登录bug修改
1个文件已修改
25 ■■■■ 已修改文件
src/views/dingdingLogin.vue 25 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/dingdingLogin.vue
@@ -11,15 +11,31 @@
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';
      } else {
        ElMessage({ message: '登录失败', type: 'error' });
        setTimeout(() => {
          window.location.href = '/login';
        }, 3000);
      }
    })
    .catch((e: any) => {
      setTimeout(() => {
        window.location.href = '/login';
      }, 3000);
  });
};
onMounted(() => {
@@ -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(
    //   {