|
源码:define(function(require){
var $ = require("jquery");
var justep = require("$UI/system/lib/justep");
require("$UI/system/lib/cordova/cordova");
require("cordova!com.phonegap.plugins.barcodescanner");
var Model = function(){
this.callParent();
this.STORE_ID = "com.justep.demo.advice.barcodedata";
};
Model.prototype.ticketCreate = function(event){
event.source.limit = 2;
};
$(function(){
$('.x-panel-content').scroll(function(){
var hh=$('.x-panel-content').scrollTop();
if( hh > 0){
$('.x-titlebar').addClass('bgtop');
$('.x-titlebar').find('img.ss').attr('src','img/scan1.png');
}else{
$('.x-titlebar').removeClass('bgtop');
$('.x-titlebar').find('img.ss').attr('src','img/scan.png');
}
});
});
//扫一扫
Model.prototype.button3Click = function(event){
var data = this.comp("fileData");
this.comp('titleOutput').set({value: "扫描二维码"});
this.comp('codeOutput').set({value: ""});
this.comp('fileOutput').set({value: ""});
var me = this;
function onSuccess(result) {
data.newData({index : 0});
data.setValue("filePath", result.text);
data.setValue("fileName", result.format);
data.setValue('createTime', justep.Date.toString(new Date(), justep.Date.DEFAULT_FORMAT));
me.comp('titleOutput').set({value: "扫描成功!"});
me.comp('codeOutput').set({value: result.format});
me.comp('fileOutput').set({value: result.text});
}
function onError(error) {
me.comp('titleOutput').set({value: "扫描失败!" + error});
}
cordova.plugins.barcodeScanner.scan(onSuccess, onError);
};
Model.prototype.modelLoad = function(event){
var me = this;
document.addEventListener("deviceready", onDeviceReady, false);
// 加载完成
function onDeviceReady() {
me.comp("scanBtn").set({disabled: false});
if(localStorage.getItem(me.STORE_ID) != "")
me.comp("fileData").loadData(JSON.parse(localStorage.getItem(me.STORE_ID)));
}
};
return Model;
});
|
-
报错信息
|