使用uni.getUserProfile
获取用户信息。每次请求都会弹出授权窗口,用户同意后返回 userInfo,userInfo为用户的信息
// 获取用户信息
uni.getUserProfile({
desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
success: res => {
//保存头像
this.personalForm.picture = res.userInfo.avatarUrl;
}
});