7

关于微信小程序 wx.login 和 wx.getUserInfo 调用的先后顺序 - 搞搞震

 3 years ago
source link: https://www.wujingquan.com/posts/b2d5ed34.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
关于微信小程序 wx.login 和 wx.getUserInfo 调用的先后顺序
wx.getUserInfo({
        success: res => {
            wx.login({
                success: data => {
                    wx.request({
                        url: 'https://example.com',
                        data: {
                            code: res.code,
                            encryptedData: data.encryptedData,
                            iv: data.iv
                        }
                    })
                }
            })
        }
})

wx.getUserInfo 调用之后才调用 wx.login,这种调用顺序,会出现概率性校验解密失败的问题。

最好的顺序是先调用 wx.login 再调用 wx.getUserInfo。

  1. 关于 wx.login 和 wx.getUserInfo 的先后顺序

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK