<script>
import { mapActions, mapState } from 'vuex';

export default {
  async onLaunch(options) {
    console.log('App Launch', options);
    if (!this.token) {
      // 不论有没有token都直接从userId获取token
      // token有过期时间 从本地获取可能是过期 干脆直接从userId获取
      if (!options.query || !options.query.u) {
        // 参数里没有u (userId)提示
        this.$t.ui.showToast('缺少用户信息参数');
      } else {
        await this.getToken(options.query.u);
      }
    }
  },
  onShow: function () {
    console.log('App Show');
  },
  onHide: function () {
    console.log('App Hide');
  },

  computed: mapState('user', ['token']),

  methods: { ...mapActions('user', ['getToken']) },
};
</script>

<style lang="scss">
@import './common/styles/iconfont.scss';
@import 'uview-ui/index.scss';
</style>
