Mr.Shi
2023-08-11 b15a83329e33a954f41c9558b58aa1a64332c46b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<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>