<script>
export default {
  onLaunch: function () {
    const init = () => {
      this.$store.commit('getSysInfo')
      this.$store.dispatch('getAppConfig')
      // this.$store.dispatch('getNotices')
    }

    const watchNetwork = ({ isConnected }) => {
      if (!isConnected) return // 当发现有网络时
      init() // 初始化
      // uni.$emit('initIndex') // 通知首页也重新加载
      uni.offNetworkStatusChange(watchNetwork) // 取消监听
    }

    uni.getNetworkType({
      success: ({ networkType }) => {
        switch (networkType) {
          case 'none':
            uni.onNetworkStatusChange(watchNetwork) // 监听网络状态
            break
          default:
            init()
            break
        }
      }
    })
  }
  /*onShow: function () {
    console.log('App Show')
  },
  onHide: function () {
    console.log('App Hide')
  }*/
}
</script>

<style lang="scss">
/*每个页面公共css */
/* 注意要写在第一行，同时给style标签加入lang="scss"属性 */
@import '@/uni_modules/uview-ui/index.scss';
@import 'static/styles/public.scss';
@import '@/static/styles/iconfont/iconfont.css';
</style>
