<template>
|
<div class="box">
|
<div class="box_content" v-show="show" @click="LOGIN">
|
<img src="@/assets/icon/loginError.png" alt="" />
|
<span>登录失败,请点击重新登录</span>
|
</div>
|
</div>
|
</template>
|
|
<script setup lang="ts">
|
import { onMounted, getCurrentInstance, ref } from 'vue'
|
import { ddLogin, getUserInfo, testLogin, getDingdingCorpId } from "@/apis"
|
import { Toast } from "vant"
|
import { useStore } from "vuex"
|
import { useRouter } from "vue-router"
|
const { proxy }: any = getCurrentInstance()
|
|
const store = useStore()
|
|
const router = useRouter()
|
|
let show = ref<boolean>(false)
|
|
const LOGIN = async () => {
|
show.value = false
|
// 判断如果是从钉钉进入,执行登录操作
|
// if (proxy.$dd.env.platform == 'notInDingTalk') {
|
// process.env.VUE_APP_COMPANYID
|
if (proxy.$dd.env.platform !== 'notInDingTalk') {
|
if (store.state.companyId !== 'noLogin') {
|
getDingdingCorpId(store.state.companyId)
|
.then(dataCode => {
|
if (dataCode.code === 200) {
|
proxy.$dd.runtime.permission.requestAuthCode({
|
corpId: dataCode.data,
|
onSuccess: async (result: any) => {
|
let res: any = await ddLogin({ code: result.code, companyId: store.state.companyId })
|
if (res.code === 200) {
|
let info: any = await getUserInfo()
|
if (info.code === 200) {
|
await store.commit('setEntrance', 'DD')
|
await store.commit('setUserInfo', info.data)
|
await store.dispatch('getMenuList', 2)
|
await router.go(-1)
|
} else {
|
Toast.fail(info.message)
|
show.value = true
|
}
|
} else {
|
Toast.fail(res.message)
|
show.value = true
|
}
|
},
|
onFail: (err: any) => {
|
show.value = true
|
console.log(err)
|
Toast.fail('钉钉登录失败')
|
}
|
})
|
}
|
})
|
}
|
} else {
|
// let res = await testLogin({
|
// username: 'manager',
|
// password: '1',
|
// companyId: '1',
|
// uuid: '0000',
|
// code: '0000'
|
// })
|
|
// let res = await testLogin({
|
// username: '15395136032',
|
// password: '123456',
|
// companyId: '4',
|
// uuid: '0000',
|
// code: '0000'
|
// })
|
|
// let res = await testLogin({ // 英子姐
|
// username: '18055151023',
|
// password: '123456',
|
// companyId: '1',
|
// uuid: '0000',
|
// code: '0000'
|
// })
|
// let res = await testLogin({ // 大栓
|
// username: '18019924213',
|
// password: '123456',
|
// companyId: '1',
|
// uuid: '0000',
|
// code: '0000'
|
// })
|
let res = await testLogin({ // 文武
|
username: '18656077929',
|
password: '123456',
|
companyId: '8',
|
uuid: '0000',
|
code: '0000'
|
})
|
// let res = await testLogin({ // 胡克东
|
// username: '17751132561',
|
// password: '123456',
|
// companyId: '1',
|
// uuid: '0000',
|
// code: '0000'
|
// })
|
|
// let res = await testLogin({
|
// username: '15056231084',
|
// password: '123456',
|
// companyId: '1',
|
// uuid: '0000',
|
// code: '0000'
|
// })
|
if (res.code === 200) {
|
window.localStorage.setItem('token', res.data)
|
let info: any = await getUserInfo()
|
if (info.code === 200) {
|
await store.commit('setEntrance', 'H5')
|
await store.commit('setUserInfo', info.data)
|
await store.dispatch('getMenuList', 2)
|
await router.go(-1)
|
} else {
|
show.value = true
|
Toast.fail(res.message)
|
}
|
} else {
|
show.value = true
|
Toast.fail(res.message)
|
}
|
}
|
}
|
|
onMounted(async () => {
|
LOGIN()
|
})
|
</script>
|
|
<style lang="scss" scoped>
|
.box {
|
width: 100%;
|
position: absolute;
|
height: 100%;
|
background: white;
|
.box_content {
|
position: absolute;
|
top: 50%;
|
left: 50%;
|
transform: translate(-50%, -50%);
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
flex-direction: column;
|
img {
|
width: 200px;
|
height: 200px;
|
}
|
span {
|
font-size: 28px;
|
margin-top: 20px;
|
}
|
}
|
}
|
</style>
|