touchstart() { wx.getSetting({ success(res) { if (!res.authSetting['scope.record']) { wx.authorize({ scope: 'scope.record', success() {// 用户已经同意小程序使用录音功能,后续调用 wx.startRecord 接口不会弹窗询问 wx.startRecord({ success(res) { const tempFilePath = res.tempFilePath console.log(tempFilePath, '文件') } }) }, fail(error) { console.log(error, '获取录音授权失败!') } }) } } }) },
先说一下出现这个情况的原因,第一次拒绝授权之后,后面在拉取录音的权限时就没有反应了,错误码为12006
要么清除小程序缓存,要么提示用户手动到设置里面开启权限