QRScanner

头像
temp
2019-11-15阅读 41
        QRScanner.prepare(onDone); // show the prompt
function onDone(err, status){
if (err) {
alert('启动出错:' + JSON.stringify(err));
console.error(err);
}
if (status.authorized) {
QRScanner.scan(displayContents);
function displayContents(err, text) {
if(err) {
alert('启动扫描出错:' + JSON.stringify(err));
} else {
// The scan completed, display the contents of the QR code:
alert(text);
}
}
//开始扫描,需要将页面的背景设置成透明
QRScanner.show(function(err, text){
debugger
});
} else if (status.denied) {
// The video preview will remain black, and scanning is disabled. We can
// try to ask the user to change their mind, but we'll have to send them
// to their device settings with `QRScanner.openSettings()`.
} else {
// we didn't get permission, but we didn't get permanently denied. (On
// Android, a denial isn't permanent unless the user checks the "Don't
// ask again" box.) We can ask again at the next relevant opportunity.
}
}