收藏
回答

小程序录音权限问题?

  changeShow() {

        let that = this;

        uni.getSetting({

            success: (res) => {

                console.log('获取到的授权状态:', res.authSetting['scope.record']);

                if (res.authSetting['scope.record'] === undefined || !res.authSetting['scope.record']) {

                    // 用户尚未做出授权选择,或者已拒绝授权

                    uni.authorize({

                        scope: 'scope.record',

                        success: () => {

                            console.log('麦克风权限授权成功');

                            that.disabled = false;

                            // 可以继续录音操作

                        },

                        fail: () => {

                            console.log('麦克风权限授权失败');

                            uni.showModal({

                                title: '提示',

                                content: '您拒绝了麦克风权限,将无法使用录音功能。请前往微信设置页面开启麦克风权限。',

                                showCancel: false,

                                complete: () => {

                                    // 引导用户前往微信的全局设置页面手动开启权限

                                    uni.openSetting({

                                        success: (settingdata) => {

                                            console.log('设置页面返回的授权状态:', settingdata.authSetting['scope.record']);

                                            if (settingdata.authSetting['scope.record']) {

                                                console.log('用户已开启麦克风权限');

                                                that.disabled = false;

                                                // 可以继续录音操作

                                            } else {

                                                console.log('用户未开启麦克风权限');

                                                that.disabled = true;

                                                uni.showModal({

                                                    title: '提示',

                                                    content: '您未开启麦克风权限,将无法使用录音功能。请前往微信设置页面开启麦克风权限。',

                                                    showCancel: false

                                                });

                                            }

                                        }

                                    });

                                }

                            });

                        }

                    });

                } else {

                    // 用户已明确授权

                    console.log('已获取麦克风权限');

                    that.disabled = false;

                    // 可以继续录音操作

                }

            },

})

    },


体验版和开发都正常 , 正式版,uni.authorize没有调起弹窗,但是却直接进到了uni.authorize的fail

回答关注问题邀请回答
收藏

1 个回答

  • 3+5=8
    3+5=8
    06-01

    我也是一样的问题, 体验、 真机测试都可以的, 同样的代码, 为什么上线了就不行了

    06-01
    有用
    回复
登录 后发表内容