扫描二维码
来源:互联网 发布:python 创建临时文件 编辑:程序博客网 时间:2024/05/21 09:00
define(function(require) {
var $ = require("jquery");
var justep = require("$UI/system/lib/justep");
require("$UI/system/lib/cordova/cordova");
require("css!$UI/demo/native/common/pub").load();
require("cordova!phonegap-plugin-barcodescanner");
var Model = function() {
this.callParent();
this.STORE_ID = "com.justep.demo.advice.barcodedata";
};
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)));
}
};
// 关闭功能
Model.prototype.backBtnClick = function(event) {
localStorage.setItem(this.STORE_ID, JSON.stringify(this.comp("fileData").toJson(false)));
justep.Shell.closePage();
};
//扫描二维码
Model.prototype.scanBtnClick = 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.fileListClick = function(event) {
this.comp('titleOutput').set({value: ""});
this.comp('codeOutput').set({value: ""});
this.comp('fileOutput').set({value: ""});
var data = this.comp("fileData");
var codeText = data.getValue("filePath");
if(codeText.indexOf("http") > -1){
window.open(codeText, '_blank', 'toolbarposition=top,location=no,enableViewportScale=yes');
}else{
alert(codeText);
}
};
// 清空历史记录
Model.prototype.deleteBtnClick = function(event) {
this.comp("fileData").clear();
this.comp('titleOutput').set({value: "清空历史记录"});
this.comp('codeOutput').set({value: ""});
this.comp('fileOutput').set({value: ""});
localStorage.setItem(this.STORE_ID, "");
};
return Model;
});
var $ = require("jquery");
var justep = require("$UI/system/lib/justep");
require("$UI/system/lib/cordova/cordova");
require("css!$UI/demo/native/common/pub").load();
require("cordova!phonegap-plugin-barcodescanner");
var Model = function() {
this.callParent();
this.STORE_ID = "com.justep.demo.advice.barcodedata";
};
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)));
}
};
// 关闭功能
Model.prototype.backBtnClick = function(event) {
localStorage.setItem(this.STORE_ID, JSON.stringify(this.comp("fileData").toJson(false)));
justep.Shell.closePage();
};
//扫描二维码
Model.prototype.scanBtnClick = 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.fileListClick = function(event) {
this.comp('titleOutput').set({value: ""});
this.comp('codeOutput').set({value: ""});
this.comp('fileOutput').set({value: ""});
var data = this.comp("fileData");
var codeText = data.getValue("filePath");
if(codeText.indexOf("http") > -1){
window.open(codeText, '_blank', 'toolbarposition=top,location=no,enableViewportScale=yes');
}else{
alert(codeText);
}
};
// 清空历史记录
Model.prototype.deleteBtnClick = function(event) {
this.comp("fileData").clear();
this.comp('titleOutput').set({value: "清空历史记录"});
this.comp('codeOutput').set({value: ""});
this.comp('fileOutput').set({value: ""});
localStorage.setItem(this.STORE_ID, "");
};
return Model;
});
阅读全文
0 0
- 二维码扫描
- 二维码扫描
- 二维码扫描
- 二维码扫描
- 二维码扫描
- 二维码扫描
- 二维码扫描
- 二维码扫描
- 二维码扫描
- 扫描二维码
- 二维码扫描
- 二维码扫描
- 二维码扫描
- 二维码扫描
- 扫描二维码
- 二维码扫描
- 二维码扫描
- 扫描二维码
- 好的博客地址们
- 亲测有用的Mac Android Studio 查看SHA1 的方法
- Java数据库配置一
- Messages: No result defined for action cn.itcast.oa.test.TestAction and result SUCCESS
- c#开发环境下用Directx载入3D模型
- 扫描二维码
- SDN控制器之OVN实验四:配置OVN负载均衡器
- php 通过经纬度获取距离
- 设计模式单例模式
- Problem C: 一元二次方程类
- Sqlite 分组查询
- 【Jsoup】配合 htmlunit 爬取异步加载的网页
- REST架构
- JAVA的动态代理入门