|
|
@@ -8,21 +8,14 @@ const store = new Vuex.Store({
|
|
|
token: '',
|
|
|
avatarUrl: '',
|
|
|
userName: '',
|
|
|
- userInfo:{
|
|
|
- avatar:''
|
|
|
- }
|
|
|
+ userInfo:null
|
|
|
},
|
|
|
getters: {
|
|
|
userInfo: state => {
|
|
|
- if(state.userInfo.avatar==''){
|
|
|
+ if(state.userInfo==null){
|
|
|
if(uni.getStorageSync('union_id')){
|
|
|
- api.getInfo().then(resdata => {
|
|
|
- if(resdata.data.code == 200){
|
|
|
- state.userInfo = resdata.data.data;
|
|
|
- }
|
|
|
- });
|
|
|
+ getUserInfo(state)
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
return state.userInfo
|
|
|
}
|
|
|
@@ -34,4 +27,10 @@ const store = new Vuex.Store({
|
|
|
|
|
|
}
|
|
|
})
|
|
|
+async function getUserInfo(state){
|
|
|
+ const resdata = await api.getInfo()
|
|
|
+ if(resdata.data.code == 200){
|
|
|
+ state.userInfo = resdata.data.data;
|
|
|
+ }
|
|
|
+}
|
|
|
export default store
|