微信小程序如何自动弹出提示微信授权?

clipboard.png
我想在一进入页面的时候就进行判断提示并且弹出提示授权!
请问该如何处理比较合理

wx.authorize({})

//可以通过 wx.getSetting 先查询一下用户是否授权了 "scope.record" 这个 scope
wx.getSetting({

success(res) {
    if (!res.authSetting['scope.record']) { wx.authorize({ scope: 'scope.record', success() { // 用户已经同意小程序使用录音功能,后续调用 wx.startRecord 接口不会弹窗询问 wx.startRecord() } }) } }

})

文档里有的 https://developers.weixin.qq.com/miniprogram/dev/api/authorize.html


微信小程序授权获取用户详细信息openid的实例详解

http://www.jb51.net/article/124132.htm

猜你喜欢

转载自www.cnblogs.com/kenshinobiy/p/9118056.html