Sfoglia il codice sorgente

fix: 注册成功后重新获取用户信息更新realName

Developer 4 giorni fa
parent
commit
f5afeda30e
1 ha cambiato i file con 14 aggiunte e 3 eliminazioni
  1. 14 3
      common/stores/user.js

+ 14 - 3
common/stores/user.js

@@ -35,9 +35,20 @@ export const useUserStore = defineStore('user', {
 						resolve(false)
 						return
 					}
-					// 注册成功,进入第二步添加孩子
-					this.registerStep = 2;
-					resolve(true)
+					// 注册成功,重新获取用户信息更新 realName 等字段
+					api.get('/wx/userWelfareData', {}).then(({data:welfareRes}) => {
+						if(welfareRes.code === 0) {
+							this.userInfo = {...this.userInfo, ...welfareRes.data};
+							uni.setStorageSync('userInfo', JSON.stringify(this.userInfo));
+						}
+						// 进入第二步添加孩子
+						this.registerStep = 2;
+						resolve(true)
+					}).catch(() => {
+						// 即使获取失败也继续流程
+						this.registerStep = 2;
+						resolve(true)
+					})
 				})
 			});
 		},