<template> 
 | 
    <div class="auth"> 
 | 
        <div class="auth_loading" v-if="status == 1"> 
 | 
            <van-loading size="50px" color="#1989fa" /> 
 | 
            <span>正在登录,请稍后...</span> 
 | 
        </div> 
 | 
        <div class="auth_err" v-if="status == 2"> 
 | 
            <img src="@/assets/icon/default_404@2x.png" alt="" /> 
 | 
            <span>页面登录失败</span> 
 | 
            <button @click="login">点击重试</button> 
 | 
        </div> 
 | 
        <div class="auth_permissions" v-if="status == 3"> 
 | 
            <img src="@/assets/icon/default_loginfailed@2x.png" alt="" /> 
 | 
            <span>您的账号授权登录失败,请联系管理员</span> 
 | 
            <button>点击返回EDGP</button> 
 | 
        </div> 
 | 
    </div> 
 | 
  </template> 
 | 
   
 | 
  <script setup lang="ts"> 
 | 
    import { ref, onMounted } from 'vue' 
 | 
    import { useRouter } from 'vue-router' 
 | 
    import { useStore } from 'vuex' 
 | 
    import { lingyangLogin, getUserInfo } from '@/apis/index' 
 | 
    import { Toast } from "vant" 
 | 
   
 | 
    const store = useStore() 
 | 
    const router = useRouter() 
 | 
    let status = ref(1) 
 | 
    let data: any = ref({}) 
 | 
  
 | 
    const login = () => { 
 | 
        status.value = 1 
 | 
        lingyangLogin(data.value) 
 | 
            .then(async(res) => { 
 | 
                if (res.code === 200) { 
 | 
                    let info: any = await getUserInfo() 
 | 
                    if (info.code === 200) { 
 | 
                        await store.commit('setUserInfo', info.data) 
 | 
                        await store.commit('setCompany', 'noLogin') 
 | 
                        await store.dispatch('getMenuList', 2) 
 | 
                        await router.replace('/workbench') 
 | 
                    } else { 
 | 
                        Toast.fail(info.message) 
 | 
                        status.value = 2 
 | 
                    } 
 | 
                } else { 
 | 
                    Toast.fail(res.message) 
 | 
                    status.value = 2 
 | 
                } 
 | 
            }) 
 | 
            .catch(err => { 
 | 
                Toast.fail(err.message) 
 | 
                status.value = 2 
 | 
            }) 
 | 
    } 
 | 
  
 | 
    onMounted(() => { 
 | 
        store.commit('setEntrance', 'DD') 
 | 
        let query = window.location.href.split('?')[1].split('&') 
 | 
        query.forEach(item => { 
 | 
            let subQuery = item.split('=') 
 | 
            data.value[subQuery[0]] = subQuery[1] 
 | 
        }) 
 | 
        login() 
 | 
    }) 
 | 
  </script> 
 | 
   
 | 
  <style lang="scss" scoped> 
 | 
  .auth { 
 | 
    width: 100vw; 
 | 
    height: 100vh; 
 | 
    display: flex; 
 | 
    align-items: center; 
 | 
    justify-content: center; 
 | 
    background: white; 
 | 
    .auth_permissions { 
 | 
        display: flex; 
 | 
        align-items: center; 
 | 
        flex-direction: column; 
 | 
        img { 
 | 
            width: 400px; 
 | 
            height: 400px; 
 | 
        } 
 | 
        span { 
 | 
            font-size: 28px; 
 | 
            font-family: PingFangSC-Regular, PingFang SC; 
 | 
            font-weight: 400; 
 | 
            color: #222222; 
 | 
            margin-top: 10px; 
 | 
        } 
 | 
        button { 
 | 
            width: 272px; 
 | 
            height: 72px; 
 | 
            line-height: 72px; 
 | 
            text-align: center; 
 | 
            background: #216EEE; 
 | 
            border-radius: 4px; 
 | 
            font-size: 28px; 
 | 
            font-family: SourceHanSansSC-Regular, SourceHanSansSC; 
 | 
            font-weight: 400; 
 | 
            color: #FFFFFF; 
 | 
            border: none; 
 | 
            margin-top: 60px; 
 | 
        } 
 | 
    } 
 | 
    .auth_err { 
 | 
        display: flex; 
 | 
        align-items: center; 
 | 
        flex-direction: column; 
 | 
        img { 
 | 
            width: 400px; 
 | 
            height: 400px; 
 | 
        } 
 | 
        span { 
 | 
            font-size: 28px; 
 | 
            font-family: PingFangSC-Regular, PingFang SC; 
 | 
            font-weight: 400; 
 | 
            color: #222222; 
 | 
            margin-top: 10px; 
 | 
        } 
 | 
        button { 
 | 
            width: 272px; 
 | 
            height: 72px; 
 | 
            line-height: 72px; 
 | 
            text-align: center; 
 | 
            background: #216EEE; 
 | 
            border-radius: 4px; 
 | 
            font-size: 28px; 
 | 
            font-family: SourceHanSansSC-Regular, SourceHanSansSC; 
 | 
            font-weight: 400; 
 | 
            color: #FFFFFF; 
 | 
            border: none; 
 | 
            margin-top: 60px; 
 | 
        } 
 | 
    } 
 | 
    .auth_loading { 
 | 
        display: flex; 
 | 
        align-items: center; 
 | 
        flex-direction: column; 
 | 
        span { 
 | 
            font-size: 14px; 
 | 
            font-family: PingFangSC-Regular, PingFang SC; 
 | 
            font-weight: 400; 
 | 
            color: #222222; 
 | 
            margin-top: 20px; 
 | 
        } 
 | 
    } 
 | 
  } 
 | 
  </style> 
 | 
   
 |