小程序登录、用户信息相关接口调整后wx.getUserInfo接口可以直接调用吗?

小程序 文章 2021-03-10 10:41 75 0 全屏看文

小程序登录、用户信息相关接口调整后wx.getUserInfo接口可以直接调用吗?Can the wx.getUserInfo interface be called directly after the small program login and user information related interfaces are adjusted?

小程序登录、用户信息相关接口调整后wx.getUserInfo接口可以直接调用吗?

如题,调整前的wx.getUserInfo接口只能通过用户点击按钮来触发

        <Button          open-type='getUserInfo'          onGetUserInfo={this.handleConfirm}        >授权获取用户信息</Button>


调整后是否可以直接调用

    wx.getUserInfo({      success (res) {        console.log('getUserInfo res', res)      }    })


我在本地调试工具中试了下,截止到2021-03-09应该还不能直接调用,还是需要点击按钮触发(指定open-type)。是不是在2021年4月13日后wx.getUserInfo接口就可以直接调用了?

建议可以直接调用,不依赖用户点击按钮触发,否则调整后如果要同时获取用户的openId和真实昵称,那么还得让用户点击按钮调用getUserProfile接口

Before adjustment wx.getUserInfo The interface can only trigger < button open type = getUserInfo 'ongetuserinfo' by clicking the button={ this.handleConfirm }> authorization to obtain user information < / button > can it be directly called after adjustment wx.getUserInfo ({ success (res) { console.log ('getUserInfo res', res) } }) I tried in the local debugging tool. As of March 9, 2021, it should not be called directly, or it needs to be triggered by clicking the button (specify open type). Is it after April 13, 2021 wx.getUserInfo Interface can be called directly? It is recommended that it can be called directly without the user clicking the button to trigger. Otherwise, if you want to get the user's openid and real nickname at the same time after adjustment, you have to let the user click the button to call the getuserprofile interface

回答:

陈宇明:

一定需要用户点击触发

|G.XIAO|:

大兄弟,还是要多研究下为啥这样做。我们也不能一股脑获取所有信息,应该是按需获取。

dhy:谢谢老哥提醒,如果只是在页面上展示还好,但是就是怕产品和业务要一股脑的获取所有信息。
默垂眸:

不能直接触发 也不是必须要按钮触发

使用点击事件调用


-EOF-