gpt4 book ai didi

javascript - 如何更改 Phonegaps 条码扫描仪插件的外观

转载 作者:行者123 更新时间:2023-11-29 20:33:19 25 4
gpt4 key购买 nike

我已将此插件安装到我的 PhoneGap 项目中:

https://github.com/phonegap/phonegap-plugin-barcodescanner

它就像一个魅力。但是,我希望能够在扫描仪打开时打开一些按钮来导航应用程序。这样一来,当应用程序打开时,扫描仪会立即打开,这样他们就可以立即扫描条形码,然后在某个地方有一个按钮,他们可以在其中进入应用程序。

我试过查看插件 javascript 等,但它只有一个 javascript 文件,如下所示:

cordova.define("phonegap-plugin-barcodescanner.BarcodeScanner", function(require, exports, module) { /**
* cordova is available under *either* the terms of the modified BSD license *or* the
* MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
*
* Copyright (c) Matt Kane 2010
* Copyright (c) 2011, IBM Corporation
*/


var exec = require("cordova/exec");

/**
* Constructor.
*
* @returns {BarcodeScanner}
*/
function BarcodeScanner() {

/**
* Encoding constants.
*
* @type Object
*/
this.Encode = {
TEXT_TYPE: "TEXT_TYPE",
EMAIL_TYPE: "EMAIL_TYPE",
PHONE_TYPE: "PHONE_TYPE",
SMS_TYPE: "SMS_TYPE"
// CONTACT_TYPE: "CONTACT_TYPE", // TODO: not implemented, requires passing a Bundle class from Javascript to Java
// LOCATION_TYPE: "LOCATION_TYPE" // TODO: not implemented, requires passing a Bundle class from Javascript to Java
};

/**
* Barcode format constants, defined in ZXing library.
*
* @type Object
*/
this.format = {
"all_1D": 61918,
"aztec": 1,
"codabar": 2,
"code_128": 16,
"code_39": 4,
"code_93": 8,
"data_MATRIX": 32,
"ean_13": 128,
"ean_8": 64,
"itf": 256,
"maxicode": 512,
"msi": 131072,
"pdf_417": 1024,
"plessey": 262144,
"qr_CODE": 2048,
"rss_14": 4096,
"rss_EXPANDED": 8192,
"upc_A": 16384,
"upc_E": 32768,
"upc_EAN_EXTENSION": 65536
};
};

/**
* Read code from scanner.
*
* @param {Function} successCallback This function will recieve a result object: {
* text : '12345-mock', // The code that was scanned.
* format : 'FORMAT_NAME', // Code format.
* cancelled : true/false, // Was canceled.
* }
* @param {Function} errorCallback
*/
BarcodeScanner.prototype.scan = function (successCallback, errorCallback, config) {

if(config instanceof Array) {
// do nothing
} else {
if(typeof(config) === 'object') {
config = [ config ];
} else {
config = [];
}
}

if (errorCallback == null) {
errorCallback = function () {
};
}

if (typeof errorCallback != "function") {
console.log("BarcodeScanner.scan failure: failure parameter not a function");
return;
}

if (typeof successCallback != "function") {
console.log("BarcodeScanner.scan failure: success callback parameter must be a function");
return;
}

exec(successCallback, errorCallback, 'BarcodeScanner', 'scan', config);
};

//-------------------------------------------------------------------
BarcodeScanner.prototype.encode = function (type, data, successCallback, errorCallback, options) {
if (errorCallback == null) {
errorCallback = function () {
};
}

if (typeof errorCallback != "function") {
console.log("BarcodeScanner.encode failure: failure parameter not a function");
return;
}

if (typeof successCallback != "function") {
console.log("BarcodeScanner.encode failure: success callback parameter must be a function");
return;
}

exec(successCallback, errorCallback, 'BarcodeScanner', 'encode', [
{"type": type, "data": data, "options": options}
]);
};

var barcodeScanner = new BarcodeScanner();
module.exports = barcodeScanner;

});

最佳答案

适用于 Android 的 Phonegap 条码扫描器插件仅提供 Phonegap 和 ZXing 之间的接口(interface)。项目。它是 Android 的 ZXing 客户端,它定义了在“扫描模式”下显示的用户界面,这是 native 完成的(在 Java 中)而不是 Javascript。

要更改它,您需要编辑 library project由插件使用并在那里更改 native UI 代码。

关于javascript - 如何更改 Phonegaps 条码扫描仪插件的外观,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31681306/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com