zhanghua
2 天以前 396b9a06392db5736eb5a7d485879174d73bb39a
补签
1个文件已添加
66 ■■■■■ 已修改文件
src/views/rztLogin.vue 66 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/rztLogin.vue
New file
@@ -0,0 +1,66 @@
<template>
  <div id="content" class="content">
  </div>
</template>
<script setup name="Oss" lang="ts">
import { useRoute } from 'vue-router';
import { rztLogin } from '@/api/system/user';
import { setToken, removeToken,setPlat } from '@/utils/auth';
import { ElMessage } from 'element-plus';
import { any } from 'vue-types';
const getUserData = async (code: string) => {
  await rztLogin({
    code: code
  })
    .then((res: any) => {
      console.log("____________res:" + JSON.stringify(res));
      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 = '/rzt_login';
        }, 3000);
      }
    })
    .catch((e: any) => {
      setTimeout(() => {
        window.location.href = '/rzt_login';
      }, 3000);
    });
};
onMounted(() => {
  setPlat('rzt');
  removeToken()
  const router = useRoute();
  let code = router.query.code;
  if (code) {
    getUserData(code);
  } else {
    var mode = 'openid corpid';
    window.location.href =
      // 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=ww9904fd98c1b0df9e&redirect_uri=http://171.221.173.53:8801/rzt_login&response_type=code&scope=SCOPE&agentid=1000128&state=STATE#wechat_redirect';
      'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wwa1a67ed0008261d9&redirect_uri=' + encodeURI('http://171.221.173.53:8801/rzt_login') + '&response_type=code&scope=SCOPE&agentid=1000414&state=STATE#wechat_redirect';
  }
});
</script>
<style lang="scss" scoped>
.content {
  display: flex;
  align-items: center;
  justify-content: center;
}
.self-defined-classname {
  // width: 300px;
  // height: 300px;
}
</style>