mui.min.js &mon.js
!DOCTYPE html
html
head
meta charset= utf-8 /
meta name= viewport content= initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover /
meta name= HandheldFriendly content= true /
meta name= MobileOptimized content= 320 /
title 扫一扫 /title
script type= text/javascript src= common.js /script
script type= text/javascript src= mui.min.js /script
link rel= stylesheet href= common.css type= text/css charset= utf-8 /
script type= text/javascript
var ws=null,wo=null;
var scan=null;
// H5 plus恶性事件解决
function plusReady(){
// 获得对话框目标
ws=plus.webview.currentWebview();
nv=ws.getTitleNView();
wo=ws.opener();
// 刚开始扫描仪
ws.addEventListener( show , function(){
scan=new plus.barcode.Barcode( bcid ,[plus.barcode.QR,plus.barcode.EAN8,plus.barcode.EAN13],{frameColor: #00FF00 ,scanbarColor: #00FF00
scan.onmarked=onmarked;
scan.start({conserve:true,filename: _doc/barcode/
createSubview();
}, false);
// 显示信息网页页面并关掉等候框
ws.show();
document.addEventListener( plusready , plusReady, false);
// 二维码扫描仪取得成功
function onmarked(type, result, file){
switch(type){
case plus.barcode.QR:
type = QR //二维码
break;
case plus.barcode.EAN13:
type = EAN13 //13位条形码
break;
case plus.barcode.EAN8:
type = EAN8 //八位条形码
break;
default:
type = 其他 +type;//其他
break;
}
//分辨不是是网站地址
if(result.indexOf( / )==0){
//是网站地址,立即自动跳转
//plus.runtime.openURL(result);//启用手机上访问器自动跳转
mui.openWindow({//APP内带主要参数自动跳转
& ,//把結果传送给特定网页页面
id: deok ,
extras:{
result:result
}
});
//plus.webview.open(result, id //APP内没有主要参数立即自动跳转
//plus.webview.currentWebview().hide();//关掉对话框
//plus.webview.currentWebview().close( none //先掩藏再关掉对话框,不然网页页面会闪一下再关掉
//plus.webview.close( deok //关掉特定id的对话框
} else{
//并不是网站地址,复印出結果
alert(result);
scan.start({conserve:true, filename: _doc/barcode/ //扫描仪出結果后全自动再次扫描仪
//switchFlash();//开/关闪亮灯
function createSubview(){
view = new plus.nativeObj.View( nbutton , {
bottom: 20px ,
left: 30% ,
width: 40% ,
height: 44px
}, [{
tag: rect ,
id: rect ,
rectStyles: {
radius: 8px ,
color: rgba(255,0,0,0.8)
}},{
tag: font ,
id: text ,
text: 打开闪亮灯 ,
textStyles: {
color: #FFFFFF
}]);
// 解决点一下恶性事件
view.addEventListener( click , function(e){
switchScan();//更改按按键文本
}, false);
ws.append(view);
var bScan = false;
function switchScan(){
if(bScan){
switchFlash();
view (view.drawText( 打开闪亮灯 , {}, {color: #FFFFFF }, text
}else{
switchFlash();
view (view.drawText( 关掉闪亮灯 , {}, {color: #FFFFFF }, text
}
bScan=!bScan;
/script
style type= text/css
#bcid {
width: 100%;
position: absolute;
top: 0px;
bottom: 0px;
text-align: center;
.tip {
color: #FFFFFF;
font-weight: bold;
text-shadow: 0px -1px #103E4C;
/style
/head
的编码以下 !DOCTYPE html
html
head
meta charset= UTF-8
meta name= viewport content= width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no /
title 扫二维码結果 /title
style type= text/css /style
/head
body
div 下边是扫二维码网页页面传回来的数据信息 /div
div p id= data /p /div
script type= text/javascript
if (window.plus) {
plusready();
} else {
document.addEventListener( plusready , plusready, false);
}
function plusready() {
var w = plus.webview.currentWebview();
var result = w.result;//获得传送回来的主要参数
document.querySelector( #data ).innerText = result;//复印結果
//plus.webview.close( deok
//window.location.href=result;//自动跳转到总体目标网站地址
//解决回到恶性事件
plus.key.addEventListener( backbutton ,function() {plus.webview.currentWebview().close();})
}
/script
/body
假如你的难题还没有有处理,能够点一下网页页面右边的“ ”,网站站长接到难题之后尽早回应处理计划方案到你的电子邮箱。
造就起源于难题,拥有难题才会思索,拥有思索,才有处理难题的方式,才有寻找单独构思的将会。 —— 陶行知