<script>
	export default {
    globalData: {
      navbarHeight: 44,
    },
		onLaunch: async function() {
      this.globalData.navbarHeight = uni.getSystemInfoSync().safeArea.top

      uni.login({
        provider: 'weixin', //使用微信登录
        success: async (loginRes) => {
          try {
            const {token} = await this.$u.api.appletLogin({
              code: loginRes.code
            })
            this.$u.vuex('vuex_token', token)
            const { user } = await this.$u.api.getUserInfo()
            this.$u.vuex('vuex_user', user)
          } catch (err) {
            console.error(err)
          }
        },
        fail:err => {
          console.log(err)
        }
      });
      // const token = this.vuex_token ? this.vuex_token : uni.getStorageSync('lifeData')?.vuex_token;
      // if (token) {
      //   try {
      //     const { user } = await this.$u.api.getUserInfo()
      //     this.$u.vuex('vuex_user', user)
      //   } catch (err) {
      //     console.error(err)
      //   }
      // }
    },
		onShow: function() {
		},
		onHide: function() {
		}
	}
</script>

<style lang="scss">
	/*每个页面公共css */
	@import "uview-ui/index.scss";
</style>
