WeChat Mini Program Project_Qiu Bo Optimal 53

49. Login page _ get user information

pages\login\index.json

{
    
    
  "usingComponents": {
    
    },
  "navigationBarTitleText": "登录"
}

pages\login\index.wxml

<button type="primary" plain>登录</button>

pages\login\index.wxss

button{
    
    
    margin-top: 40rpx;
    width: 70%;
}

Insert picture description here
Get user information

<button type="primary" plain open-type="getUserInfo" bindgetuserinfo="handleGetUserInfo">登录</button>

Insert picture description here
Insert picture description here
Insert picture description here
pages\login\index.js

Page({
    
    
  handleGetUserInfo(e){
    
    
    //console.log(e);

    const {
    
    userInfo}=e.detail;
    wx.setStorageSync( "userinfo", userInfo);
    wx.navigateBack({
    
    
      delta: 1
    });
  }
})

pages\user\index.wxml

<navigator url="/pages/login/index">登录</navigator>

Clear all caches——>From the personal center (there is nothing in the Storage storage cache)——>Login——>Jump to the login page——>Login button——>WeChat permission allowed (there is also data in the cache at this time ) The
Insert picture description here
login page function is completed

Guess you like

Origin blog.csdn.net/cpcpn/article/details/108684942