收藏
回答

wx.authorize 接口的本地调试表现与手机端不一致

问题模块 框架类型 问题类型 操作系统 工具版本
开发者工具 小程序 Bug macOS 1.02.1809260
openMap: function () {
    wx.getSetting({
        success: (res) => {
            let locationAuth = res.authSetting['scope.userLocation']
            if(!locationAuth) {
                wx.authorize({
                    scope: 'scope.userLocation',
                    success: (res) => {
                        wx.navigateTo({
                            url: '/pages/map/map',
                        })
                    },
                    fail: (res) => {
                        wx.showModal({
                            title: '需要地理位置授权',
                            content: '',
                            confirmText: this.data.authBtnText,
                            success: (res) => {
                                if(res.confirm) {
                                    wx.openSetting({
 
                                    })
                                }
                            }
                        })
                    }
                })
            } else {
                wx.navigateTo({
                    url: '/pages/map/map',
                })
            }
        }
    })
}



按照新规则使用 bindtap='openMap' 触发授权,wx.showModal() 放在 wx.authorize() 外面可以通过 confirm 回调成功调用 wx.openSetting() 呼出设置页面,但是如上面的代码一样放在 wx.authorize() 的 fail 回调分支中的话,则在开发工具中调用 wx.openSetting() 无响应,但在手机端仍然可正常呼出设置页面

回答关注问题邀请回答
收藏
登录 后发表内容