因为在微信小程序中wx.getuserInfo已经失效,所以我们在uniapp中也应该使用wx.getUserProfile来获取用户信息
页面的逻辑
- 一上来加载个人中心页,当用户点击未登录三个字时跳转登录页
- 登录页点击微信登录应该跳出授权弹窗获取用户的授权信息(使用wx.getUserProfile)
- 当用户点击同意授权时,应该将获取的用户信息使用同步或者异步存储存储到storage中(wx.setStorageSync),以便个人中心页使用,并且同时跳转到个人中心页(wx.reLaunch)
login.vue
getuserinfo(e) {
wx.getUserProfile({
desc:'用户完善个人信息',
success: (res) => {
// console.log(res)
let userInformation=res.userInfo
wx.setStorageSync(