Applet user authorization login

With the help of the API provided by WeChat in the Mini Program, users can quickly authorize and log in, reduce user registration costs, and better retain users.

Get user information

  • wx.getUserProfile
  • wx.getUserInfo

None of the above interfaces can be used, see the official announcement for details .

individual subject

Obtain the code through wx.login, then obtain the openid through the server, and use openid for user identification.

Business entity

Business principals no longer need to call wx.login in advance to log in. With the help of the open-type of the WeChat applet button, the code is obtained in the callback function and passed to the server in exchange for the WeChat user's information. The applet whose main type is an enterprise can obtain the user's mobile phone number.

Currently, this interface is open to non-individual developers and mini programs that have completed certification (excluding overseas entities)

<button open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber"></button>

// 拉起微信获取手机号弹框

Page({
    
    
  getPhoneNumber (e) {
    
    
    console.log(e.detail.code)
    // todo 把code传到服务端去获取微信提供的接口
  }
})

Server

After the server obtains the mobile phone number of the WeChat user, it can issue a token as the basis for judging the login status of the mini program.

Guess you like

Origin blog.csdn.net/IICOOM/article/details/129159679