已解决
麦克风首次授权弹出两次let that = this let options = { scope: 'scope.record', content: '请前往设置页打开麦克风' } return new Promise((resolve, reject) => { wx.getSetting({ success: function (res) { let auth = res.authSetting['scope.scope'] console.log(auth); if (auth === true) { //已授权 that.start() } else if (auth === undefined) { // 首次授权 wx.authorize({ scope: options.scope, success() { resolve(true) }, fail(res) { } }) } else if (!res.authSetting['scope.record']) { //麦克风再次授权 console.log(169); wx.showModal({ title: '提示', content: '您未授权录音功能,是否授权?', showCancel: true, success: (res) => { if (res.confirm) { //确认 wx.openSetting({ success: (setRes) => { if (settingRes.authSetting[options.scope]) { resolve(true) } }, fail: (setRes) => { console.log(setRes); } }) } else if (res.cancel) { //取消 wx.showModal({ title: '提示', content: '授权失败', showCancel: false, }) } } }) } } }) })
2022-08-26