<template>
    <div>
        <span>Welcome to the Submission system</span>
    </div>
</template>

<script>
export default {
    data() {
        return {
            journal: this.$route.query.journal,
            abbr: this.$route.query.abbr
        };
    },
    async created() {
        var journal_id;
        var journal_id_abbr;
        if (this.abbr) {
            journal_id_abbr = await this.getJournalByAbbr();
        }

        if (this.journal) {
            journal_id = await this.getJournalByAlias();
        }

        setTimeout(() => {
           
            if (journal_id_abbr) {
                localStorage.setItem('ms_journal_alias', journal_id_abbr);
            } else if (journal_id) {
                localStorage.setItem('ms_journal_alias', journal_id);
            }
            this.$router.push('/');
        }, 1000);
    },
    methods: {
        async getJournalByAlias() {
            var data;
            await this.$api.post('api/Article/getJournalByAlias', { alias: this.journal }).then((res) => {
                data = res.journal_id;
            });
            return data;
        },
        async getJournalByAbbr() {
            var data;
            await this.$api.post('api/Article/getJournalByAbbr', { abbr: this.abbr }).then((res) => {
                // localStorage.setItem('ms_journal_alias', res.journal_id);
                data = res.data.detail ? res.data.detail.journal_id : null;
            });
            return data;
        }
    }
};
</script>
