<template>
    <div></div>
</template>
<script>
import { getQueryObjectSearch } from '@/utils'
import { addCorpDoAuth } from "@/api/accounts/corpWeChat";
export default {
    name: 'corpDoAuth',
    data() {
        return {

        }
    },
    created() {
        let query = getQueryObjectSearch()
        if (Object.keys(query).length > 0) {
            const loading = this.$loading({
                lock: true,
                text: '正在授权，请稍后。。。',
                spinner: 'el-icon-loading',
                background: 'rgba(0, 0, 0, 0.8)'
            });
            console.log(query);
            addCorpDoAuth({ authCode: query.auth_code, expiresIn: query.expires_in, state: query.state }).then(response => {
                loading.close();
                console.log('response----->', response);
                let data = response.data
                if (data) {
                    localStorage.setItem("corpAdMp", "ok");
                } else {
                    localStorage.setItem("corpAdMp", "false");
                    return
                }
                setTimeout(() => {
                    window.close()
                }, 200)
            }).catch(() => loading.close())
        }
    }
}
</script>