wx.openSetting接口线上问题
发布于 6 年前 作者 xiulanyang 15470 次浏览 来自 问答
  • 当前 Bug 的表现(可附上截图)

上线后在wx.showModal中调用wx.openSetting接口,不会跳到设置页,但是测试的时候,在真机上测试,都是可以跳转到设置页的

我当时看了wx.openSettingAPI更新的官方说明,

这样写应该是没有问题的,为什么线上会跳不过去?????????

  • 预期表现
  • 复现路径

点击授权不能跳转到设置页

  • 提供一个最简复现 Demo

<view class=“intro” bindtap=“startRecord”>开始录音</view>

startRecord: function(){

let that = this;

wx.authorize({

scope: ‘scope.record’,

success() {

    console.log(“录音授权成功”);

},

fail() {

    console.log(“第一次录音授权失败”);

    wx.showModal({

        title: ‘提示’,

        content: ‘您未授权录音,功能将无法使用’,

        showCancel: true,

        confirmText: “授权”,

        confirmColor: “#52a2d8”,

        success: function (res) {

            if (res.confirm) {

            //确认则打开设置页面(重点)

                wx.openSetting({

                    success: (res) => {    

                        if (!res.authSetting[‘scope.record’]) {

                            //未设置录音授权

                            wx.showModal({

                                    title: ‘提示’,

                                    content: ‘您未授权录音,功能将无法使用’,

                                    showCancel: false,

                                    success: function (res) { },

                             })

                        } else {

                            console.log(“设置录音授权成功”);

                        }

                },

                fail: function () {

                    console.log(“授权设置录音失败”);

                }

            })

            } else if (res.cancel) {

                console.log(“cancel”);

            }

        },

    fail: function () {

        console.log(“openfail”);

    }

    })

    }

    })

}

1 回复

建议用

<button open-type="openSetting">打开授权设置页</button>

回到顶部