Doctor.vue 2.26 KB
<template>
    <van-config-provider :theme-vars='themeVars' class="h-full">
        <div class='h-full resident-home'>
            <router-view v-slot='{ Component }'>
                <Transition name='route' mode='out-in'>
                    <component :is='Component' v-if='visible' />
                </Transition>
            </router-view>
        </div>
    </van-config-provider>
</template>

<script>
import { getDict } from '@/api/base.js'
import { useStore } from './store/index.js'
import { backHome, getQueryVariable } from '@/utils/common'
import { getAuthInfo } from '@/api/doctor/generalFU'

export default {
    data() {
        return {
            visible: false,
            themeVars: {
                primaryColor: '#607FF0',
                buttonPrimaryBackground: '#607FF0',
                buttonPrimaryBorderColor: '#607FF0',
                buttonDefaultBorderColor: '#BFBFBF',
                buttonNormalFontSize: '.16rem',
                loadingSpinnerColor: '#607FF0',
                // tab
                tabActiveTextColor: '#607FF0',
                tabTextColor: '#8C8C8C',
                tabsBottomBarColor: '#607FF0',
                // 表单相关
                cellVerticalPadding: '.15rem',
                cellTextColor: '#262626',
                cellBorderColor: '#d9d9d9',
                navBarIconColor: '#262626'
            }
        }
    },
    setup() {
        const store = useStore()
        return { store }
    },
    created() {
        this.init()
    },
    methods: {
        async init() {
            let token = getQueryVariable('token')
            if (!token) {
                token = sessionStorage.getItem('token')
                if (process.env.NODE_ENV !== 'production') {
                    token = '4ef7a32e-c217-44b6-ac5d-8ad9a91d38a0'
                }
            }
            if (token) {
             sessionStorage.setItem('token', token)
                const res = await getDict()
                this.store.$patch({ dict: res.data || {} })
                const user = await getAuthInfo()
                this.store.$patch({authInfo: user.data || {}})

                this.visible = true
            } else {
                backHome()
            }

        }
    }
}
</script>

<style lang='less' scoped>

</style>