onLoad: function (options) {
this.get_record_auth()
},
get_record_auth(){
var that=this;
wx.getSetting().then(res=>{
if(res.authSetting['scope.record']){
that.setData({authed:true})
}
else{
wx.authorize({
scope: 'scope.record',
}).then(res=>{
that.setData({authed:true})
}).catch(err=>{
that.cancel_auth()
})
}
})
},
cancel_auth(){
var that=this;
wx.showModal({
title:'提示',
content:'未授权无法录音哦!',
concelText:'不授权',
confirmText:'去授权',
success:res=>{
if(res.confirm){
wx.openSetting({
success(res){
if(res.authSetting['scope.record']){
that.setData({authed:true})
}
}
}
)
}
}
})
}
好像是老的一些方法并不支持then的用法,试试回调写在success里试试呢?
wx.authorize({ scope: 'scope.record', success: res => {} })