<template>
    <div v-loading="loading" class="hc-body-loading" element-loading-text="加载中...">
        <div v-if="isErrorShow" class="error-page">
            <div :style="`background-image: url(${svgdev});`" class="img" />
            <div class="content">
                <h1>300</h1>
                <div class="desc">请先指定要跳转的地址</div>
            </div>
        </div>
    </div>
</template>

<script setup>
import { onMounted, ref } from 'vue'
import { useAppStore } from '~src/store'
import { useRoute, useRouter } from 'vue-router'
import { getObjValue, isNullES } from 'js-fast-way'
import svgdev from '~ass/view/dev.svg'

//初始变量
const router = useRouter()
const useRoutes = useRoute()
const store = useAppStore()

//变量
const loading = ref(true)
const isErrorShow = ref(false)

//渲染完成
onMounted(() => {
    // http://计量的域名/#/auth-page?pid=xxx&cid=xxx&layout=no&url=xxx
    const { pid, cid, layout, url } = getObjValue(useRoutes.query)
    if (!isNullES(url)) {
        isErrorShow.value = false
        //缓存数据
        store.setProjectId(pid)
        store.setContractId(cid)
        store.setIsLayout(layout)
        //跳转
        setTimeout(() => {
            loading.value = false
            router.push({ path: url })
        }, 200)
    } else {
        loading.value = false
        isErrorShow.value = true
    }
})
</script>

<style lang="scss" scoped>
@import "../../styles/error/style.scss";
.hc-body-loading {
    position: relative;
    height: 100%;
    width: 100%;
}
</style>
