微信小程序录音权限设置
methods: {
recordShow(e) {
var that = this;
uni.getSetting({
success(res) {
// console.log(res.authSetting['scope.record']);
//判断是否第一次获取录音功能
if (!res.authSetting['scope.record']) {
//调用后会立刻弹窗询问用户是否同意授权录音给小程序
uni.authorize({
scope: 'scope.record',
success() {
// 用户已经同意小程序使用录音功能,后续调用 wx.startRecord 接口不会弹窗询问
uni.startRecord()
}
})
//判断录音是否是开启状态false没开启就跳转到开启页面
if (res.authSetting['scope.record'] == false) {
uni.openSetting({
success(res) {
console.log(res.authSetting)
}
});
}
} else if (res.authSetting['scope.record'] == true) {
that.show = true;
console.log(e.currentTarget.dataset.id);
that.current = e.currentTarget.dataset.id;
}
}
})
},
}