|
我调用了codova,但是搞不懂barcodetext 为什么第一次的值是空的,在sendrequest里面调不到,第二次又有值了,想问下codova里面要将变量的值传递出来,是通过全局变量,还是通过其他的方法。
cordova.plugins.barcodeScanner.scan(function(result) {
barcodetext = result.text;
alert("barcodetext"+barcodetext);
alert("We got a barcode\n" + "Result: " + result.text + "\n" + "Format: " + result.format + "\n" + "Cancelled: " + result.cancelled);
}, function(error) {
alert("Scanning failed: " + error);
});
//+
alert("开始servlet"+barcodetext);
if (barcodetext != null) {
justep.Baas.sendRequest({
"url" : "/oa/checkin",
"action" : "signIn",
"async" : false,
"params" : {
"barcodetext" : barcodetext,
"userid" : userid
},
"success" : function(date) {
alert(date.state);
// 获取返回值,存放到output1组件中
// me.comp("output1").set({
// "value" : data.code
// });
}
});
} |
|