Android手机不会弹出授权框
发布于 5 年前 作者 jkong 10362 次浏览 来自 问答

需求上是要实现弹出用户授权框 用户在点击了“允许”后跳转到指定的页面,在iOS和开发者工具的模拟器上运行都是没问题的。在安卓手机上就会出现不弹出授权框 直接跳转到该页面的情况。

开发者工具版本:1.02.1803210 (当前最新)

代码如下:

wx.getUserInfo({

fail   : res =>{

// debugger

console.log(res);

},

success: res => {

// debugger

app.globalData.userInfo = res.userInfo

this.setData({

userInfo: res.userInfo,

hasUserInfo: true

})

if (!app.globalData.isHasPhone){

//授权成功 跳转到某个页面

wx.navigateTo({

url: '…/xxx/xxx,

})

}

}

})

4 回复

手机之前没有授权 每次测试我都是先清除缓存然后再扫描二维码的

我用安卓手机测试 出现两种情况: 1、 输出为false 发现在小程序的设置界面上“用户信息”为关闭

                                                         2、 当我把设置中的用户信息打开之后 重新清楚缓存 扫描二维码进行测试 输出结果为true 没有弹出授权框 直接跳转到我要跳转的页面中……

wx.getSetting({

success: (res) => {

console.log(res.authSetting[‘scope.userInfo’])

}

})

把这个打出来看看

是不是这个手机之前授过权呢

回到顶部