<script>
import config from './config'
import store from '@/store'
import { getAccessToken } from '@/utils/auth'

export default {
  onLaunch: function () {
    this.initApp()
  },
  methods: {
    // 初始化应用
    async initApp() {
      await uni.hideTabBar()
      uni.hideTabBar({
        animation: false
      })
      // 初始化应用配置
      this.initConfig()
      // 检查用户登录状态
      this.checkLogin()
    },
    initConfig() {
      this.globalData.config = config
    },
    checkLogin() {
      if (!getAccessToken()) {
        this.$tab.reLaunch('/pages/login')
      } else {
        this.$store.dispatch('GetInfo')
      }
    }
  }
}
</script>

<style lang="scss">
@import '@/uni_modules/windi-css-uniapp/index.scss';
@import '@/static/scss/index.scss';
</style>
