Commit cbb9e6fc by 王锐

二维码 指纹

parent 6df0cc38
......@@ -56,6 +56,20 @@
text-align: center;
background: greenyellow;
}
#upload{
width: 100%;
height: 40px;
line-height: 40px;
text-align: center;
background: greenyellow;
}
#figer{
width: 100%;
height: 40px;
line-height: 40px;
text-align: center;
background: greenyellow;
}
</style>
<body>
<br>
......@@ -75,12 +89,16 @@
<div id="filedownload">下载文件</div>
<br />
<div id="uuid">设备唯一标识</div>
<br />
<div id="upload">上传</div>
<br />
<div id="figer">指纹</div>
</body>
</html>
<script src="js/jquery-3.2.1.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/methods.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
document.addEventListener('plusready', function() {
document.addEventListener('plusready', function() {}, false);
var btn = document.getElementById('btn')
var btn2 = document.getElementById('btn2')
var data = JSON.stringify({
......@@ -173,13 +191,15 @@
alert('no')
},
)
}, false);
$("#filedownload").on("click", function() {
var arr=["http://img-cdn-qiniu.dcloud.net.cn/static/images/activity/plugin-side.png","https://www.baidu.com/img/bd_logo1.png"]
//http://img-cdn-qiniu.dcloud.net.cn/static/images/activity/plugin-side.png
var arr = ["http://img-cdn-qiniu.dcloud.net.cn/static/images/activity/plugin-side.png",
"https://www.baidu.com/img/bd_logo1.png"
]
//http://img-cdn-qiniu.dcloud.net.cn/static/images/activity/plugin-side.png
// var downUrl = "https://www.baidu.com/img/bd_logo1.png"
var savePath = "image/"
......@@ -190,15 +210,68 @@
function error(res) {
alert(res)
}
for(var i=0; i<arr.length; i++){
fileDownload(arr[i], savePath, success, error);
function presence(res) {
alert(res)
}
for (var i = 0; i < arr.length; i++) {
fileDownload(arr[i], savePath, success, error, presence);
}
})
$("#uuid").on("click",function(){
getUuid(function success(res){
$("#uuid").on("click", function() {
getUuid(function success(res) {
alert(res)
})
})
})
$("#upload").on("click", function() {
createUpload(url, path)
})
$("#figer").on("click", function() {
if (plus.fingerprint) {
if (plus.fingerprint.isSupport()) {
if (plus.fingerprint.isKeyguardSecure()) {
if (plus.fingerprint.isEnrolledFingerprints()) {
fingerpring()
} else {
alert("未设置指纹")
}
} else {
alert("未设置锁屏密码")
}
} else {
alert("不支持指紋")
}
} else {
console.log("请更新版本");
}
})
function fingerpring() {
var waiting = null;
plus.fingerprint.authenticate(function() {
plus.nativeUI.closeWaiting(); //兼容Android平台关闭等待框
alert('指纹识别成功');
}, function(e) {
switch (e.code) {
case e.AUTHENTICATE_MISMATCH:
plus.nativeUI.toast('指纹匹配失败,请重新输入');
break;
case e.AUTHENTICATE_OVERLIMIT:
plus.nativeUI.closeWaiting(); //兼容Android平台关闭等待框
plus.nativeUI.alert('指纹识别失败次数超出限制,请使用其它方式进行认证');
break;
default:
plus.nativeUI.closeWaiting(); //兼容Android平台关闭等待框
plus.nativeUI.alert('指纹识别失败(' + e.code + '),请重试');
break;
}
});
// Android平台弹出等待提示框
if ('Android' == plus.os.name) {
plus.nativeUI.showWaiting('指纹识别中...');
}
}
</script>
......@@ -226,3 +226,21 @@ function readerFile(path, name, success, error) {
function getUuid(success){
success(plus.device.uuid )
}
//上传文件
function createUpload(url,path) {
var task = plus.uploader.createUpload( url,
{ method:"POST",blocksize:204800,priority:100 },
function ( t, status ) {
// 上传完成
if ( status == 200 ) {
alert( "Upload success: " + t.url );
} else {
alert( "Upload failed: " + status );
}
}
);
task.addFile( path, {key:"testdoc"} ); //文件
// task.addData( "string_key", "string_value" );
//task.addEventListener( "statechanged", onStateChanged, false );
task.start();
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>barcode_scan</name>
<comment>Create By HBuilder</comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.pandora.projects.ui.MKeyBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.aptana.ide.core.unifiedBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.pandora.projects.ui.MKeyNature</nature>
<nature>com.aptana.projects.webnature</nature>
</natures>
<filteredResources>
<filter>
<id>1514176249296</id>
<name></name>
<type>10</type>
<matcher>
<id>org.eclipse.ui.ide.orFilterMatcher</id>
<arguments>
<matcher>
<id>org.eclipse.ui.ide.multiFilter</id>
<arguments>1.0-projectRelativePath-matches-false-false-bin</arguments>
</matcher>
<matcher>
<id>org.eclipse.ui.ide.multiFilter</id>
<arguments>1.0-projectRelativePath-matches-false-false-setting</arguments>
</matcher>
</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
<!DOCTYPE html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="HandheldFriendly" content="true" />
<meta name="MobileOptimized" content="320" />
<title>二维码扫描</title>
<!-- <link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" /> -->
<style type="text/css">
#bcid {
width: 100%;
position: absolute;
top: 0px;
bottom: 44px;
text-align: center;
}
.tip {
color: #FFFFFF;
font-weight: bold;
text-shadow: 0px -1px #103E5C;
}
footer {
width: 100%;
height: 44px;
position: absolute;
bottom: 0px;
line-height: 44px;
text-align: center;
color: #FFF;
}
.fbt {
width: 50%;
height: 100%;
background-color: #FFCC33;
float: left;
}
.fbt:active {
-webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.5);
box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.5);
}
</style>
<script type="text/javascript" src="js/common.js"></script>
<script type="text/javascript">
var isOpen = false;
var ws = null,
wo = null;
var scan = null,
domready = false;
// H5 plus事件处理
function plusReady() {
if(ws || !window.plus || !domready) {
return;
}
// 获取窗口对象
ws = plus.webview.currentWebview();
// 开始扫描
ws.addEventListener('show', function() {
scan = new plus.barcode.Barcode('bcid');
scan.onmarked = onmarked;
scan.start({
conserve: true,
filename: '_doc/barcode/'
});
}, false);
// 显示页面并关闭等待框
ws.show('pop-in');
}
if(window.plus) {
plusReady();
} else {
document.addEventListener('plusready', plusReady, false);
}
// 监听DOMContentLoaded事件
document.addEventListener('DOMContentLoaded', function() {
domready = true;
plusReady();
}, false);
// 二维码扫描成功
function onmarked(type, result, file) {
switch(type) {
case plus.barcode.QR:
type = 'QR';
break;
case plus.barcode.EAN13:
type = 'EAN13';
break;
case plus.barcode.EAN8:
type = 'EAN8';
break;
default:
type = '其它' + type;
break;
}
result = result.replace(/\n/g, '');
plus.nativeUI .alert('扫描结果:' + JSON.stringify(result), function() {
console.log('扫描成功')
}, "二维码扫描", "OK");
back();
}
// 从相册中选择二维码图片
function scanPicture() {
plus.gallery.pick(function(path) {
plus.barcode.scan(path, onmarked, function(error) {
plus.nativeUI.alert('无法识别此图片');
});
}, function(err) {
console.log('Failed: ' + err.message);
});
}
function setFlash(){
isOpen = !isOpen;
if(isOpen){
scan.setFlash(true);
}else{
scan.setFlash(false);
}
}
</script>
</head>
<body style="background-color: #000000;">
<div id="bcid">
<div style="height:40%"></div>
<p class="tip">...载入中...</p>
</div>
<footer>
<div class="fbt" onclick="scanPicture()">从相册选择二维码</div>
<div class="fbt" onclick="setFlash()">是否开启闪光灯</div>
</footer>
</body>
</html>
\ No newline at end of file
* {
* {
-webkit-user-select: none;
-ms-touch-select: none;
/*
-ms-touch-action: none;
*/
}
html {
width: 100%;
height: 100%;
}
body {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
font-family: Arial;
font-size:16px;
color: #6c6c6c;
-webkit-touch-callout:none;
-webkit-tap-highlight-color:rgba(0,0,0,0);
-webkit-text-size-adjust:none;
}
header {
width: 100%;
height: 44px;
position: fixed;
top: 0;
left: 0;
font-size: 17px;
text-align: center;
line-height: 44px;
background: #D74B28;
/*background: -webkit-linear-gradient(top,rgba(215,75,40,1),rgba(215,75,40,0.8));*/
z-index: 9999;
/*border-bottom: 1px solid rgba(215,75,40,0.8);*/
-ms-touch-action: none;
}
.nvbt {
width:15%;
height:100%;
float:left;
overflow:hidden;
text-overflow:ellipsis;
white-space:nowrap;
}
.nvbt:active {
background-color: rgba(170,170,170,0.1);
}
.nvtt {
width: 70%;
height: 100%;
color: #f7f7f7;
float: left;
overflow:hidden;
text-overflow:ellipsis;
white-space:nowrap;
}
.content {
text-align: center;
padding-top: 44px;
}
.scontent {
width: 100%;
position: fixed;
top: 44px;
bottom: 0px;
text-align: center;
overflow-y: scroll;
-webkit-overflow-scrolling: touch;
-ms-touch-action: pan-y cross-slide-y;
-ms-scroll-chaining: none;
-ms-scroll-limit: 0 50 0 50;
}
.dcontent {
text-align: center;
padding-top: 44px;
padding-bottom: 80px;
}
.sdcontent {
width: 100%;
position: fixed;
top: 44px;
bottom: 80px;
text-align: center;
overflow-y: scroll;
-webkit-overflow-scrolling: touch;
-ms-touch-action: pan-y cross-slide-y;
-ms-scroll-chaining: none;
-ms-scroll-limit: 0 50 0 50;
}
.heading {
margin:0 1em;
text-align:left;
}
.des {
padding: 0 1em;
text-align:left;
text-indent: 2em;
word-break: break-all;
}
.logo {
width: 100%;
text-align: center;
}
.button {
font-size: 18px;
font-weight: normal;
text-decoration: none;
display: block;
text-align: center;
overflow:hidden;
text-overflow:ellipsis;
white-space:nowrap;
color: #FFF;
background-color: #FFCC33;
border: 1px solid #ECB100;
padding: .5em 0em;
margin: .5em .7em;
-webkit-border-radius: 5px;
border-radius: 5px;
}
.button:active {
outline: 0;
-webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125);
box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125);
}
.button-waring {
color: #666;
background-color: #ebebeb;
border-color: #e0e0e0;
}
.button-select {
font-size: 14px;
background-color: #CCCCCC;
border: 0;
-webkit-border-radius: 2px;
border-radius: 2px;
}
.dlist {
padding: 0px;
margin: 1em;
background: #fff;
border: 1px solid #ddd;
-webkit-border-radius: 3px;
border-radius: 3px;
}
.ditem {
overflow: hidden;
list-style-type: none;
font-size: 1em;
padding: 1em;
border-bottom: inset 1px #ebebeb;
vertical-align: middle;
}
.ditem:active {
background: #f4f4f4;
}
.ditem:last-child {
border-bottom: inset 0px #ebebeb;
}
.ditem-empty {
overflow: hidden;
list-style-type: none;
font-size: 1em;
padding: 1em;
vertical-align: middle;
}
#output {
height: 64px;
position: fixed;
left: 0;
right: 0;
bottom: 0;
color: #f00;
background: #FFF;
font-size: 12px;
line-height: 16px;
word-break: break-all;
z-index: 6666;
padding: 8px 16px;
overflow-x: hidden;
overflow-y: scroll;
border-top: 2px solid #AAA;
-webkit-overflow-scrolling: touch;
}
.iback {
background: no-repeat center center url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABYCAYAAAADWlKCAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAKwwAACsMBNCkkqwAAABZ0RVh0Q3JlYXRpb24gVGltZQAwOS8xMi8xM5w+I3MAAAAcdEVYdFNvZnR3YXJlAEFkb2JlIEZpcmV3b3JrcyBDUzVxteM2AAACcklEQVR4nO3a0XESURiG4TeO99iBWoGZ+RvADtKBpAPtwBLsANJBrEAs4MyYDmIHSQXkgk0mMLK7ILt8/+F778ici394OGfDsher1Qqn05tTD+A2M4hYBhHLIGIZRCyDiGUQsQwilkHEMohYBhHLIGIZRCyDiGUQsQwilkHEMohYBhHLIGIZRCyDiGUQsQwilkHEMohYb089wNCVUq6Ay+blfUQsTjhOZxc1P9tbSlkAX7b+/C0ifpxgnF5Ve2TtwAD4OvIoe1UlSAsGwPsRR9m76kA6MAD+jjTKQVUF0gMD4HaEUQ6umot6T4ybiJgNP83hVbFDasGACnZIT4yfEXE1wjj/Xeod0hPjDpgNPsyRSguyB8Y0Ih6Gn+g4pQSpFQMSgtSMAclAaseARCDngAFJQM4FAxKAnBMGiH8xLKVMgV89ln6MiPthpxkn6R0SEUvgusfSZSnlsnuZftI75LlSygyYdyx7ZH1s/Rl+ouFKAQIvx9ctMGlZlh4lDQhAcywtqRhF+hqyXfMmT1m/6buasL6mzMaY6dilAoENlLuWZRNgnhEl1ZH1ulLKO9bH16eOpdfqz2K9Lt0Oea75EjilfadAsp2SFgQ2UH53LJ2XUr4PPtARSntkbVfL7+rVgEBvlM/NHQDJUh9Z2zWf/puOZbPhJzm8qkDgBaXt/teHcSY5rOpAAJp/c/vclJSrShDYifKI+NPvVV3U/1VzU3LavFyo/25SPUi2qj2ysmYQsQwilkHEMohYBhHLIGIZRCyDiGUQsQwilkHEMohYBhHLIGIZRCyDiGUQsQwilkHEMohYBhHLIGIZRCyDiGUQsZ4Ak9fPFwUy/HsAAAAASUVORK5CYII=);
background-size: 50px 44px;
color: #f7f7f7;
}
.idoc {
background: no-repeat center center url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABYCAYAAAADWlKCAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAKwwAACsMBNCkkqwAAABZ0RVh0Q3JlYXRpb24gVGltZQAwOS8xMi8xM5w+I3MAAAAcdEVYdFNvZnR3YXJlAEFkb2JlIEZpcmV3b3JrcyBDUzVxteM2AAAC2klEQVR4nO3bMU9TURjG8T9qIpskDjqYUAejm5B3MS4yOJoUNzd0dCJ+Av0IMrrVTSfK5oiT05vAJG64OUp0carDOdBbjLWBYp+W55fckHC5Nyf8c+5pk3Pner0epuPCpAdggxxEjIOIcRAxDiLGQcQ4iBgHEeMgYhxEjIOIcRAxDiLGQcQ4iBgHEeMgYhxEjIOIcRAxDiLGQcQ4iBgHEXNp0gMYVWY+BV4DO0AX2I6InYkO6gzMqe9czMwFSog2JcQqsFBPfwW2gW5EdCcywDGTDpKZS0AH6AGPgW/APeAi8AhYAZYal2zRD7T//0Y6PrJBGo+oTeAFME+ZHdfqnxwA+8AP4EY9t8Lg7Dl8tE3N7JEMkpkdYA14FhGdzGwBT4DLQy77Qgl0FXhICdSq5w6oM4cSaH/8ox4P1UV9DXhLWcABrgCfKf/ghb9cc7seUOI8B34CQZk5q5R1iMzcpQTqqH0wUJ0hzUEdLdz15zywSIlzZ4Tb/QL2KLPnFnCfxuyJiLlxjHlcpiHIcQMLd2YuUsK0gOsj3P4rJdAncJCR/CNI08DCnZnzlMdWi+GPN4BXoBdk2r+pLwLrwGaN+A5YBnYjYgN4A3ygzIipoLqon1SbPxfubkS8r797ObmhjWbWgjTdrcc6IPVYGmbaH1kzx0HEOIgYBxHjIGIcRIyDiHEQMQ4ixkHEOIgYBxHjIGIcRIyDiHEQMQ4ixkHEOIgYBxHjIGJUgyzTfznnXJHcBlQ3QO8A1J3vbfobpsfp+5jvd2qSQZrqqwMb9SAz2/TfBWmd8LZ7lFnoIKcVEVuUDdeHb1gdBloadl3DdkR8PKPhnZrkZuuTqO8iNmfP0UZrtQ3Vw8xMkOMy8wElzmpE3Jz0eEY1s0GmlerH3nPLQcQ4iBgHEeMgYhxEjIOIcRAxDiLGQcQ4iBgHEeMgYhxEjIOIcRAxDiLGQcQ4iBgHEeMgYhxEjIOI+Q2gWbiBmTXKQQAAAABJRU5ErkJggg==);
background-size: 50px 44px;
}
\ No newline at end of file
<!DOCTYPE html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>扫一扫示例页面</title>
<style type="text/css">
#open_barcode {
display: block;
margin:50px auto;
padding: 10px 20px;
background-color: #D74B28;
color:#fff;
outline: none;
border:none;
}
</style>
</head>
<body>
<button id="open_barcode">打开扫一扫页面</button>
<script>
(function(){
var openBtn = document.getElementById('open_barcode');
document.addEventListener('plusready', function(){
console.log('plusready');
});
openBtn.addEventListener('click', function(e){
var barcodeWV = plus.webview.create('barcode_scan.html','barcode', {
titleNView: {
titleText:'二维码扫描',
titleColor:'#fff',
backgroundColor:'#D74B28',
autoBackButton:true
}
});
barcodeWV.show('slide-in-right',300);
})
})();
</script>
</body>
</html>
\ No newline at end of file
{
{
"index.html": {
"refer": [
"barcode_scan.html"
]
}
}
\ No newline at end of file
null
null
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment