uniapp 拒绝调用相机怎么再次唤起提示打开权限
<camera v-if="isShow" style="height: 520rpx" mode="scanCode" device-position="back" flash="off" @scancode="takeCode">
</camera>
data() {
return {
isShow:false,
}
}
onShow() {
let that = this
uni.getSetting({
success(res) {
if (!res.authSetting['scope.camera']) {
uni.authorize({
scope: 'scope.camera',
success(res) {
// 授权成功
uni.showToast({
title: '授权成功',
icon: 'none'
})
that.isShow = true
},
fail() {
uni.showModal({
content: '检测到您没打开获取相机功能权限,是否去设置打开?',
confirmText: "确认",
cancelText: '取消',
success: (res) => {
if (res.confirm) {
uni.openSetting({
success: (res) => {
uni.showToast({
title: '授权成功',
icon: 'none',
duration:2000
})
},
fail: (err) => {
console.log(err)
}
})
} else {
uni.showToast({
title: '获取授权相机授权失败',
icon: 'none',
success: function() {
uni.navigateBack()
}
})
}
}
})
}
})
}else{
that.isShow = true
}
},
fail() {
uni.showToast({
title: '获取授权相机授权失败',
icon: 'none',
success: function() {
uni.navigateBack()
}
})
}
})
},

浙公网安备 33010602011771号