8***@qq.com
8***@qq.com
  • 发布:2019-04-01 18:53
  • 更新:2019-04-09 22:00
  • 阅读:2046

有没有h5扫一扫的案例的?

分类:uni-app

h5扫一扫是自己写个h5页面的不?用<web-view src="/hybrid/html/scanCode.html"></web-view>这样的?
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script type="text/javascript" src="//js.cdn.aliyun.dcloud.net.cn/dev/uni-app/uni.webview.0.1.52.js"></script>
<script type="text/javascript">
var barcode = null;
var scanCode='';
// 扫码成功回调
function onmarked(type, result) {
var text = '未知: ';
switch (type) {
case plus.barcode.QR:
text = 'QR: ';
break;
}
alert(text + result);
scanCode=result;
}
// 创建扫码控件
function createBarcode() {
if (!barcode) {
barcode = plus.barcode.create('barcode', [plus.barcode.QR], {
top: '100px',
left: '0px',
width: '100%',
height: '500px',
position: 'static'
});
barcode.onmarked = onmarked;
plus.webview.currentWebview().append(barcode);
}
barcode.start();
}
document.addEventListener('UniAppJSBridgeReady', function() {
createBarcode();
uni.reLauch({
url: '/pages/tabbar/component/component?scanCode='+scanCode
})
});
</script>
<style type="text/css">

  • {
    -webkit-user-select: none;
    }

        html,  
        body {  
            margin: 0px;  
            padding: 0px;  
            height: 100%;  
        }  
    </style>  

    </head>
    <body>
    </body>
    </html>

2019-04-01 18:53 负责人:无 分享
已邀请:
[已删除]

[已删除]

5+demo就有

该问题目前已经被锁定, 无法添加新回复