0

我有一个项目,它必须是一个包含条形码阅读器的表单的网页,但用户可以通过移动设备或 PC 使用它。我已经尝试过使用 QUAGGAJS,它允许我通过 PC 进行操作,但是当我在手机上打开它时它不起作用。你知道我该怎么做吗?下面是我的 QUAGGAJS,如果我必须更改某些内容才能使其适用于移动设备,或者即使我必须使用另一个库或其他东西


                        <!--AQUI EMPEZAMOS LA CONEXION CON QUAGGAJS-->

                        <script src="https://cdn.rawgit.com/serratus/quaggaJS/0420d5e0/dist/quagga.min.js"></script>
                        <script>
                            var sonido = new Audio("beep.mp3");

                            Quagga.init({
                                inputStream: {
                                    name: "Live",
                                    type:"LiveStream",
                                    target: document.querySelector('#fFolio')
                                },
                                frequency: 2,
                                decoder: {
                    readers: [
                        "code_128_reader",
                        "ean_reader",
                        "ean_8_reader",
                        "code_39_reader",
                        "code_39_vin_reader",
                        "codabar_reader",
                        "upc_reader",
                        "upc_e_reader",
                        "i2of5_reader"
                    ],
                                }
                            }, function(err){
                                if(err){
                                    console.log(err);
                                    console.log("Este error es por falta de camara")
                                    return
                                }
                                console.log("La inicializacion finalizo. Listo para empezar");
                                Quagga.start();
                            });

                            //AQUI SE DISENIA EL DIBUJO DEL ESCANER

                            Quagga.onProcessed(function(result){
                                var drawingCtx = Quagga.canvas.ctx.overlay,
                                drawingCanvas = Quagga.canvas.dom.overlay;

                                if(result){
                                    if(result.boxes){
                                        drawingCtx.clearRect(0, 0, parseInt(drawingCanvas.getAttribute('width')), parseInt(drawingCanvas.getAttribute("height")));
                                        result.boxes.filter(function(box){
                                            return box !== result.box;
                                        }).forEach(function(box){
                                            Quagga.ImageDebug.drawPath(box,{
                                                x: 0,
                                                y: 1
                                            }, drawingCtx, {
                                                color: "green",
                                                lineWidth: 2
                                            });
                                        });
                                    }

                                    if (result.box) {
                                        Quagga.ImageDebug.drawPath(result.box, {
                                            x: 0,
                                            y: 1
                                        }, drawingCtx,{
                                            color: "#00F",
                                            lineWidth: 2
                                        });
                                    }

                                    if (result.codeResult && result.codeResult.code) {
                                        Quagga.ImageDebug.drawPath(result.line, {
                                            x: 'x',
                                            y: 'y'
                                        }, drawingCtx,{
                                            color: 'red',
                                            lineWidth: 3
                                        });
                                    }
                                }
                            });

                        //QUE HARA SI ENCUENTRA UN CODIGO DE BARRAS

                        Quagga.onDetected(function(data){
                            sonido.play();
                            alrtify.success('' + data.codeResult.code);
                            var r = document.getElementById("numeroFolio");
                            r.value = data.codeResult.code;
                            console.log(data.codeResult.code);
                        });
                        </script> 
                        

4

0 回答 0