-
Notifications
You must be signed in to change notification settings - Fork 1
/
app1.js
61 lines (44 loc) · 1.22 KB
/
app1.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
var app1 = new Vue({
el: '#app1',
data: {
scanner: null,
activeCameraId: null,
cameras: [],
scans: []
},
mounted: function () {
var self = this;
self.scanner = new Instascan.Scanner({ video: document.getElementById('preview'), scanPeriod: 5 });
self.scanner.addListener('scan', function (content, image) {
self.scans.unshift({ content: content });
var SoundScan = new Audio();
SoundScan.src = "scannerAlert.mp3";
SoundScan.play();
details();
function details(){
window.navigator.vibrate(500);
var id=content;
window.location = "qrcode_confirm.php?id="+id;
}
});
Instascan.Camera.getCameras().then(function (cameras) {
self.cameras = cameras;
if (cameras[1]) {
scanner.start(cameras[1]);
} else {
console.error('No cameras found.');
}
}).catch(function (e) {
console.error(e);
});
},
methods: {
formatName: function (name) {
return name || '(unknown)';
},
selectCamera: function (camera) {
this.activeCameraId = camera.id;
this.scanner.start(camera);
}
}
});