diff --git a/App.vue b/App.vue index 4d95363..fb72a82 100644 --- a/App.vue +++ b/App.vue @@ -32,10 +32,22 @@ // } await this.$store.dispatch('initData') console.log('配置数据初始化完成') + + if(uni.getStorageSync('token')){ + this.getUserInfo() + } }, onHide: function() { console.log('App Hide') - } + }, + async getUserInfo() { + const res = await this.$api.login.getUserInfo(); + if (res.code === 200) { + this.userInfo = res.result; + // 存储用户信息到store + this.$store.dispatch('updateUserInfo', this.userInfo) + } + }, } diff --git a/stores/index.js b/stores/index.js index 3f8e3ce..fe30112 100644 --- a/stores/index.js +++ b/stores/index.js @@ -64,7 +64,8 @@ const store = new Vuex.Store({ setUserInfo(state, data) { state.userInfo = data // #ifdef H5 - localStorage.setItem('userInfo', data) + localStorage.setItem('userInfo', JSON.stringify(data)) + share() // #endif }, setQrcode(state, data) { diff --git a/subPages/login/login.vue b/subPages/login/login.vue index 0e9f6e3..b2a2f20 100644 --- a/subPages/login/login.vue +++ b/subPages/login/login.vue @@ -63,9 +63,6 @@